5 # Convert a font hex file (http://unifoundry.com/unifont.html) to
6 # a .data section suitable for assembly by gas.
16 } elsif (@ARGV == 2) {
17 open $in, "<$ARGV[0]" or die "Unable to read $ARGV[0]: $!\n";
18 open $out, ">$ARGV[1]" or die "Unable to write $ARGV[1]: $!\n";
19 } elsif (@ARGV == 1) {
22 if (-e
$ARGV[0] and (stat($ARGV[0]))[7]) {
24 open $in, "<$ARGV[0]" or die "Unable to read $ARGV[0]: $!\n";
27 open $out, ">$ARGV[0]" or die "Unable to write $ARGV[0]: $!\n";
30 print STDERR
"Warning: ambiguous arguments. Assuming $ARGV[0] is $type\n";
33 Usage: hexfont2data.pl [input] [output]
41 while (my $line = <$in>) {
45 unless ($line =~ m/^(....):(.+)/) {
46 print STDERR
"Warning: Invalid line $c\n";
50 my ($n, $bmp) = ($1, $2);
53 my $length = length($bmp) / 2;
55 # XXX: I count 32 and 64, but Perl counts 16 and 32(!). I'm baffled.
59 } elsif ($length == 32) {
64 $table .= <<"TABLE_ENTRY";
69 my $bytes = "G$n: .byte ";
70 while ($bmp =~ m/(..)/g) {
73 chop $bytes; # remove trailing comma