diff options
author | Norbert Preining <preining@logic.at> | 2011-07-27 01:50:38 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2011-07-27 01:50:38 +0000 |
commit | 12aa8683e83c7c91965a1380794a78fb48450400 (patch) | |
tree | 1e79a334accfb3e831d5a764516ac41701f04a4f /Master/tlpkg/dev | |
parent | c30f48800fb2dc0e8dbab7864f2bbae5af0c9f64 (diff) |
adding starting of a updmap that reads multiple updmap.cfg files
git-svn-id: svn://tug.org/texlive/trunk@23248 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/dev')
-rw-r--r-- | Master/tlpkg/dev/multi-updmap.pl | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/Master/tlpkg/dev/multi-updmap.pl b/Master/tlpkg/dev/multi-updmap.pl new file mode 100644 index 00000000000..006367e9a6a --- /dev/null +++ b/Master/tlpkg/dev/multi-updmap.pl @@ -0,0 +1,116 @@ +#!/usr/bin/perl + +$^W = 1; +use strict; + +use Data::Dumper; + +my %settings = ( + dvipsPreferOutline => [ qw/true false/ ], + LW35 => [ qw/URW URWkb ADOBE ADOBEkb/ ], + dvipsDownloadBase35 => [ qw/true false/ ], + pdftexDownloadBase14 => [ qw/true false/ ], + dvipdfmDownloadBase14 => [ qw/true false/ ], +); + +&main(); + +sub main { + my (@l) = `kpsewhich -all updmap.cfg`; + chomp(@l); + my @UpdMaps; + my %MergedData; + # we read it in *reverse* order and simple fill up the combined data + # thus if there are multiple definitions/settings, the one coming from + # the first in the original list will win! + for my $l (reverse @l) { + my $updmap = readUpdmap($l); + if (defined($updmap->{'setting'})) { + for my $k (keys %{$updmap->{'setting'}}) { + $MergedData{'setting'}{$k} = $updmap->{'setting'}{$k}; + } + } + if (defined($updmap->{'MixedMap'})) { + for my $k (keys %{$updmap->{'MixedMap'}}) { + my $mapdata = $updmap->{'MixedMap'}{$k}; + for my $f (keys %$mapdata) { + $MergedData{'fonts'}{$f} = $mapdata->{$f}; + } + } + } + if (defined($updmap->{'Map'})) { + for my $k (keys %{$updmap->{'Map'}}) { + my $mapdata = $updmap->{'Map'}{$k}; + for my $f (keys %$mapdata) { + $MergedData{'fonts'}{$f} = $mapdata->{$f}; + } + } + } + } + $Data::Dumper::Indent = 1; + print Data::Dumper->Dump([\%MergedData], [qw(mapdata)]); +} + +sub readUpdmap { + my $fn = shift; + if (!open(FN,"<$fn")) { + log("Cannot read $fn: $!"); + return; + } + my $i = 0; + my %data; + while (<FN>) { + $i++; + chomp; + next if /^\s*$/; + next if /^\s*#/; + my ($a, $b, @rest) = split ' '; + if (@rest) { + warning("updmap: line $i in $fn contains a syntax error, more than two words!\n"); + } + if (defined($settings{$a})) { + my @possible_values = @{$settings{$a}}; + if (scalar(grep($_ eq $b, @possible_values))) { + $data{'setting'}{$a} = $b; + } else { + warning("updmap: unknown setting for $a: $b, ignored!\n"); + } + } elsif ($a eq "Map" || $a eq "MixedMap") { + if (defined($data{$a}{$b})) { + warning("updmap: double mentioning of $b in $fn\n"); + } else { + my $ret = readMapFile($b); + if (defined($ret)) { + $data{$a}{$b} = readMapFile($b); + } else { + warning("updmap: map file $b mentioned in $fn cannot be found!\n"); + } + } + } else { + warning("updmap: unrecognized line $i in $fn: $_\n"); + } + } + close(FN) || warn("Cannot close $fn: $!"); + return \%data; +} + +sub readMapFile { + my $mn = shift; + my $fn = `kpsewhich $mn`; + chomp($fn); + return if (!$fn); + open(MF,"<$fn") || return; + my %data; + while (<MF>) { + chomp; + next if /^\s*$/; + next if /^\s*%/; + my ($a, $b) = split(' ', $_, 2); + $data{$a} = $b; + } + return \%data; +} + +sub warning { + print STDERR @_; +} |