summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlgs/Resource/Init/gs_fonts.ps
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlgs/Resource/Init/gs_fonts.ps')
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_fonts.ps75
1 files changed, 61 insertions, 14 deletions
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_fonts.ps b/Master/tlpkg/tlgs/Resource/Init/gs_fonts.ps
index c47f6e57767..8e361552bc8 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_fonts.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_fonts.ps
@@ -36,7 +36,6 @@
end def
.setlanguagelevel
-
% ------ End of editable parameters ------ %
% Define the UniqueIDs and organization XUID assigned to Artifex.
@@ -67,6 +66,36 @@ end def
loop
} bind def
+% <dir.../base.extn> .basename <dir>
+/.splitdirname {
+ (/) rsearch { //true } { (\\) rsearch } ifelse
+ {3 -2 roll pop pop //true}{//false} ifelse
+} bind def
+
+% <dict> .addfontmappermitpaths
+% As fontmap can contain a *lot* of individual entries
+% we split off the filenames, and add directories to the
+% allowed paths.
+% We accumulate the paths in a dictionary, then iterate
+% the dictionary adding the paths to the PermitReading
+% list. This leverages the efficiency of dictionaries
+% handling duplicate keys.
+/.addfontmappermitpaths
+{
+ dup length dict begin
+ {
+ exch pop dup type /stringtype eq
+ {//.splitdirname exec {dup def} {pop} ifelse}
+ {pop}
+ ifelse
+ } forall
+ currentdict end
+ {exch pop /PermitFileReading exch .addcontrolpath}forall
+} bind def
+
+defaultfontmap_content length 0 gt
+{defaultfontmap_content .addfontmappermitpaths} if
+
% Load a font name -> font file name map.
userdict /Fontmap .FontDirectory maxlength dict put
userdict /.nativeFontmap .FontDirectory maxlength dict put
@@ -76,7 +105,8 @@ userdict /.nativeFontmap .FontDirectory maxlength dict put
% specification that makes later entries override earlier
% ones within the same file.
50 dict exch .readFontmap
- { .definefontmap } forall
+ dup //.addfontmappermitpaths exec
+ { .definefontmap } forall
} bind def
/.readFontmap { % <dict> <file> .readFontmap <dict>
{ dup token not { closefile exit } if
@@ -232,6 +262,11 @@ ifelse
FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if
/FONTPATH [ FONTPATH .pathlist ] def
+FONTPATH
+{
+ /PermitFileReading exch .addcontrolpath
+} forall
+
% Scan directories looking for plausible fonts. "Plausible" means that
% the file begins with %!PS-AdobeFont or %!FontType1, or with \200\001
% followed by four arbitrary bytes and then either of these strings.
@@ -309,7 +344,7 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if
/.scan1fontstring 8192 string def
% BeginFont: is not per Adobe documentation, but a few fonts have it.
/.scanfontheaders [(%!PS-Adobe*) (%!FontType*) (%%BeginFont:*)] def
-0 //.scanfontheaders { length .max } forall 6 add % extra for PFB header
+0 /.scanfontheaders .systemvar { length .max } forall 6 add % extra for PFB header
/.scan1fontfirst exch string def
/.scanfontdir % <dirname> .scanfontdir -
{ currentglobal exch //true setglobal
@@ -349,7 +384,7 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if
{ dup length 6 sub 6 exch getinterval }
if
% Check for font file headers.
- //false //.scanfontheaders
+ //false /.scanfontheaders .systemvar
{ 2 index exch .stringmatch or
}
forall exch pop
@@ -1003,13 +1038,25 @@ $error /SubstituteFont { } put
% check <libflag>
{
findlibfile not
- } {
+ }
+ {
+ //true
+ } ifelse
+
+
+ % if findlibfile didn't work, try just opening the file direcly.
+ {
dup (r) { file } stopped {
pop pop //true
} {
//false
} ifelse
- } ifelse {
+ }
+ {
+ //false
+ }ifelse
+
+ {
QUIET not
{ (Can't find \(or can't open\) font file ) print dup print
(.) = flush
@@ -1101,7 +1148,7 @@ $error /SubstituteFont { } put
} loop % end of loop
- } bind executeonly odef % must be bound and hidden for .putgstringcopy
+ } bind executeonly def % must be bound and hidden for .putgstringcopy
% Attempt to load a font from a file.
/.tryloadfont { % <fontname> .tryloadfont <font> true
@@ -1111,14 +1158,14 @@ $error /SubstituteFont { } put
/.genericrfn where {
pop
pop dup //.fonttempstring /FontResourceDir getsystemparam .genericrfn
- {//false .loadfontloop} //.internalstopped exec {//false} if {
+ {//false //.loadfontloop exec} //.internalstopped exec {//false} if {
//true
} {
dup //.nametostring exec
- {//true .loadfontloop} //.internalstopped exec {//false} if
+ {//true //.loadfontloop exec} //.internalstopped exec {//false} if
} ifelse
} {
- {//true .loadfontloop} //.internalstopped exec {//false} if
+ {//true //.loadfontloop exec} //.internalstopped exec {//false} if
} ifelse
} bind def
@@ -1138,7 +1185,7 @@ $error /SubstituteFont { } put
{ exch pop //true //false }
{
% if we can't load by name check the native font map
- dup .nativeFontmap exch .knownget
+ .nativeFontmap exch .knownget
{ //true //true }
{ //false //false } ifelse
} ifelse
@@ -1185,7 +1232,7 @@ $error /SubstituteFont { } put
{
1 dict begin
} ifelse
- //true .loadfontloop
+ //true //.loadfontloop exec
end
{ //true exit } if
}
@@ -1292,5 +1339,5 @@ FAKEFONTS { exch } if pop def % don't bind, .current/setglobal get redefined
/.nametostring /.fontnamestring /.checkalias /.fontknownget /.stdsubstfont
/.putgstringcopy
/.definenativefontmap
- /.findfontname
-] {systemdict exch .forceundef} forall
+ /.findfontname /.addfontmappermitpaths /.splitdirname
+] systemdict .undefinternalnames