From 35412fce345bbb491202173df7c0b8f0925fe67d Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 25 Apr 2016 02:12:52 +0100 Subject: [PATCH] Add bdf normaliser (to cope with fontforge output directly, since bdftopcf | pcf2bdf sometimes fails). --- bdfnorm | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ debian/changelog | 2 ++ mkrules | 6 +++--- 3 files changed, 59 insertions(+), 3 deletions(-) create mode 100755 bdfnorm diff --git a/bdfnorm b/bdfnorm new file mode 100755 index 0000000..da20e76 --- /dev/null +++ b/bdfnorm @@ -0,0 +1,54 @@ +#!/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"; + s/./ unpack "B4", pack "H*", $& /ge; +# print "# $_\n"; + $_ = ("0" x ($cbbox[2] - $fbbox[2])) . $_; +# print "# $_\n"; + s/0+$//; +# print "# $_\n"; + $_ .= "0" x ($numbytes*8 - length); +# print "# $_\n"; + s/.{4}/ unpack "H", pack "B4", $& /ge; + $_ .= "\n"; + } + print; +} diff --git a/debian/changelog b/debian/changelog index 55fcd04..3e2a321 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,8 @@ xfonts-traditional (1.7.2~~iwj) UNRELEASED; urgency=medium * An internal error message in printrule is improved slightly. * Add debhelper-build-stamp to .gitignore. * Permit new foundry names to contain "."s. + * Add bdf normaliser (to cope with fontforge output directly, since + bdftopcf | pcf2bdf sometimes fails). -- Ian Jackson Sun, 24 Apr 2016 22:07:21 +0100 diff --git a/mkrules b/mkrules index d16d6b4..3c5f935 100755 --- a/mkrules +++ b/mkrules @@ -43,9 +43,9 @@ while read keyword rest; do ./ffconvert.pe "$f/$pcf" # 1. fontforge writes a silly filename # 2. our crappy machinery copes only - # with BDFs from pcf2bdf, not from - # fontforge - bdftopcf <"$f/$pcf".BDF*.bdf |pcf2bdf >$out + # with BDFs all of whose chars have + # the bbox of the font + ./bdfnorm <"$f/$pcf".BDF*.bdf >$out else echo >&2 "cannot make $out!" exit 1 -- 2.30.2