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:
parent
ae0c23847b
commit
ba39ff62e5
1 changed files with 24 additions and 7 deletions
31
tools/bdf2c
31
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;
|
||||
|
||||
if ($#ARGV < 0) {
|
||||
print "Usage: convbdf font.bdf > font.c\n";
|
||||
exit -1;
|
||||
$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: $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+)/;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue