diff options
author | Deri James <deri@chuzzlewit.myzen.co.uk> | 2022-06-10 21:13:24 +0100 |
---|---|---|
committer | Deri James <deri@chuzzlewit.myzen.co.uk> | 2022-06-10 21:13:24 +0100 |
commit | 4ae4aeb6555f4f16c28fcb03eb1f56577826054c (patch) | |
tree | 2db42a297b143cb1276465f83b59fdaa66b77616 /font | |
parent | a5105938c002980d3e75e1824403fe3ee608d6ed (diff) | |
download | groff-git-4ae4aeb6555f4f16c28fcb03eb1f56577826054c.tar.gz |
[gropdf]: Changes to BuildFoundries.
* font/devpdf/util/BuildFoundries.pl: Collect search paths into
an array rather than a colon delimited string, this allows
the @PATH_SEPARATOR@ character (':' or ';') to be used to
delimit paths yielded by the command 'gs -h' but still use ':'
to delimit paths in the Foundry file. This means the same
Foundry file can be used on all systems.
* font/devpdf/Foundry.in: Add more likely paths to find the URW
fonts.
Diffstat (limited to 'font')
-rw-r--r-- | font/devpdf/Foundry.in | 2 | ||||
-rw-r--r-- | font/devpdf/util/BuildFoundries.pl | 153 |
2 files changed, 84 insertions, 71 deletions
diff --git a/font/devpdf/Foundry.in b/font/devpdf/Foundry.in index beab42210..4aa52303a 100644 --- a/font/devpdf/Foundry.in +++ b/font/devpdf/Foundry.in @@ -72,7 +72,7 @@ EURO|N||||*../devps/freeeuro.pfa # URW fonts are typically shipped with Ghostscript, but can be replaced. #Foundry|Name|Search path -foundry|U|(gs):@urwfontsdir@:/usr/share/fonts/type1/gsfonts:/opt/local/share/fonts/urw-fonts +foundry|U|@urwfontsdir@:/usr/share/fonts/type1/gsfonts:/usr/share/fonts/default/Type1:/usr/share/fonts/default/Type1/adobestd35:/usr/share/fonts/type1/urw-base35:/opt/local/share/fonts/urw-fonts:(gs) # Define flags for afmtodit. diff --git a/font/devpdf/util/BuildFoundries.pl b/font/devpdf/util/BuildFoundries.pl index 33ec7add8..9bf6fb0e3 100644 --- a/font/devpdf/util/BuildFoundries.pl +++ b/font/devpdf/util/BuildFoundries.pl @@ -33,7 +33,8 @@ GetOptions("check" => \$check, "dirURW=s" => \$dirURW); (my $progname = $0) =~s @.*/@@; my $where=shift||''; -my $devps=shift||'../devps'; +my @d=(split(':',shift||'../devps')); +my $devps=\@d; chdir $where if $where ne ''; my (%flg,@downloadpreamble,%download); my $GSpath=FindGSpath(); @@ -59,7 +60,7 @@ exit 0; sub LoadFoundry { my $fn=shift; - my $foundrypath=''; + my $foundrypath; $notFoundFont=0; open(F,"<$fn") or Die("file '$fn' not found or not readable"); @@ -85,12 +86,18 @@ sub LoadFoundry if (lc($r[0]) eq 'foundry') { - Warn("\nThe path(s) used for searching:\n$foundrypath\n") if $notFoundFont; + Warn("\nThe path(s) used for searching:\n".join(':',$foundrypath)."\n") if $notFoundFont; $foundry=uc($r[1]); - $foundrypath=''; - $foundrypath.="$dirURW:" if $dirURW; - $foundrypath.=$r[2].':'.$devps; - $foundrypath=~s/\(gs\)/$GSpath/; + $foundrypath=[]; + push(@{$foundrypath},$dirURW) if $dirURW; + push(@{$foundrypath},(split(':',$r[2])),@{$devps}); + foreach my $j (0..$#{$foundrypath}) + { + if ($foundrypath->[$j]=~m'\s*\(gs\)') + { + splice(@{$foundrypath},$j,1,@{$GSpath}); + } + } $notFoundFont=0; } else @@ -159,7 +166,7 @@ sub LoadFoundry } close(F); - Warn("\nThe path(s) used for searching:\n$foundrypath\n") if $notFoundFont; + Warn("\nThe path(s) used for searching:\n".join(':',$foundrypath)."\n") if $notFoundFont; } sub RunAfmtodit @@ -238,68 +245,66 @@ sub LocateFile my $tryafm=shift; return(substr($files,1)) if substr($files,0,1) eq '*'; - foreach my $file (split('!',$files)) + foreach my $p (@{$path}) { - if ($tryafm) + next if !defined($p) or $p eq ';' or $p eq ':'; + $p=~s/^\s+//; + $p=~s/\s+$//; + + next if $p=~m/^\%rom\%/; # exclude %rom% paths (from (gs)) + + foreach my $file (reverse(split('!',$files))) { - if (!($file=~s/\..+$/.afm/)) + if ($tryafm) { - # no extenaion - $file.='.afm'; + if (!($file=~s/\..+$/.afm/)) + { + # no extenaion + $file.='.afm'; + } } - } - - if ($file=~m'/') - { - # path given with file name so no need to search the paths - - if (-r $file) - { - return($file); - } - - if ($tryafm and $file=~s'type1/'afm/'i) - { - if (-r "$file") - { - return($file); - } - } - - return(''); - } - - if ($path eq '(tex)') - { - my $res=`kpsewhich $file`; - return '' if $?; - chomp($res); - return($res); - } - - my (@paths)=split(/$pathsep/,$path); - foreach my $p (@paths) - { - next if !defined($p) or $p eq ';' or $p eq ':'; - $p=~s/^\s+//; - $p=~s/\s+$//; + if ($file=~m'/') + { + # path given with file name so no need to search the paths + + if (-r $file) + { + return($file); + } + + if ($tryafm and $file=~s'type1/'afm/'i) + { + if (-r "$file") + { + return($file); + } + } + + return(''); + } - next if $p=~m/^\%rom\%/; # exclude %rom% paths (from (gs)) + if ($path eq '(tex)') + { + my $res=`kpsewhich $file`; + return '' if $?; + chomp($res); + return($res); + } - if (-r "$p/$file") - { - return("$p/$file"); - } + if (-r "$p/$file") + { + return("$p/$file"); + } - if ($tryafm and $p=~s'type1/'afm/'i) - { - if (-r "$p/$file") - { - return("$p/$file"); - } - } - } + if ($tryafm and $p=~s'type1/'afm/'i) + { + if (-r "$p/$file") + { + return("$p/$file"); + } + } + } } return(''); @@ -309,7 +314,7 @@ sub FindGSpath { my (@res)=`@GROFF_GHOSTSCRIPT_INTERPRETERS@ -h 2>/dev/null`; return '' if $?; - my $buildpath=''; + my $buildpath=[]; my $stg=1; foreach my $l (@res) @@ -329,7 +334,8 @@ sub FindGSpath else { $l=~s/^\s+//; - $buildpath.=$l; + $pathsep=';' if substr($l,-1) eq ';'; + push(@{$buildpath},(split("$pathsep",$l))); } } } @@ -471,7 +477,7 @@ sub Msg { sub CheckFoundry { my $fn=shift; - my $foundrypath=''; + my $foundrypath=[]; $notFoundFont=0; open(F,"<$fn") or Die("file '$fn' not found or not readable"); @@ -495,10 +501,17 @@ sub CheckFoundry if (lc($r[0]) eq 'foundry') { $foundry=uc($r[1]); - $foundrypath=''; - $foundrypath.="$dirURW:" if $dirURW; - $foundrypath.=$r[2].':'.$devps; - $foundrypath=~s/\(gs\)/$GSpath/; + $foundrypath=[]; + push(@{$foundrypath},$dirURW) if $dirURW; + push(@{$foundrypath},(split(':',$r[2])),$devps); + foreach my $j (0..$#{$foundrypath}) + { + if ($foundrypath->[$j]=~m'\s*\(gs\)') + { + splice(@{$foundrypath},$j,1,@{$GSpath}); + } + } + $notFoundFont=0; } else { @@ -516,7 +529,7 @@ sub CheckFoundry # Don't run afmtodit, just copy the grops font file my $gotf=1; - my $gropsfnt=LocateFile($devps,$r[0],0); + my $gropsfnt=LocateFile([$devps],$r[0],0); if ($gropsfnt ne '' and -r "$gropsfnt") { |