blob: 0b02834fc73db64a9f3b2795ed8c26176e1aeb2a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#!/usr/bin/perl -w
use strict;
use POSIX;
our @fbbox;
our @cbbox;
our $numbytes;
our $zeroes;
our $botpad;
$|=1;
while (<>) {
if (m/^FONTBOUNDINGBOX\s+([-0-9]+)\s+([-0-9]+)\s+([-0-9]+)\s+([-0-9]+)$/) {
die if @fbbox;
@fbbox = ($1,$2,$3,$4); # xsz ysz xoff yoff
# FONTBOUNDINGBOX 10 20 0 -4
} elsif (m/^BBX\s+([-0-9]+)\s+([-0-9]+)\s+([-0-9]+)\s+([-0-9]+)$/) {
die unless @fbbox;
@cbbox = ($1,$2,$3,$4);
print "BBX @fbbox\n";
next;
} elsif (m/^BITMAP\b/) {
die unless @cbbox;
$numbytes = ceil($fbbox[0] / 8);
$zeroes = ('00' x $numbytes)."\n";
$botpad = $cbbox[3] - $fbbox[3];
my $toppad = $fbbox[1] - $cbbox[1] - $botpad;
print;
print $zeroes x $toppad;
next;
} elsif (m/^ENDCHAR\b/) {
die unless defined $zeroes;
print $zeroes x $botpad;
$zeroes = undef;
} elsif (defined $zeroes) {
chomp;
m/[^0-9A-F]/ and die "$& ?";
# print "# $_\n";
$_ = unpack "B*", pack "H*", $_;
# print "# $_\n";
$_ = ("0" x ($cbbox[2] - $fbbox[2])) . $_;
# print "# $_\n";
s/0+$//;
# print "# $_\n";
$_ .= "0" x ($numbytes*8 - length);
# print "# $_\n";
$_ = unpack "H*", pack "B*", $_;
$_ = uc $_;
$_ .= "\n";
}
print;
}
|