7 our $package='xfonts-traditional';
8 our $sharedir="/usr/share/$package";
16 return unless $verbose;
17 print $reportfh @_,"\n" or die $!;
25 foreach my $path (@rulespath) {
26 my $script="$path/$key.rules";
27 $!=0; $@=''; my $f = do $script;
29 reportloaded("rules: loaded ",$script);
33 die "$! $? $script" unless $! == &ENOENT;
35 return $cache{$key}=undef;
38 sub processbdf ($$$) {
39 my ($inbdf,$outbdf,$what) = @_;
42 my ($w,$h,$xo,$yo,$y,$bitmap,$glyph);
45 if ($state eq 'bitmap' && $y==$h) {
49 my $key= sprintf "%s,%d,%d,%d,%d", $foundry,$w,$h,$xo,$yo;
50 my $rules= loadrules($key);
51 return (0,'no rules') if !$rules;
53 $modified += ($_ ne $glyph);
54 print $outbdf $_,"\n" or die $!
55 foreach split /\;/, $_; # /;
58 if ($state eq 'bitmap') {
59 m/^([0-9a-fA-F]+)\s+$/ or die $y;
60 length($1) == (($w+7 >> 3) << 1) or die "$1 $w";
65 if ($state eq 'idle' && m/^FOUNDRY\s+/) {
66 die if defined $foundry;
67 return (0,'foundry syntax') unless m/^FOUNDRY\s+\"(\w+)\"\s+/;
68 $foundry = $foundrymap{lc $1};
69 return (0,'no foundry') unless defined $foundry;
70 $_ = "FOUNDRY \"$foundry\"\n";
72 if ($state eq 'idle' && m/^FONT\s+/) {
74 return 0 unless m/^(FONT\s+)\-(\w+)\-/;
75 $font = $foundrymap{lc $2};
76 return (0,'no foundry') unless defined $font;
77 $_ = "FONT -$font-$'";
79 if ($state eq 'idle' && m/^STARTCHAR\s/) {
80 die unless defined $foundry;
81 die unless defined $font;
82 return (0,'foundry != font') unless $foundry eq $font;
86 if ($state eq 'startchar') {
87 if (m/^BBX\s+(\+?\d+)\s+(\+?\d+)\s+([-+]?\d+)\s+([-+]?\d+)\s+$/) {
88 ($w,$h,$xo,$yo) = ($1,$2,$3,$4);
91 die unless defined $w;
97 print $outbdf $_ or die $!;
99 die $! if $inbdf->error;
100 die $! if $outbdf->error or !$outbdf->flush;
101 die unless $state eq 'idle';
103 printf $reportfh "%s: %d glyphs changed\n", $what, $modified
106 printf $reportfh "%s: unchanged - no rules matched\n", $what
113 'R|rules-include=s@' => \@rulespath,
114 'share-dir=s' => \$sharedir,
115 'verbose|v+' => \$verbose,
118 sub define_mode ($$) {
119 my ($optname,$f) = @_;
120 push @options, $optname, sub {
121 die "only one mode may be specified\n" if defined $mode;
126 sub loadfoundries () {
127 foreach my $path (@rulespath) {
128 my $p = "$path/foundries";
129 my $f = new IO::File $p;
131 die "$p $!" unless $!==&ENOENT;
132 print $reportfh "foundries: none in $p\n" or die $! if $verbose;
138 m/^(\w+)\s+(\w+)$/ or die;
140 next if exists $foundrymap{$k};
143 $f->error and die $!;
144 reportloaded('foundries: loaded ',$p);
146 die "no foundry maps\n" unless %foundrymap;
149 our $stdin = new IO::File '<&STDIN' or die $!;
150 our $stdout = new IO::File '>&STDOUT' or die $!;
151 our $stderr = new IO::File '>&STDERR' or die $!;
154 define_mode('bdf-filter', sub {
155 die "no arguments allowed with --bdf-filter\n" if @ARGV;
158 my $r = processbdf($stdin,$stdout,'stdin');
160 print STDERR "stdin not processed: $r\n";
165 Getopt::Long::Configure(qw(bundling));
166 GetOptions(@options) or exit 127;
168 push @rulespath, "$sharedir/rules";
170 die "need a mode\n" unless $mode;
174 # 70 zcat /usr/share/fonts/X11/misc/6x13.pcf.gz |pcf2bdf >in.bdf
175 # 71 ./utility <in.bdf >out.bdf
176 # 83 bdftopcf out.bdf >out.pcf
178 # 85 cp out.pcf.gz /usr/share/fonts/X11/misc/
179 # really mkfontdir /usr/share/fonts/X11/misc/