diff options
Diffstat (limited to 'meta/recipes-extended/ghostscript/ghostscript/CVE-2019-6116-0006.patch')
-rw-r--r-- | meta/recipes-extended/ghostscript/ghostscript/CVE-2019-6116-0006.patch | 596 |
1 files changed, 0 insertions, 596 deletions
diff --git a/meta/recipes-extended/ghostscript/ghostscript/CVE-2019-6116-0006.patch b/meta/recipes-extended/ghostscript/ghostscript/CVE-2019-6116-0006.patch deleted file mode 100644 index 79e640b18f..0000000000 --- a/meta/recipes-extended/ghostscript/ghostscript/CVE-2019-6116-0006.patch +++ /dev/null | |||
@@ -1,596 +0,0 @@ | |||
1 | From 97f9052ce49e6844b06a49ff9e4b8fc1eaf6bd10 Mon Sep 17 00:00:00 2001 | ||
2 | From: Chris Liddell <chris.liddell@artifex.com> | ||
3 | Date: Wed, 9 Jan 2019 14:24:07 +0000 | ||
4 | Subject: [PATCH 6/7] Undefine a bunch of gs_fonts.ps specific procs | ||
5 | |||
6 | Also reorder and add some immediate evaluation, so it still works with the | ||
7 | undefining. | ||
8 | |||
9 | CVE: CVE-2019-6116 | ||
10 | Upstream-Status: Backport [git://git.ghostscript.com/ghostpdl.git] | ||
11 | |||
12 | Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com> | ||
13 | --- | ||
14 | Resource/Init/gs_dps1.ps | 3 +- | ||
15 | Resource/Init/gs_fonts.ps | 275 +++++++++++++++++++++----------------- | ||
16 | Resource/Init/gs_res.ps | 7 +- | ||
17 | 3 files changed, 157 insertions(+), 128 deletions(-) | ||
18 | |||
19 | diff --git a/Resource/Init/gs_dps1.ps b/Resource/Init/gs_dps1.ps | ||
20 | index b75ea14..8700c8c 100644 | ||
21 | --- a/Resource/Init/gs_dps1.ps | ||
22 | +++ b/Resource/Init/gs_dps1.ps | ||
23 | @@ -67,7 +67,8 @@ level2dict begin | ||
24 | |||
25 | /selectfont % <fontname> <size> selectfont - | ||
26 | { | ||
27 | - { 1 .argindex findfont | ||
28 | + { | ||
29 | + 1 .argindex findfont | ||
30 | 1 index dup type /arraytype eq { makefont } { scalefont } ifelse | ||
31 | setfont pop pop | ||
32 | } stopped { /selectfont .systemvar $error /errorname get signalerror } if | ||
33 | diff --git a/Resource/Init/gs_fonts.ps b/Resource/Init/gs_fonts.ps | ||
34 | index c13a2fc..0562235 100644 | ||
35 | --- a/Resource/Init/gs_fonts.ps | ||
36 | +++ b/Resource/Init/gs_fonts.ps | ||
37 | @@ -100,7 +100,7 @@ userdict /.nativeFontmap .FontDirectory maxlength dict put | ||
38 | { 2 index token not | ||
39 | { (Fontmap entry for ) print 1 index =only | ||
40 | ( ends prematurely! Giving up.) = flush | ||
41 | - {.loadFontmap} 0 get 1 .quit | ||
42 | + {//.loadFontmap exec} 0 get 1 .quit | ||
43 | } if | ||
44 | dup /; eq { pop 3 index 3 1 roll .growput exit } if | ||
45 | pop | ||
46 | @@ -202,6 +202,14 @@ NOFONTPATH { /FONTPATH () def } if | ||
47 | { pop } | ||
48 | { /FONTPATH (GS_FONTPATH) getenv not { () } if def } | ||
49 | ifelse | ||
50 | + | ||
51 | +% The following are dummy definitions that, if we have a FONTPATH, will | ||
52 | +% be replaced in the following section. | ||
53 | +% They are here so immediately evaulation will work, and allow them to | ||
54 | +% undefined at the bottom of the file. | ||
55 | +/.scanfontbegin{} bind def | ||
56 | +/.scanfontdir {} bind def | ||
57 | + | ||
58 | FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if | ||
59 | /FONTPATH [ FONTPATH .pathlist ] def | ||
60 | |||
61 | @@ -242,12 +250,12 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if | ||
62 | /.scanfontbegin | ||
63 | { % Construct the table of all file names already in Fontmap. | ||
64 | currentglobal //true setglobal | ||
65 | - .scanfontdict dup maxlength Fontmap length 2 add .max .setmaxlength | ||
66 | + //.scanfontdict dup maxlength Fontmap length 2 add .max .setmaxlength | ||
67 | Fontmap | ||
68 | { exch pop | ||
69 | { dup type /stringtype eq | ||
70 | - { .splitfilename pop .fonttempstring copy .lowerstring cvn | ||
71 | - .scanfontdict exch //true put | ||
72 | + { //.splitfilename exec pop //.fonttempstring copy //.lowerstring exec cvn | ||
73 | + //.scanfontdict exch //true put | ||
74 | } | ||
75 | { pop | ||
76 | } | ||
77 | @@ -280,9 +288,9 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if | ||
78 | /txt //true | ||
79 | .dicttomark def | ||
80 | /.scan1fontstring 8192 string def | ||
81 | -% %%BeginFont: is not per Adobe documentation, but a few fonts have it. | ||
82 | +% BeginFont: is not per Adobe documentation, but a few fonts have it. | ||
83 | /.scanfontheaders [(%!PS-Adobe*) (%!FontType*) (%%BeginFont:*)] def | ||
84 | -0 .scanfontheaders { length .max } forall 6 add % extra for PFB header | ||
85 | +0 //.scanfontheaders { length .max } forall 6 add % extra for PFB header | ||
86 | /.scan1fontfirst exch string def | ||
87 | /.scanfontdir % <dirname> .scanfontdir - | ||
88 | { currentglobal exch //true setglobal | ||
89 | @@ -291,10 +299,10 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if | ||
90 | 0 0 0 4 -1 roll % found scanned files | ||
91 | { % stack: <fontcount> <scancount> <filecount> <filename> | ||
92 | exch 1 add exch % increment filecount | ||
93 | - dup .splitfilename .fonttempstring copy .lowerstring | ||
94 | + dup //.splitfilename exec //.fonttempstring copy //.lowerstring exec | ||
95 | % stack: <fontcount> <scancount> <filecount+1> <filename> | ||
96 | % <BASE> <ext> | ||
97 | - .scanfontskip exch known exch .scanfontdict exch known or | ||
98 | + //.scanfontskip exch known exch //.scanfontdict exch known or | ||
99 | { pop | ||
100 | % stack: <fontcount> <scancount> <filecount+1> | ||
101 | } | ||
102 | @@ -309,7 +317,7 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if | ||
103 | % On some platforms, the file operator will open directories, | ||
104 | % but an error will occur if we try to read from one. | ||
105 | % Handle this possibility here. | ||
106 | - dup .scan1fontfirst { readstring } .internalstopped | ||
107 | + dup //.scan1fontfirst { readstring } .internalstopped | ||
108 | { pop pop () } | ||
109 | { pop } | ||
110 | ifelse | ||
111 | @@ -322,7 +330,7 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if | ||
112 | { dup length 6 sub 6 exch getinterval } | ||
113 | if | ||
114 | % Check for font file headers. | ||
115 | - //false .scanfontheaders | ||
116 | + //false //.scanfontheaders | ||
117 | { 2 index exch .stringmatch or | ||
118 | } | ||
119 | forall exch pop | ||
120 | @@ -335,7 +343,7 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if | ||
121 | { exch copystring exch | ||
122 | DEBUG { ( ) print dup =only flush } if | ||
123 | 1 index .definenativefontmap | ||
124 | - .splitfilename pop //true .scanfontdict 3 1 roll .growput | ||
125 | + //.splitfilename exec pop //true //.scanfontdict 3 1 roll .growput | ||
126 | % Increment fontcount. | ||
127 | 3 -1 roll 1 add 3 1 roll | ||
128 | } | ||
129 | @@ -352,7 +360,7 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if | ||
130 | } | ||
131 | ifelse | ||
132 | } | ||
133 | - .scan1fontstring filenameforall | ||
134 | + //.scan1fontstring filenameforall | ||
135 | QUIET | ||
136 | { pop pop pop } | ||
137 | { ( ) print =only ( files, ) print =only ( scanned, ) print | ||
138 | @@ -422,7 +430,6 @@ systemdict /NONATIVEFONTMAP known .setnativefontmapbuilt | ||
139 | //true .setnativefontmapbuilt | ||
140 | } ifelse | ||
141 | } bind def | ||
142 | -currentdict /.setnativefontmapbuilt .forceundef | ||
143 | |||
144 | % Create the dictionary that registers the .buildfont procedure | ||
145 | % (called by definefont) for each FontType. | ||
146 | @@ -526,7 +533,8 @@ buildfontdict 3 /.buildfont3 cvx put | ||
147 | % We use this only for explicitly aliased fonts, not substituted fonts: | ||
148 | % we think this matches the observed behavior of Adobe interpreters. | ||
149 | /.aliasfont % <name> <font> .aliasfont <newFont> | ||
150 | - { .currentglobal 3 1 roll dup .gcheck .setglobal | ||
151 | + { | ||
152 | + currentglobal 3 1 roll dup gcheck setglobal | ||
153 | % <bool> <name> <font> | ||
154 | dup length 2 add dict % <bool> <name> <font> <dict> | ||
155 | dup 3 -1 roll % <bool> <name> <dict> <dict> <font> | ||
156 | @@ -541,7 +549,7 @@ buildfontdict 3 /.buildfont3 cvx put | ||
157 | % whose FontName is a local non-string, if someone passed a | ||
158 | % garbage value to findfont. In this case, just don't | ||
159 | % call definefont at all. | ||
160 | - 2 index dup type /stringtype eq exch .gcheck or 1 index .gcheck not or | ||
161 | + 2 index dup type /stringtype eq exch gcheck or 1 index gcheck not or | ||
162 | { pop % <bool> <name> <dict> | ||
163 | 1 index dup type /stringtype eq { cvn } if | ||
164 | % <bool> <name> <dict> <name1> | ||
165 | @@ -566,10 +574,11 @@ buildfontdict 3 /.buildfont3 cvx put | ||
166 | % Don't bind in definefont, since Level 2 redefines it. | ||
167 | /definefont .systemvar exec | ||
168 | } | ||
169 | - { /findfont cvx {.completefont} .errorexec pop exch pop | ||
170 | + { | ||
171 | + /findfont cvx {.completefont} //.errorexec exec pop exch pop | ||
172 | } | ||
173 | ifelse | ||
174 | - exch .setglobal | ||
175 | + exch setglobal | ||
176 | } odef % so findfont will bind it | ||
177 | |||
178 | % Define .loadfontfile for loading a font. If we recognize Type 1 and/or | ||
179 | @@ -669,10 +678,19 @@ buildfontdict 3 /.buildfont3 cvx put | ||
180 | [(Cn) 4] [(Cond) 4] [(Narrow) 4] [(Pkg) 4] [(Compr) 4] | ||
181 | [(Serif) 8] [(Sans) -8] | ||
182 | ] readonly def | ||
183 | + | ||
184 | +/.fontnamestring { % <fontname> .fontnamestring <string|name> | ||
185 | + dup type dup /nametype eq { | ||
186 | + pop .namestring | ||
187 | + } { | ||
188 | + /stringtype ne { pop () } if | ||
189 | + } ifelse | ||
190 | +} bind def | ||
191 | + | ||
192 | /.fontnameproperties { % <int> <string|name> .fontnameproperties | ||
193 | % <int'> | ||
194 | - .fontnamestring | ||
195 | - .substituteproperties { | ||
196 | + //.fontnamestring exec | ||
197 | + //.substituteproperties { | ||
198 | 2 copy 0 get search { | ||
199 | pop pop pop dup length 1 sub 1 exch getinterval 3 -1 roll exch { | ||
200 | dup 0 ge { or } { neg not and } ifelse | ||
201 | @@ -710,13 +728,7 @@ buildfontdict 3 /.buildfont3 cvx put | ||
202 | % <other> .nametostring <other> | ||
203 | dup type /nametype eq { .namestring } if | ||
204 | } bind def | ||
205 | -/.fontnamestring { % <fontname> .fontnamestring <string|name> | ||
206 | - dup type dup /nametype eq { | ||
207 | - pop .namestring | ||
208 | - } { | ||
209 | - /stringtype ne { pop () } if | ||
210 | - } ifelse | ||
211 | -} bind def | ||
212 | + | ||
213 | /.substitutefontname { % <fontname> <properties> .substitutefontname | ||
214 | % <altname|null> | ||
215 | % Look for properties and/or a face name in the font name. | ||
216 | @@ -724,7 +736,7 @@ buildfontdict 3 /.buildfont3 cvx put | ||
217 | % base font; otherwise, use the default font. | ||
218 | % Note that the "substituted" font name may be the same as | ||
219 | % the requested one; the caller must check this. | ||
220 | - exch .fontnamestring { | ||
221 | + exch //.fontnamestring exec { | ||
222 | defaultfontname /Helvetica-Oblique /Helvetica-Bold /Helvetica-BoldOblique | ||
223 | /Helvetica-Narrow /Helvetica-Narrow-Oblique | ||
224 | /Helvetica-Narrow-Bold /Helvetica-Narrow-BoldOblique | ||
225 | @@ -734,12 +746,12 @@ buildfontdict 3 /.buildfont3 cvx put | ||
226 | } 3 1 roll | ||
227 | % Stack: facelist properties fontname | ||
228 | % Look for a face name. | ||
229 | - .substitutefaces { | ||
230 | + //.substitutefaces { | ||
231 | 2 copy 0 get search { | ||
232 | pop pop pop | ||
233 | % Stack: facelist properties fontname [(pattern) family properties] | ||
234 | dup 2 get 4 -1 roll or 3 1 roll | ||
235 | - 1 get .substitutefamilies exch get | ||
236 | + 1 get //.substitutefamilies exch get | ||
237 | 4 -1 roll pop 3 1 roll | ||
238 | } { | ||
239 | pop pop | ||
240 | @@ -748,7 +760,7 @@ buildfontdict 3 /.buildfont3 cvx put | ||
241 | 1 index length mod get exec | ||
242 | } bind def | ||
243 | /.substitutefont { % <fontname> .substitutefont <altname> | ||
244 | - dup 0 exch .fontnameproperties .substitutefontname | ||
245 | + dup 0 exch //.fontnameproperties exec .substitutefontname | ||
246 | % Only accept fonts known in the Fontmap. | ||
247 | Fontmap 1 index known not | ||
248 | { | ||
249 | @@ -814,7 +826,7 @@ FAKEFONTS not { (%END FAKEFONTS) .skipeof } if | ||
250 | counttomark 1 sub { .aliasfont } repeat end | ||
251 | % <fontname> mark <font> | ||
252 | exch pop exch pop | ||
253 | -} odef | ||
254 | +} bind odef | ||
255 | /findfont { | ||
256 | .findfont | ||
257 | } bind def | ||
258 | @@ -860,7 +872,7 @@ FAKEFONTS not { (%END FAKEFONTS) .skipeof } if | ||
259 | } { | ||
260 | dup .substitutefont | ||
261 | 2 copy eq { pop defaultfontname } if | ||
262 | - .checkalias | ||
263 | + //.checkalias exec | ||
264 | QUIET not { | ||
265 | SHORTERRORS { | ||
266 | (%%[) print 1 index =only | ||
267 | @@ -886,8 +898,8 @@ $error /SubstituteFont { } put | ||
268 | //null 0 1 FONTPATH length 1 sub { | ||
269 | FONTPATH 1 index get //null ne { exch pop exit } if pop | ||
270 | } for dup //null ne { | ||
271 | - dup 0 eq { .scanfontbegin } if | ||
272 | - FONTPATH 1 index get .scanfontdir | ||
273 | + dup 0 eq { //.scanfontbegin exec} if | ||
274 | + FONTPATH 1 index get //.scanfontdir exec | ||
275 | FONTPATH exch //null put //true | ||
276 | } { | ||
277 | pop //false | ||
278 | @@ -897,11 +909,10 @@ $error /SubstituteFont { } put | ||
279 | % scanning of FONTPATH. | ||
280 | /.dofindfont { % mark <fontname> .dofindfont % mark <alias> ... <font> | ||
281 | .tryfindfont not { | ||
282 | - | ||
283 | % We didn't find the font. If we haven't scanned | ||
284 | % all the directories in FONTPATH, scan the next one | ||
285 | % now and look for the font again. | ||
286 | - .scannextfontdir { | ||
287 | + //.scannextfontdir exec { | ||
288 | % Start over with an empty alias list. | ||
289 | counttomark 1 sub { pop } repeat % mark <fontname> | ||
290 | .dofindfont | ||
291 | @@ -927,6 +938,7 @@ $error /SubstituteFont { } put | ||
292 | } if | ||
293 | % Substitute for the font. Don't alias. | ||
294 | % Same stack as at the beginning of .dofindfont. | ||
295 | + | ||
296 | $error /SubstituteFont get exec | ||
297 | % | ||
298 | % igorm: I guess the surrounding code assumes that .stdsubstfont | ||
299 | @@ -935,72 +947,11 @@ $error /SubstituteFont { } put | ||
300 | % used in .dofindfont and through .stdsubstfont | ||
301 | % just to represent a simple iteration, | ||
302 | % which accumulates the aliases after the mark. | ||
303 | - .stdsubstfont | ||
304 | + //.stdsubstfont exec | ||
305 | } ifelse | ||
306 | } ifelse | ||
307 | } if | ||
308 | } bind def | ||
309 | -% Try to find a font using only the present contents of Fontmap. | ||
310 | -/.tryfindfont { % <fontname> .tryfindfont <font> true | ||
311 | - % <fontname> .tryfindfont false | ||
312 | - //.FontDirectory 1 index .fontknownget | ||
313 | - { % Already loaded | ||
314 | - exch pop //true | ||
315 | - } | ||
316 | - { | ||
317 | - dup Fontmap exch .knownget | ||
318 | - { //true //true } | ||
319 | - { % Unknown font name. Look for a file with the | ||
320 | - % same name as the requested font. | ||
321 | - dup .tryloadfont | ||
322 | - { exch pop //true //false } | ||
323 | - { | ||
324 | - % if we can't load by name check the native font map | ||
325 | - dup .nativeFontmap exch .knownget | ||
326 | - { //true //true } | ||
327 | - { //false //false } ifelse | ||
328 | - } ifelse | ||
329 | - } ifelse | ||
330 | - | ||
331 | - { % Try each element of the Fontmap in turn. | ||
332 | - pop | ||
333 | - //false exch % (in case we exhaust the list) | ||
334 | - % Stack: fontname false fontmaplist | ||
335 | - { exch pop | ||
336 | - dup type /nametype eq | ||
337 | - { % Font alias | ||
338 | - .checkalias .tryfindfont exit | ||
339 | - } | ||
340 | - { dup dup type dup /arraytype eq exch /packedarraytype eq or exch xcheck and | ||
341 | - { % Font with a procedural definition | ||
342 | - exec % The procedure will load the font. | ||
343 | - % Check to make sure this really happened. | ||
344 | - //.FontDirectory 1 index .knownget | ||
345 | - { exch pop //true exit } | ||
346 | - if | ||
347 | - } | ||
348 | - { % Font file name | ||
349 | - //true .loadfontloop { //true exit } if | ||
350 | - } | ||
351 | - ifelse | ||
352 | - } | ||
353 | - ifelse //false | ||
354 | - } | ||
355 | - forall | ||
356 | - % Stack: font true -or- fontname false | ||
357 | - { //true | ||
358 | - } | ||
359 | - { % None of the Fontmap entries worked. | ||
360 | - % Try loading a file with the same name | ||
361 | - % as the requested font. | ||
362 | - .tryloadfont | ||
363 | - } | ||
364 | - ifelse | ||
365 | - } | ||
366 | - if | ||
367 | - } | ||
368 | - ifelse | ||
369 | - } bind def | ||
370 | |||
371 | % any user of .putgstringcopy must use bind and executeonly | ||
372 | /.putgstringcopy % <dict> <name> <string> .putgstringcopy - | ||
373 | @@ -1014,25 +965,6 @@ $error /SubstituteFont { } put | ||
374 | } executeonly ifelse | ||
375 | } .bind executeonly odef % must be bound and hidden for .forceput | ||
376 | |||
377 | -% Attempt to load a font from a file. | ||
378 | -/.tryloadfont { % <fontname> .tryloadfont <font> true | ||
379 | - % <fontname> .tryloadfont false | ||
380 | - dup .nametostring | ||
381 | - % Hack: check for the presence of the resource machinery. | ||
382 | - /.genericrfn where { | ||
383 | - pop | ||
384 | - pop dup .fonttempstring /FontResourceDir getsystemparam .genericrfn | ||
385 | - {//false .loadfontloop} .internalstopped {//false} if { | ||
386 | - //true | ||
387 | - } { | ||
388 | - dup .nametostring | ||
389 | - {//true .loadfontloop} .internalstopped {//false} if | ||
390 | - } ifelse | ||
391 | - } { | ||
392 | - {//true .loadfontloop} .internalstopped {//false} if | ||
393 | - } ifelse | ||
394 | -} bind def | ||
395 | - | ||
396 | /.loadfontloop { % <fontname> <filename> <libflag> .loadfontloop | ||
397 | % <font> true | ||
398 | % -or- | ||
399 | @@ -1102,7 +1034,7 @@ $error /SubstituteFont { } put | ||
400 | } if | ||
401 | |||
402 | % Check to make sure the font was actually loaded. | ||
403 | - dup 3 index .fontknownget | ||
404 | + dup 3 index //.fontknownget exec | ||
405 | { dup /PathLoad 4 index .putgstringcopy | ||
406 | 4 1 roll pop pop pop //true exit | ||
407 | } executeonly if | ||
408 | @@ -1113,7 +1045,7 @@ $error /SubstituteFont { } put | ||
409 | exch dup % Stack: origfontname fontdirectory path path | ||
410 | (r) file .findfontname | ||
411 | { % Stack: origfontname fontdirectory path filefontname | ||
412 | - 2 index 1 index .fontknownget | ||
413 | + 2 index 1 index //.fontknownget exec | ||
414 | { % Yes. Stack: origfontname fontdirectory path filefontname fontdict | ||
415 | dup 4 -1 roll /PathLoad exch .putgstringcopy | ||
416 | % Stack: origfontname fontdirectory filefontname fontdict | ||
417 | @@ -1136,7 +1068,7 @@ $error /SubstituteFont { } put | ||
418 | % Stack: fontdict | ||
419 | } executeonly | ||
420 | if pop % Stack: origfontname fontdirectory path | ||
421 | - } | ||
422 | + } executeonly | ||
423 | if pop pop % Stack: origfontname | ||
424 | |||
425 | % The font definitely did not load correctly. | ||
426 | @@ -1150,7 +1082,87 @@ $error /SubstituteFont { } put | ||
427 | |||
428 | } bind executeonly odef % must be bound and hidden for .putgstringcopy | ||
429 | |||
430 | -currentdict /.putgstringcopy .undef | ||
431 | +% Attempt to load a font from a file. | ||
432 | +/.tryloadfont { % <fontname> .tryloadfont <font> true | ||
433 | + % <fontname> .tryloadfont false | ||
434 | + dup //.nametostring exec | ||
435 | + % Hack: check for the presence of the resource machinery. | ||
436 | + /.genericrfn where { | ||
437 | + pop | ||
438 | + pop dup //.fonttempstring /FontResourceDir getsystemparam .genericrfn | ||
439 | + {//false .loadfontloop} .internalstopped {//false} if { | ||
440 | + //true | ||
441 | + } { | ||
442 | + dup //.nametostring exec | ||
443 | + {//true .loadfontloop} .internalstopped {//false} if | ||
444 | + } ifelse | ||
445 | + } { | ||
446 | + {//true .loadfontloop} .internalstopped {//false} if | ||
447 | + } ifelse | ||
448 | +} bind def | ||
449 | + | ||
450 | +% Try to find a font using only the present contents of Fontmap. | ||
451 | +/.tryfindfont { % <fontname> .tryfindfont <font> true | ||
452 | + % <fontname> .tryfindfont false | ||
453 | + //.FontDirectory 1 index //.fontknownget exec | ||
454 | + { % Already loaded | ||
455 | + exch pop //true | ||
456 | + } | ||
457 | + { | ||
458 | + dup Fontmap exch .knownget | ||
459 | + { //true //true } | ||
460 | + { % Unknown font name. Look for a file with the | ||
461 | + % same name as the requested font. | ||
462 | + dup //.tryloadfont exec | ||
463 | + { exch pop //true //false } | ||
464 | + { | ||
465 | + % if we can't load by name check the native font map | ||
466 | + dup .nativeFontmap exch .knownget | ||
467 | + { //true //true } | ||
468 | + { //false //false } ifelse | ||
469 | + } ifelse | ||
470 | + } ifelse | ||
471 | + | ||
472 | + { % Try each element of the Fontmap in turn. | ||
473 | + pop | ||
474 | + //false exch % (in case we exhaust the list) | ||
475 | + % Stack: fontname false fontmaplist | ||
476 | + { exch pop | ||
477 | + dup type /nametype eq | ||
478 | + { % Font alias | ||
479 | + //.checkalias exec | ||
480 | + .tryfindfont exit | ||
481 | + } | ||
482 | + { dup dup type dup /arraytype eq exch /packedarraytype eq or exch xcheck and | ||
483 | + { % Font with a procedural definition | ||
484 | + exec % The procedure will load the font. | ||
485 | + % Check to make sure this really happened. | ||
486 | + //.FontDirectory 1 index .knownget | ||
487 | + { exch pop //true exit } | ||
488 | + if | ||
489 | + } | ||
490 | + { % Font file name | ||
491 | + //true .loadfontloop { //true exit } if | ||
492 | + } | ||
493 | + ifelse | ||
494 | + } | ||
495 | + ifelse //false | ||
496 | + } | ||
497 | + forall | ||
498 | + % Stack: font true -or- fontname false | ||
499 | + { //true | ||
500 | + } | ||
501 | + { % None of the Fontmap entries worked. | ||
502 | + % Try loading a file with the same name | ||
503 | + % as the requested font. | ||
504 | + //.tryloadfont exec | ||
505 | + } | ||
506 | + ifelse | ||
507 | + } | ||
508 | + if | ||
509 | + } | ||
510 | + ifelse | ||
511 | + } bind def | ||
512 | |||
513 | % Define a procedure to load all known fonts. | ||
514 | % This isn't likely to be very useful. | ||
515 | @@ -1192,9 +1204,9 @@ FAKEFONTS { exch } if pop def % don't bind, .current/setglobal get redefined | ||
516 | /.loadinitialfonts | ||
517 | { NOFONTMAP not | ||
518 | { /FONTMAP where | ||
519 | - { pop [ FONTMAP .pathlist ] | ||
520 | + { pop [ FONTMAP //.pathlist exec] | ||
521 | { dup VMDEBUG findlibfile | ||
522 | - { exch pop .loadFontmap } | ||
523 | + { exch pop //.loadFontmap exec } | ||
524 | { /undefinedfilename signalerror } | ||
525 | ifelse | ||
526 | } | ||
527 | @@ -1208,7 +1220,7 @@ FAKEFONTS { exch } if pop def % don't bind, .current/setglobal get redefined | ||
528 | pop pop | ||
529 | defaultfontmap_content { .definefontmap } forall | ||
530 | } { | ||
531 | - .loadFontmap | ||
532 | + //.loadFontmap exec | ||
533 | } ifelse | ||
534 | } { | ||
535 | pop pop | ||
536 | @@ -1272,3 +1284,18 @@ FAKEFONTS { exch } if pop def % don't bind, .current/setglobal get redefined | ||
537 | { .makemodifiedfont | ||
538 | dup /FontName get exch definefont pop | ||
539 | } bind def | ||
540 | + | ||
541 | +% Undef these, not needed outside this file | ||
542 | +[ | ||
543 | + % /.fonttempstring /.scannextfontdir - are also used in gs_res.ps, so are undefined there | ||
544 | + % /.fontnameproperties - is used in pdf_font.ps | ||
545 | + % /.scanfontheaders - used in gs_cff.ps, gs_ttf.ps | ||
546 | + /.loadfontloop /.tryloadfont /.findfont /.pathlist /.loadFontmap /.lowerstring | ||
547 | + /.splitfilename /.scanfontdict /.scanfontbegin | ||
548 | + /.scanfontskip /.scan1fontstring | ||
549 | + /.scan1fontfirst /.scanfontdir | ||
550 | + /.setnativefontmapbuilt /.aliasfont | ||
551 | + /.setloadingfont /.substitutefaces /.substituteproperties /.substitutefamilies | ||
552 | + /.nametostring /.fontnamestring /.checkalias /.fontknownget /.stdsubstfont | ||
553 | + /.putgstringcopy | ||
554 | +] {systemdict exch .forceundef} forall | ||
555 | diff --git a/Resource/Init/gs_res.ps b/Resource/Init/gs_res.ps | ||
556 | index 18d5452..b016113 100644 | ||
557 | --- a/Resource/Init/gs_res.ps | ||
558 | +++ b/Resource/Init/gs_res.ps | ||
559 | @@ -961,7 +961,7 @@ userdict /.localcsdefaults //false put | ||
560 | dup type /nametype eq { .namestring } if | ||
561 | dup type /stringtype ne { //false exit } if | ||
562 | % Check the resource directory. | ||
563 | - dup .fonttempstring /FontResourceDir getsystemparam .genericrfn | ||
564 | + dup //.fonttempstring /FontResourceDir getsystemparam .genericrfn | ||
565 | status { | ||
566 | pop pop pop pop //true exit | ||
567 | } if | ||
568 | @@ -969,7 +969,7 @@ userdict /.localcsdefaults //false put | ||
569 | % as the font. | ||
570 | findlibfile { closefile //true exit } if | ||
571 | % Scan a FONTPATH directory and try again. | ||
572 | - .scannextfontdir not { //false exit } if | ||
573 | + //.scannextfontdir exec not { //false exit } if | ||
574 | } loop | ||
575 | } bind def | ||
576 | |||
577 | @@ -1008,7 +1008,7 @@ currentdict /.fontstatusaux .undef | ||
578 | } ifelse | ||
579 | } bind executeonly | ||
580 | /ResourceForAll { | ||
581 | - { .scannextfontdir not { exit } if } loop | ||
582 | + { //.scannextfontdir exec not { exit } if } loop | ||
583 | /Generic /Category findresource /ResourceForAll get exec | ||
584 | } bind executeonly | ||
585 | /.ResourceFileStatus { | ||
586 | @@ -1163,6 +1163,7 @@ end % level2dict | ||
587 | [ | ||
588 | /.default_resource_dir | ||
589 | /.resource_dir_name | ||
590 | + /.fonttempstring /.scannextfontdir % from gs_fonts.ps | ||
591 | ] | ||
592 | {systemdict exch .forceundef} forall | ||
593 | |||
594 | -- | ||
595 | 2.18.1 | ||
596 | |||