diff options
author | Daniel Stenberg <daniel@haxx.se> | 2002-09-13 06:31:16 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2002-09-13 06:31:16 +0000 |
commit | ba39ff62e5ee88f7defd04fa6b1165bcbe36183d (patch) | |
tree | 24a6c3603d2e971b5787912a6179ef51628b64d7 | |
parent | ae0c23847ba0b2c98d830480f98b998d7f3bec1a (diff) | |
download | rockbox-ba39ff62e5ee88f7defd04fa6b1165bcbe36183d.tar.gz rockbox-ba39ff62e5ee88f7defd04fa6b1165bcbe36183d.zip |
Greg Haerr added -limit <max_encode_hex_value>
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2282 a1c6a512-1295-4272-9138-f99709370657
-rwxr-xr-x | tools/bdf2c | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/tools/bdf2c b/tools/bdf2c index ff3d5ed3b3..e6b8ee7df7 100755 --- a/tools/bdf2c +++ b/tools/bdf2c @@ -1,10 +1,11 @@ #! /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> # # 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 # - fixed DWIDTH 0 parsing # - don't limit font size to 0x7e characters @@ -19,12 +20,28 @@ use POSIX; +$name = (reverse split /\//, $0)[0]; +$limit_char = 65535; + +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: convbdf font.bdf > font.c\n"; - exit -1; + print "Usage: $name [-limit <max_encode_hex_value>] font.bdf > font.c\n"; + exit 1; } -##$LAST_CHAR = 0x7e; $IMAGE_BITS = 16; $IMAGE_NIBBLES = $IMAGE_BITS/4; $IMAGE_MASK = 0xffff; @@ -35,7 +52,7 @@ $font = $file; $font =~ s/\.bdf//; $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"; open BDF, "<$file" || die; @@ -73,7 +90,7 @@ while (<BDF>) { chop; undef $encoding, undef $width, undef $bbx, undef $bby, undef $bbw, undef $bbh if /^STARTCHAR /; $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 = $font_width if defined $width && $width <= 0; ($bbw, $bbh, $bbx, $bby) = ($1, $2, $3, $4) if /^BBX (-?\d+) (-?\d+) (-?\d+) (-?\d+)/; |