X-Git-Url: https://git.distorted.org.uk/~mdw/xfonts-traditional/blobdiff_plain/1f0fee99f0b4dad7de9ebc42521a8548adf7e4a6..be65f15aacb3b55f504a18f7eecac9356d71e2ce:/update-xfonts-traditional diff --git a/update-xfonts-traditional b/update-xfonts-traditional index 4b71d14..65d1d08 100755 --- a/update-xfonts-traditional +++ b/update-xfonts-traditional @@ -20,12 +20,18 @@ our $mode; our %foundrymap; our $verbose=0; our $reportfh; +our $foundryinfo; +our %props; sub reportloaded { return unless $verbose; print $reportfh @_,"\n" or die $!; } +sub statsummary () { + return join ' ', ((stat _)[1,7,9,10]); +} + sub loadrules ($) { my ($key) = @_; our %cache; @@ -50,6 +56,7 @@ sub processbdf ($$$$) { my ($foundry,$font); my ($w,$h,$xo,$yo,$y,$bitmap,$glyph); my $modified=0; + %props = (); while (<$inbdf>) { if ($state eq 'bitmap' && $y==$h) { $glyph = uc $glyph; @@ -92,6 +99,10 @@ sub processbdf ($$$$) { $state='startchar'; $w=undef; } + if (($state eq 'idle' || $state eq 'startchar') && + m/^([A-Z_]+)\s+(.*\S)\s+$/) { + $props{$1}=$2; + } if ($state eq 'startchar') { if (m/^BBX\s+(\+?\d+)\s+(\+?\d+)\s+([-+]?\d+)\s+([-+]?\d+)\s+$/) { ($w,$h,$xo,$yo) = ($1,$2,$3,$4); @@ -101,6 +112,9 @@ sub processbdf ($$$$) { $y=0; $glyph=''; $state='bitmap'; + $props{' 7bit'}= + ($props{'CHARSET_REGISTRY'} =~ m/iso8859|utf|iso10646/i && + $props{'ENCODING'} <= 127); } } print $outbdf $_ or die $!; @@ -119,7 +133,14 @@ sub processbdf ($$$$) { } sub loadfoundries () { + $foundryinfo = ''; foreach my $path (@rulespath) { + if (!stat $path) { + die "$path $!" unless $!==&ENOENT; + next; + } + $foundryinfo .= statsummary().' '.$path."\0\n"; + my $p = "$path/foundries"; my $f = new IO::File $p; if (!$f) { @@ -127,6 +148,7 @@ sub loadfoundries () { print $reportfh "foundries: none in $p\n" or die $! if $verbose; next; } + stat $f or die $!; while (<$f>) { s/^\s*//; s/\s+$//; next if m/^\#/; @@ -143,13 +165,13 @@ sub loadfoundries () { sub processpcfgz ($$$$) { my ($inpcfgz,$outpcfgz,$logfile,$what) = @_; - + print $reportfh "processing $inpcfgz to $outpcfgz\n" if $verbose>=2; my $current = new IO::File $inpcfgz, '<' or die "$inpcfgz $!"; my ($usread,$uswrite); my ($reader,$writer); my @children; - foreach my $proc (['zcat'], ['pcf2bdf'], [], - ['bdftopcf'],['',qw(gzip -1)]) { + foreach my $proc (['gunzip'], ['pcf2bdf'], [], + ['bdftopcf'],['',qw(gzip -1 -n)]) { my $isfinal = (@$proc && $proc->[0] eq ''); if (!$isfinal) { $reader = new IO::Handle or die $!; @@ -214,18 +236,27 @@ sub processfontdir ($) { die "$fontdir $!" unless $!==&ENOENT; return; } + my $changed = 0; my $olddone = do "$fontdir/$donefile"; if (!$olddone) { die "$fontdir $! $@ " unless $!==&ENOENT; + } elsif ($olddone->{''} ne $foundryinfo) { + our $repro_reported; + print $reportfh "reprocessing fonts (rules updated)\n" or die $! + unless $repro_reported++; + $olddone = undef; + } + if (!$olddone) { $olddone = { }; + $changed = 1; } - my $newdone = { }; + my $newdone = { '' => $foundryinfo }; my $log = new IO::File "$fontdir/$logfile", "w" or die "$fontdir/$logfile $!"; my %outfiles; # bitmask: 1 /*exists*/ | 2 /*wanted*/ - my $changed; my $updated=0; my $reported=0; + my $anypcfs=0; flush $reportfh or die $!; while (my $dent = scalar readdir FD) { @@ -245,7 +276,9 @@ sub processfontdir ($) { next; } die "$fontdir $dent" unless -f _; - my $stats = join ' ', ((stat _)[1,7,9,10]); + $anypcfs++; + + my $stats = statsummary(); my $tdone = $olddone->{$dent}; my $outdent = $fontprefix.$dent; if (defined $tdone && $tdone eq $stats) { @@ -265,9 +298,9 @@ sub processfontdir ($) { or die "$fontdir $outdent $!"; $updated++; $outfiles{$outdent} |= 3; - $changed = 1; } $newdone->{$dent} = $stats; + $changed = 1; } my $affected=0; foreach my $olddent (keys %outfiles) { @@ -278,13 +311,18 @@ sub processfontdir ($) { } unlink "$fontdir/$olddent" or die "$fontdir $olddent $!"; $changed = 1; + $updated++; } - if (!%$newdone) { + if (!stat "$fontdir/fonts.dir") { + $!==&ENOENT or die "$fontdir $!"; + } else { + $!=0; $?=0; system 'mkfontdir',$fontdir; + die "$fontdir $? $!" if $? or $!; + } + if (!$anypcfs) { unlink "$fontdir/$logfile" or die "$fontdir $!"; unlink "$fontdir/$donefile" or $!==&ENOENT or die "$fontdir $!"; } elsif ($changed) { - $!=0; $?=0; system 'mkfontdir',$fontdir; - die "$fontdir $? $!" if $? or $!; my $newdoneh = new IO::File "$fontdir/$donefile.new", 'w' or die "$fontdir $!"; print $newdoneh Dumper($newdone) or die "$fontdir $!"; @@ -366,6 +404,14 @@ define_mode('process-fonttrees', sub { } }); +define_mode('update', sub { + die "no arguments allowed with --postinst\n" unless !@ARGV; + loadfoundries(); + foreach my $d (@fonttrees) { + processfonttree($d); + } +}); + Getopt::Long::Configure(qw(bundling)); GetOptions(@options) or exit 127;