fix raw encoding for single chars

don't die if i want unknown chars from .bdf
This commit is contained in:
Stefan `Sec` Zehl 2011-05-23 02:56:28 +02:00
parent 4aaf35be4c
commit 446985c2aa
1 changed files with 8 additions and 3 deletions

View File

@ -164,14 +164,15 @@ for (0..$#charlist){
$c1size+=3; $c1size+=3;
$c2size+=1; $c2size+=1;
my $oneraw;
# If encoding is bigger, fall back to original char # If encoding is bigger, fall back to original char
if($#enc>$#raw+3){ if($#enc>$#raw+3){
warn "Compression failure: Encoding char $char raw.\n"; warn "Compression failure: Encoding char $char raw.\n";
$raw=1; $oneraw=1;
}; };
# Generate C source # Generate C source
if($raw){ if($raw||$oneraw){
$c2size-=scalar(@enc); $c2size-=scalar(@enc);
@enc=(255,$preblank,$postblank,@raw); @enc=(255,$preblank,$postblank,@raw);
$c2size+=scalar(@enc); $c2size+=scalar(@enc);
@ -501,6 +502,7 @@ sub getfontname {
###################################################################### ######################################################################
our $bdf; our $bdf;
our %chars; our %chars;
our $fallback;
sub init_bdf{ sub init_bdf{
($title,$licence)=($font,"<licence>"); ($title,$licence)=($font,"<licence>");
my($bb); my($bb);
@ -517,6 +519,7 @@ sub init_bdf{
/^COPYRIGHT "(.*)"/ && do {$licence=$1;}; /^COPYRIGHT "(.*)"/ && do {$licence=$1;};
/^FAMILY_NAME "(.*)"/ && do {$title=$1;}; /^FAMILY_NAME "(.*)"/ && do {$title=$1;};
/^FONTBOUNDINGBOX (\d+) (\d+)/ && do {$bb="$1x$2";}; /^FONTBOUNDINGBOX (\d+) (\d+)/ && do {$bb="$1x$2";};
/^DEFAULT_CHAR (\d+)/ && do {$fallback=$1;};
last if /^ENDPROPERTIES/; last if /^ENDPROPERTIES/;
}; };
@ -577,8 +580,10 @@ sub init_bdf{
sub render_bdf{ sub render_bdf{
my $ccode=$charlist[shift]; my $ccode=$charlist[shift];
# print "Char: $ccode:\n";
$ccode=$fallback if !defined $chars{$ccode};
my $tchar=$chars{$ccode}; my $tchar=$chars{$ccode};
# print "Char: $ccode:\n",join("\n",@{$tchar}),"\nEND\n"; # print join("\n",@{$tchar}),"\nEND\n";
return @{$tchar}; return @{$tchar};
}; };