From 18d2cc90c07991866e00f714d471981e570c8279 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 7 Jan 2012 16:22:39 +0000 Subject: [PATCH] wip --- 6,13,0,-2.rules | 3 +++ bdf-filter | 41 -------------------------------- utility | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 75 insertions(+), 41 deletions(-) create mode 100644 6,13,0,-2.rules delete mode 100644 bdf-filter create mode 100755 utility diff --git a/6,13,0,-2.rules b/6,13,0,-2.rules new file mode 100644 index 0000000..8bf133e --- /dev/null +++ b/6,13,0,-2.rules @@ -0,0 +1,3 @@ +sub { + s/00(;..)$/A8$1/; +} diff --git a/bdf-filter b/bdf-filter deleted file mode 100644 index a4e6220..0000000 --- a/bdf-filter +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/perl -w -use strict; - -our $state='begin'; -our ($w,$h,$xo,$yo,$y,$bitmap,$glyph); - -while (<>) { - if ($state eq 'bitmap' && $y==$h) { - $state='idle'; - } - if ($state eq 'bitmap') { - m/^([0-9a-fA-F]+)\s+$/ or die $y; - length($1) == (($w+7 >> 3) << 1) or die "$1 $w"; - $glyph .= "$1;"; - } - if ($state eq 'begin' && m/^FOUNDRY\s+\"Misc\"\s+/i) { - s/misc/Trad/i; - $state='idle'; - } - if ($state eq 'idle' && m/^STARTCHAR\s/) { - $state='startchar'; - $w=undef; - } - if ($state eq 'startchar') { - if (m/^BBX\s+(\+?\d+)\s+(\+?\d+)\s+([-+]?\d+)\s+([-+]?\d+)\s+$/) { - ($w,$h,$xo,$yo) = ($1,$2,$3,$4); - } - if (m/^BITMAP\s+$/) { - die unless defined $w; - $y=0; - $glyph=''; - $state='bitmap'; - } - } - - - if ($inchar) { - if ( - $inchar - - next unless $foundry; diff --git a/utility b/utility new file mode 100755 index 0000000..41c9455 --- /dev/null +++ b/utility @@ -0,0 +1,72 @@ +#!/usr/bin/perl -w +use strict; +use POSIX; +use IO::File; + +our @rulespath=('.'); + +our $state='begin'; +our ($w,$h,$xo,$yo,$y,$bitmap,$glyph); + +sub loadrules () { + our %cache; + my $key= sprintf "%d,%d,%d,%d", $w,$h,$xo,$yo; + my $fc=$cache{$key}; + return $fc if $fc; + foreach my $path (@rulespath) { + my $script="$path/$key.rules"; + $!=0; $@=''; my $f = do $script; + if (defined $f) { + $cache{$key}=$f; + return $f; + } + die "$! $? $script" unless $! == &ENOENT; + } + return $cache{$key}=undef; +} + +sub processbdf ($$) { + my ($inbdf,$outbdf) = @_; + while (<$inbdf>) { + if ($state eq 'bitmap' && $y==$h) { + local ($_) = lc $glyph; + my $rules= loadrules(); + return 0 if !$rules; + s/\;$//; + $rules->(); + print $outbdf $_,"\n" or die $! + foreach split /\;/ $_; # /; + $state='idle'; + } + if ($state eq 'bitmap') { + m/^([0-9a-fA-F]+)\s+$/ or die $y; + length($1) == (($w+7 >> 3) << 1) or die "$1 $w"; + $glyph .= "$1;"; + } + if ($state eq 'begin' && m/^FOUNDRY\s+/) { + return 0 unless m/^FOUNDRY\s+\"[Mm]isc\"\s+/) { + s/misc/Trad/i; + $state='idle'; + } + if ($state eq 'idle' && m/^STARTCHAR\s/) { + $state='startchar'; + $w=undef; + } + if ($state eq 'startchar') { + if (m/^BBX\s+(\+?\d+)\s+(\+?\d+)\s+([-+]?\d+)\s+([-+]?\d+)\s+$/) { + ($w,$h,$xo,$yo) = ($1,$2,$3,$4); + } + if (m/^BITMAP\s+$/) { + die unless defined $w; + $y=0; + $glyph=''; + $state='bitmap'; + } + } + } + die $! if $inbdf->error; + die $! if $outbdf->error or $outbdf->flush; + die unless $state eq 'idle'; +} + +processbdf('STDIN','STDOUT'); -- 2.11.0