From ba39ff62e5ee88f7defd04fa6b1165bcbe36183d Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 13 Sep 2002 06:31:16 +0000 Subject: Greg Haerr added -limit git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2282 a1c6a512-1295-4272-9138-f99709370657 --- tools/bdf2c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'tools') 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 # # from The Microwindows Project (http://microwindows.org) # +# modified 09/12/02 added -limit 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 ] 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 () { 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+)/; -- cgit v1.2.3