summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Jackson <ijackson@chiark.greenend.org.uk>2016-04-25 02:12:52 +0100
committerIan Jackson <ijackson@chiark.greenend.org.uk>2016-04-25 02:12:52 +0100
commit35412fce345bbb491202173df7c0b8f0925fe67d (patch)
tree0401f5c0ee7ed4b3765dac1c9226796f735ff0d9
parente71e2b04f91733145e27fe04981bba48ca5f4d32 (diff)
Add bdf normaliser (to cope with fontforge output directly, since bdftopcf | pcf2bdf sometimes fails).
-rwxr-xr-xbdfnorm54
-rw-r--r--debian/changelog2
-rwxr-xr-xmkrules6
3 files changed, 59 insertions, 3 deletions
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 <ijackson@chiark.greenend.org.uk> 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