0
|
1 #!/usr/bin/perl
|
|
2 use strict;
|
|
3
|
|
4 my ($name,$encoding,@bitmap);
|
|
5
|
|
6 #while(<>) {
|
|
7 # last if (/^ENDPROP/);
|
|
8 #}
|
|
9
|
|
10 #my $dum = <>; # skip CHARS
|
|
11
|
|
12 my ($lineno,$line);
|
|
13 my $width;
|
|
14 my $height;
|
|
15
|
|
16 while(<>) {
|
|
17 if(/^STARTCHAR\s+(.*)/) { &init(); $name=$1; print;
|
|
18 } elsif (/^ENCODING\s+(\d+)/) { $encoding=$1; print;
|
|
19 } elsif (/^SWIDTH (\d+) (\d+)/) { print;
|
|
20 } elsif (/^DWIDTH (\d+) (\d+)/) { $width = $1; print;
|
|
21 } elsif (/^BBX ([-+\d]+) ([-+\d]+) ([-+\d]+) ([-+\d]+)/) { print; $height = $2;
|
|
22 } elsif (/^BITMAP/) { print; $line = $lineno+2; # error line must start 1
|
|
23 } elsif (/^ENDCHAR/) { &display(); print "ENDCHAR\n";
|
|
24 } elsif (/^[ *]+$/) { chop; push(@bitmap,$_);
|
|
25 }
|
|
26 $lineno++;
|
|
27 }
|
|
28
|
|
29 sub display {
|
|
30 my $hwidth = int((($width+7)&(~7))/4);
|
|
31 # print "hwdith $hwidth\n";
|
|
32 my $i = 0;
|
|
33 for my $hex (@bitmap) {
|
|
34 my $bin;
|
|
35 my $orig = $hex;
|
|
36 my $j = 0;
|
|
37 while($hex =~ s/..//) {
|
|
38 if ($& eq " ") {
|
|
39 $bin .= "0";
|
|
40 } elsif ($& eq "**") {
|
|
41 $bin .= "1";
|
|
42 } else {
|
|
43 print $line+$i,": Error Bad Alignment ","| "x$width,"\n";
|
|
44 print $line+$i,": Error Bad Alignment ","$orig\n";
|
|
45 last;
|
|
46 }
|
|
47 if ($j++ > $width) {
|
|
48 print $line+$i,": Error Too long",substr($orig,$j),
|
|
49 "|$hex too long \n" if ($hex =~ /[^ ]/);
|
|
50 last;
|
|
51 }
|
|
52 }
|
|
53 # print "bitmap $bin -- $i\n";
|
|
54 my $h = pack("B*",$bin . "0"x$width);
|
|
55 my $b = unpack("H*",$h);
|
|
56 $b = substr($b,0,$hwidth);
|
|
57 print "$b\n";
|
|
58 last if ($i++ > $height-2);
|
|
59 }
|
|
60 # print "hhhh $height-$i = ",$height-$i,"\n";
|
|
61 print (("0"x$hwidth."\n")x($height-$i)) if ($height-$i > 0);
|
|
62 }
|
|
63
|
|
64 sub init {
|
|
65 $name = '';
|
|
66 $encoding = 0;
|
|
67 @bitmap= ();
|
|
68 }
|
|
69
|
|
70 # end
|