From 98174cb391042ba9201423aeb2766300f473f61a Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Fri, 11 Jul 2014 20:10:31 -0400 Subject: write_fbcon(): Write bitmaps --- diff --git a/bin/bdf2fbcon b/bin/bdf2fbcon index f7501b1..85e469e 100755 --- a/bin/bdf2fbcon +++ b/bin/bdf2fbcon @@ -283,8 +283,14 @@ sub parse_bdf_2_1 sub write_fbcon { my ($output_fh, $font) = @_; + my $bytes_x; my $i; my $char; + my $j; + my $bitmap; + my $k; + + $bytes_x = int(($font->{'width'} + 7) / 8); for (@{$font->{'comments'}}) { printf($output_fh "/* %s */\n", $_); @@ -292,7 +298,7 @@ sub write_fbcon printf($output_fh "/* Generated by bdf2fbcon */\n\n"); printf($output_fh "#include \n\n"); printf($output_fh "#define FONTDATAMAX %d\n\n", - int(($font->{'width'} + 7) / 8) * $font->{'height'} * 256); + $bytes_x * $font->{'height'} * 256); printf($output_fh "static const unsigned char" . " fontdata_%s[FONTDATAMAX] = {\n", $font->{'name'}); @@ -301,6 +307,16 @@ sub write_fbcon $char = $font->{'chars'}[$i]; printf($output_fh "\n\t/* %3d 0x%02x '%s' */\n", $i, $i, $char->{'name'}); + for ($j = 0; $j < $font->{'height'}; ++$j) { + $bitmap = $char->{'bitmap'}[$i]; + printf($output_fh "\t"); + $bitmap <<= $bytes_x * 8 - $font->{'width'}; + for (my $k = ($bytes_x - 1) * 8; $k >= 0; $k -= 8) { + printf("0x%02x, ", ($bitmap >> $k) & 0xFF); + } + printf($output_fh "/* %0" . $font->{'width'} . "b */\n", + $bitmap); + } } printf($output_fh "\n};\n\n"); -- cgit v0.9.1