3 # printrule bad.bdf good.bdf <height> '^ENCODING <nn>$' 0|1 <comment>
4 # printrule bad.bdf good.bdf <height> '^STARTCHAR <name>$' 0|1 <comment>
6 # This script is an assistant for printing rules for pasting into
7 # *.rules files. The idea is that you get bdfs of the font you don't
8 # and do like, and specify the character, and it will print a rule
11 # Final argument, if 1, says the glyph is a letter without an
12 # ascender, and edits the regexp not to match the whitespace where
19 our ($badf,$goodf,$height,$regexp,$partial,$comment) = @ARGV;
23 my $f = new IO::File $p or die "$p $!";
27 die $p unless defined;
32 for (my $y=0; $y<$height; $y++) {
33 <$f> =~ m/^([0-9a-f]+)$/i or die "$p $_ ?";
41 my $good = get($goodf);
44 $bad =~ s/^(?:00\;)+//; my $badrm= $&;
45 $good =~ s/^(?:00\;)+//; my $goodrm= $&;
46 die "$badrm $bad $goodrm $good " unless $badrm eq $goodrm;
47 $s = sprintf 's/\\b%s$/%s/', $bad, $good;
49 $s = sprintf 's/^%s$/%s/', $bad, $good;
51 printf " %s; # %s\n", $s, $comment or die $!;