summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xtools/bdf2c29
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+)/;