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 56 57 58 59 60 61 62 63 64 65 66 67
|
#!/usr/bin/env perl
# $Id: make_EBDT,v 1.4 2003/08/05 16:26:37 s42335 Exp $
#
# usage: make_EBDT BDF1 BDF2 ...
#
# build an EBDT(Embedded Bitmap DaTa, or bdat in MacOS) table from BDF(BIT)
# and dump it into stdout.
#
# BUGS: currently only imageFormat 6 is supported.
#
# 2002/2/3, by 1@2ch
# * public domain *
#
$p=$0; $p=~s:[^/]+$::; push(@INC,$p);
require 'lib_util.pl';
require 'lib_metric.pl';
sub usage() {
print "usage: make_EBDT BDF1 BDF2 ...\n";
exit 1;
}
0 == @ARGV && usage();
sub format6 {
open(IN, $_[0]) || die("open: $_[0]: $!");
my $bw, $bh, $hox, $hoy, $hbytes, $had, $vad;
my $b = 0, $bits;
while(<IN>) {
chop;
my @F = split(/\s+/);
my $c = shift(@F);
if ($c eq 'BBX') {
($bw, $bh, $hox, $hoy) = @F;
$hbytes = int(($bw+7)/8);
} elsif ($c eq 'DWIDTH') {
($had, $vad_dummy) = @F;
} elsif ($c eq 'BITMAP') {
$b = 1;
$bits = '';
} elsif ($c eq 'ENDCHAR') {
wbigGlyphMetrics($bh, $bw, $hox, $hoy+$bh, $had, 0, 0, $bh);
wstrn($bits);
$b = 0;
} elsif ($b) {
$c =~ tr/./0/;
$c =~ tr/@/1/;
$bits .= pack('B' . $hbytes*8, $c);
}
}
close(IN);
}
# version number (0x00020000 fixed)
wopen('&STDOUT');
wuint32(0x00020000);
foreach my $i (@ARGV) {
if ($i =~ /^:(\d+)$/) {
;
} else {
format6($i);
}
}
|