summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-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 @@
1#! /usr/bin/perl -w 1#! /usr/bin/perl -w
2# 2#
3# Convert BDF files to incore MWCFONT structure 3# Convert BDF files to incore MWCFONT structure 'C' source
4# Copyright (c) 2002 by Greg Haerr <greg@censoft.com> 4# Copyright (c) 2002 by Greg Haerr <greg@censoft.com>
5# 5#
6# from The Microwindows Project (http://microwindows.org) 6# from The Microwindows Project (http://microwindows.org)
7# 7#
8# modified 09/12/02 added -limit <max_encode_hex_value> option
8# modified on 09/10/02 by G Haerr 9# modified on 09/10/02 by G Haerr
9# - fixed DWIDTH 0 parsing 10# - fixed DWIDTH 0 parsing
10# - don't limit font size to 0x7e characters 11# - don't limit font size to 0x7e characters
@@ -19,12 +20,28 @@
19 20
20use POSIX; 21use POSIX;
21 22
23$name = (reverse split /\//, $0)[0];
24$limit_char = 65535;
25
26while (defined $ARGV[0]) {
27 my $arg = shift;
28
29 if (($arg eq "-limit") && scalar(@ARGV) > 0) {
30 $limit_char = hex shift;
31 } elsif ($arg =~ "-.+") {
32 print "$name: unknown option '$arg'\n";
33 exit 1;
34 } else {
35 unshift(@ARGV, $arg);
36 last;
37 }
38}
39
22if ($#ARGV < 0) { 40if ($#ARGV < 0) {
23 print "Usage: convbdf font.bdf > font.c\n"; 41 print "Usage: $name [-limit <max_encode_hex_value>] font.bdf > font.c\n";
24 exit -1; 42 exit 1;
25} 43}
26 44
27##$LAST_CHAR = 0x7e;
28$IMAGE_BITS = 16; 45$IMAGE_BITS = 16;
29$IMAGE_NIBBLES = $IMAGE_BITS/4; 46$IMAGE_NIBBLES = $IMAGE_BITS/4;
30$IMAGE_MASK = 0xffff; 47$IMAGE_MASK = 0xffff;
@@ -35,7 +52,7 @@ $font = $file;
35$font =~ s/\.bdf//; 52$font =~ s/\.bdf//;
36$font =~ tr/a-zA-Z0-9_/_/cs; 53$font =~ tr/a-zA-Z0-9_/_/cs;
37 54
38print "/* Generated by convbdf on ", substr(`date`, 0, -1), ". */\n"; 55print "/* Generated by $name on ", substr(`date`, 0, -1), ". */\n";
39print "#include \"font.h\"\n\n"; 56print "#include \"font.h\"\n\n";
40 57
41open BDF, "<$file" || die; 58open BDF, "<$file" || die;
@@ -73,7 +90,7 @@ while (<BDF>) {
73 chop; 90 chop;
74 undef $encoding, undef $width, undef $bbx, undef $bby, undef $bbw, undef $bbh if /^STARTCHAR /; 91 undef $encoding, undef $width, undef $bbx, undef $bby, undef $bbw, undef $bbh if /^STARTCHAR /;
75 $encoding = $1 if /^ENCODING (\d+)/; 92 $encoding = $1 if /^ENCODING (\d+)/;
76## last if defined $encoding && $encoding > $LAST_CHAR; 93 last if defined $encoding && $encoding > $limit_char;
77 $width = $1 if /^DWIDTH (-?\d+)/; 94 $width = $1 if /^DWIDTH (-?\d+)/;
78 $width = $font_width if defined $width && $width <= 0; 95 $width = $font_width if defined $width && $width <= 0;
79 ($bbw, $bbh, $bbx, $bby) = ($1, $2, $3, $4) if /^BBX (-?\d+) (-?\d+) (-?\d+) (-?\d+)/; 96 ($bbw, $bbh, $bbx, $bby) = ($1, $2, $3, $4) if /^BBX (-?\d+) (-?\d+) (-?\d+) (-?\d+)/;