1
0
Fork 0
forked from len0rd/rockbox

Greg Haerr added -limit <max_encode_hex_value>

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2282 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Daniel Stenberg 2002-09-13 06:31:16 +00:00
parent ae0c23847b
commit ba39ff62e5

View file

@ -1,10 +1,11 @@
#! /usr/bin/perl -w #! /usr/bin/perl -w
# #
# Convert BDF files to incore MWCFONT structure # Convert BDF files to incore MWCFONT structure 'C' source
# Copyright (c) 2002 by Greg Haerr <greg@censoft.com> # Copyright (c) 2002 by Greg Haerr <greg@censoft.com>
# #
# from The Microwindows Project (http://microwindows.org) # from The Microwindows Project (http://microwindows.org)
# #
# modified 09/12/02 added -limit <max_encode_hex_value> option
# modified on 09/10/02 by G Haerr # modified on 09/10/02 by G Haerr
# - fixed DWIDTH 0 parsing # - fixed DWIDTH 0 parsing
# - don't limit font size to 0x7e characters # - don't limit font size to 0x7e characters
@ -19,12 +20,28 @@
use POSIX; use POSIX;
if ($#ARGV < 0) { $name = (reverse split /\//, $0)[0];
print "Usage: convbdf font.bdf > font.c\n"; $limit_char = 65535;
exit -1;
while (defined $ARGV[0]) {
my $arg = shift;
if (($arg eq "-limit") && scalar(@ARGV) > 0) {
$limit_char = hex shift;
} elsif ($arg =~ "-.+") {
print "$name: unknown option '$arg'\n";
exit 1;
} else {
unshift(@ARGV, $arg);
last;
}
}
if ($#ARGV < 0) {
print "Usage: $name [-limit <max_encode_hex_value>] font.bdf > font.c\n";
exit 1;
} }
##$LAST_CHAR = 0x7e;
$IMAGE_BITS = 16; $IMAGE_BITS = 16;
$IMAGE_NIBBLES = $IMAGE_BITS/4; $IMAGE_NIBBLES = $IMAGE_BITS/4;
$IMAGE_MASK = 0xffff; $IMAGE_MASK = 0xffff;
@ -35,7 +52,7 @@ $font = $file;
$font =~ s/\.bdf//; $font =~ s/\.bdf//;
$font =~ tr/a-zA-Z0-9_/_/cs; $font =~ tr/a-zA-Z0-9_/_/cs;
print "/* Generated by convbdf on ", substr(`date`, 0, -1), ". */\n"; print "/* Generated by $name on ", substr(`date`, 0, -1), ". */\n";
print "#include \"font.h\"\n\n"; print "#include \"font.h\"\n\n";
open BDF, "<$file" || die; open BDF, "<$file" || die;
@ -73,7 +90,7 @@ while (<BDF>) {
chop; chop;
undef $encoding, undef $width, undef $bbx, undef $bby, undef $bbw, undef $bbh if /^STARTCHAR /; undef $encoding, undef $width, undef $bbx, undef $bby, undef $bbw, undef $bbh if /^STARTCHAR /;
$encoding = $1 if /^ENCODING (\d+)/; $encoding = $1 if /^ENCODING (\d+)/;
## last if defined $encoding && $encoding > $LAST_CHAR; last if defined $encoding && $encoding > $limit_char;
$width = $1 if /^DWIDTH (-?\d+)/; $width = $1 if /^DWIDTH (-?\d+)/;
$width = $font_width if defined $width && $width <= 0; $width = $font_width if defined $width && $width <= 0;
($bbw, $bbh, $bbx, $bby) = ($1, $2, $3, $4) if /^BBX (-?\d+) (-?\d+) (-?\d+) (-?\d+)/; ($bbw, $bbh, $bbx, $bby) = ($1, $2, $3, $4) if /^BBX (-?\d+) (-?\d+) (-?\d+) (-?\d+)/;