summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Resource/Init/gs_dps1.ps3
-rw-r--r--Resource/Init/gs_fonts.ps276
-rw-r--r--Resource/Init/gs_res.ps7
3 files changed, 158 insertions, 128 deletions
diff --git a/Resource/Init/gs_dps1.ps b/Resource/Init/gs_dps1.ps
index b681ec783..719e7e1e0 100644
--- a/Resource/Init/gs_dps1.ps
+++ b/Resource/Init/gs_dps1.ps
@@ -67,7 +67,8 @@ level2dict begin
67 67
68/selectfont % <fontname> <size> selectfont - 68/selectfont % <fontname> <size> selectfont -
69 { 69 {
70 { 1 .argindex findfont 70 {
71 1 .argindex findfont
71 1 index dup type /arraytype eq { makefont } { scalefont } ifelse 72 1 index dup type /arraytype eq { makefont } { scalefont } ifelse
72 setfont pop pop 73 setfont pop pop
73 } stopped { /selectfont .systemvar $error /errorname get signalerror } if 74 } stopped { /selectfont .systemvar $error /errorname get signalerror } if
diff --git a/Resource/Init/gs_fonts.ps b/Resource/Init/gs_fonts.ps
index 48b1b2d62..63164d0ce 100644
--- a/Resource/Init/gs_fonts.ps
+++ b/Resource/Init/gs_fonts.ps
@@ -100,7 +100,7 @@ userdict /.nativeFontmap .FontDirectory maxlength dict put
100 { 2 index token not 100 { 2 index token not
101 { (Fontmap entry for ) print 1 index =only 101 { (Fontmap entry for ) print 1 index =only
102 ( ends prematurely! Giving up.) = flush 102 ( ends prematurely! Giving up.) = flush
103 {.loadFontmap} 0 get 1 .quit 103 {//.loadFontmap exec} 0 get 1 .quit
104 } if 104 } if
105 dup /; eq { pop 3 index 3 1 roll .growput exit } if 105 dup /; eq { pop 3 index 3 1 roll .growput exit } if
106 pop 106 pop
@@ -202,6 +202,14 @@ NOFONTPATH { /FONTPATH () def } if
202 { pop } 202 { pop }
203 { /FONTPATH (GS_FONTPATH) getenv not { () } if def } 203 { /FONTPATH (GS_FONTPATH) getenv not { () } if def }
204ifelse 204ifelse
205
206% The following are dummy definitions that, if we have a FONTPATH, will
207% be replaced in the following section.
208% They are here so immediately evaulation will work, and allow them to
209% undefined at the bottom of the file.
210/.scanfontbegin{} bind def
211/.scanfontdir {} bind def
212
205FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if 213FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if
206/FONTPATH [ FONTPATH .pathlist ] def 214/FONTPATH [ FONTPATH .pathlist ] def
207 215
@@ -242,12 +250,12 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if
242/.scanfontbegin 250/.scanfontbegin
243 { % Construct the table of all file names already in Fontmap. 251 { % Construct the table of all file names already in Fontmap.
244 currentglobal //true setglobal 252 currentglobal //true setglobal
245 .scanfontdict dup maxlength Fontmap length 2 add .max .setmaxlength 253 //.scanfontdict dup maxlength Fontmap length 2 add .max .setmaxlength
246 Fontmap 254 Fontmap
247 { exch pop 255 { exch pop
248 { dup type /stringtype eq 256 { dup type /stringtype eq
249 { .splitfilename pop .fonttempstring copy .lowerstring cvn 257 { //.splitfilename exec pop //.fonttempstring copy //.lowerstring exec cvn
250 .scanfontdict exch //true put 258 //.scanfontdict exch //true put
251 } 259 }
252 { pop 260 { pop
253 } 261 }
@@ -280,9 +288,9 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if
280 /txt //true 288 /txt //true
281.dicttomark def 289.dicttomark def
282/.scan1fontstring 8192 string def 290/.scan1fontstring 8192 string def
283% %%BeginFont: is not per Adobe documentation, but a few fonts have it. 291% BeginFont: is not per Adobe documentation, but a few fonts have it.
284/.scanfontheaders [(%!PS-Adobe*) (%!FontType*) (%%BeginFont:*)] def 292/.scanfontheaders [(%!PS-Adobe*) (%!FontType*) (%%BeginFont:*)] def
2850 .scanfontheaders { length .max } forall 6 add % extra for PFB header 2930 //.scanfontheaders { length .max } forall 6 add % extra for PFB header
286/.scan1fontfirst exch string def 294/.scan1fontfirst exch string def
287/.scanfontdir % <dirname> .scanfontdir - 295/.scanfontdir % <dirname> .scanfontdir -
288 { currentglobal exch //true setglobal 296 { currentglobal exch //true setglobal
@@ -291,10 +299,10 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if
291 0 0 0 4 -1 roll % found scanned files 299 0 0 0 4 -1 roll % found scanned files
292 { % stack: <fontcount> <scancount> <filecount> <filename> 300 { % stack: <fontcount> <scancount> <filecount> <filename>
293 exch 1 add exch % increment filecount 301 exch 1 add exch % increment filecount
294 dup .splitfilename .fonttempstring copy .lowerstring 302 dup //.splitfilename exec //.fonttempstring copy //.lowerstring exec
295 % stack: <fontcount> <scancount> <filecount+1> <filename> 303 % stack: <fontcount> <scancount> <filecount+1> <filename>
296 % <BASE> <ext> 304 % <BASE> <ext>
297 .scanfontskip exch known exch .scanfontdict exch known or 305 //.scanfontskip exch known exch //.scanfontdict exch known or
298 { pop 306 { pop
299 % stack: <fontcount> <scancount> <filecount+1> 307 % stack: <fontcount> <scancount> <filecount+1>
300 } 308 }
@@ -309,7 +317,7 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if
309 % On some platforms, the file operator will open directories, 317 % On some platforms, the file operator will open directories,
310 % but an error will occur if we try to read from one. 318 % but an error will occur if we try to read from one.
311 % Handle this possibility here. 319 % Handle this possibility here.
312 dup .scan1fontfirst { readstring } .internalstopped 320 dup //.scan1fontfirst { readstring } .internalstopped
313 { pop pop () } 321 { pop pop () }
314 { pop } 322 { pop }
315 ifelse 323 ifelse
@@ -322,7 +330,7 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if
322 { dup length 6 sub 6 exch getinterval } 330 { dup length 6 sub 6 exch getinterval }
323 if 331 if
324 % Check for font file headers. 332 % Check for font file headers.
325 //false .scanfontheaders 333 //false //.scanfontheaders
326 { 2 index exch .stringmatch or 334 { 2 index exch .stringmatch or
327 } 335 }
328 forall exch pop 336 forall exch pop
@@ -335,7 +343,7 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if
335 { exch copystring exch 343 { exch copystring exch
336 DEBUG { ( ) print dup =only flush } if 344 DEBUG { ( ) print dup =only flush } if
337 1 index .definenativefontmap 345 1 index .definenativefontmap
338 .splitfilename pop //true .scanfontdict 3 1 roll .growput 346 //.splitfilename exec pop //true //.scanfontdict 3 1 roll .growput
339 % Increment fontcount. 347 % Increment fontcount.
340 3 -1 roll 1 add 3 1 roll 348 3 -1 roll 1 add 3 1 roll
341 } 349 }
@@ -352,7 +360,7 @@ FONTPATH length 0 eq { (%END FONTPATH) .skipeof } if
352 } 360 }
353 ifelse 361 ifelse
354 } 362 }
355 .scan1fontstring filenameforall 363 //.scan1fontstring filenameforall
356 QUIET 364 QUIET
357 { pop pop pop } 365 { pop pop pop }
358 { ( ) print =only ( files, ) print =only ( scanned, ) print 366 { ( ) print =only ( files, ) print =only ( scanned, ) print
@@ -422,7 +430,6 @@ systemdict /NONATIVEFONTMAP known .setnativefontmapbuilt
422 //true //.setnativefontmapbuilt 430 //true //.setnativefontmapbuilt
423 } ifelse 431 } ifelse
424} bind def 432} bind def
425currentdict /.setnativefontmapbuilt .forceundef
426 433
427% Create the dictionary that registers the .buildfont procedure 434% Create the dictionary that registers the .buildfont procedure
428% (called by definefont) for each FontType. 435% (called by definefont) for each FontType.
@@ -526,7 +533,8 @@ buildfontdict 3 /.buildfont3 cvx put
526% We use this only for explicitly aliased fonts, not substituted fonts: 533% We use this only for explicitly aliased fonts, not substituted fonts:
527% we think this matches the observed behavior of Adobe interpreters. 534% we think this matches the observed behavior of Adobe interpreters.
528/.aliasfont % <name> <font> .aliasfont <newFont> 535/.aliasfont % <name> <font> .aliasfont <newFont>
529 { .currentglobal 3 1 roll dup .gcheck .setglobal 536 {
537 currentglobal 3 1 roll dup gcheck setglobal
530 % <bool> <name> <font> 538 % <bool> <name> <font>
531 dup length 2 add dict % <bool> <name> <font> <dict> 539 dup length 2 add dict % <bool> <name> <font> <dict>
532 dup 3 -1 roll % <bool> <name> <dict> <dict> <font> 540 dup 3 -1 roll % <bool> <name> <dict> <dict> <font>
@@ -541,7 +549,7 @@ buildfontdict 3 /.buildfont3 cvx put
541 % whose FontName is a local non-string, if someone passed a 549 % whose FontName is a local non-string, if someone passed a
542 % garbage value to findfont. In this case, just don't 550 % garbage value to findfont. In this case, just don't
543 % call definefont at all. 551 % call definefont at all.
544 2 index dup type /stringtype eq exch .gcheck or 1 index .gcheck not or 552 2 index dup type /stringtype eq exch gcheck or 1 index gcheck not or
545 { pop % <bool> <name> <dict> 553 { pop % <bool> <name> <dict>
546 1 index dup type /stringtype eq { cvn } if 554 1 index dup type /stringtype eq { cvn } if
547 % <bool> <name> <dict> <name1> 555 % <bool> <name> <dict> <name1>
@@ -566,10 +574,11 @@ buildfontdict 3 /.buildfont3 cvx put
566 % Don't bind in definefont, since Level 2 redefines it. 574 % Don't bind in definefont, since Level 2 redefines it.
567 /definefont .systemvar exec 575 /definefont .systemvar exec
568 } 576 }
569 { /findfont cvx {.completefont} .errorexec pop exch pop 577 {
578 /findfont cvx {.completefont} //.errorexec exec pop exch pop
570 } 579 }
571 ifelse 580 ifelse
572 exch .setglobal 581 exch setglobal
573 } odef % so findfont will bind it 582 } odef % so findfont will bind it
574 583
575% Define .loadfontfile for loading a font. If we recognize Type 1 and/or 584% Define .loadfontfile for loading a font. If we recognize Type 1 and/or
@@ -669,10 +678,19 @@ buildfontdict 3 /.buildfont3 cvx put
669 [(Cn) 4] [(Cond) 4] [(Narrow) 4] [(Pkg) 4] [(Compr) 4] 678 [(Cn) 4] [(Cond) 4] [(Narrow) 4] [(Pkg) 4] [(Compr) 4]
670 [(Serif) 8] [(Sans) -8] 679 [(Serif) 8] [(Sans) -8]
671] readonly def 680] readonly def
681
682/.fontnamestring { % <fontname> .fontnamestring <string|name>
683 dup type dup /nametype eq {
684 pop .namestring
685 } {
686 /stringtype ne { pop () } if
687 } ifelse
688} bind def
689
672/.fontnameproperties { % <int> <string|name> .fontnameproperties 690/.fontnameproperties { % <int> <string|name> .fontnameproperties
673 % <int'> 691 % <int'>
674 .fontnamestring 692 //.fontnamestring exec
675 .substituteproperties { 693 //.substituteproperties {
676 2 copy 0 get search { 694 2 copy 0 get search {
677 pop pop pop dup length 1 sub 1 exch getinterval 3 -1 roll exch { 695 pop pop pop dup length 1 sub 1 exch getinterval 3 -1 roll exch {
678 dup 0 ge { or } { neg not and } ifelse 696 dup 0 ge { or } { neg not and } ifelse
@@ -710,13 +728,7 @@ buildfontdict 3 /.buildfont3 cvx put
710 % <other> .nametostring <other> 728 % <other> .nametostring <other>
711 dup type /nametype eq { .namestring } if 729 dup type /nametype eq { .namestring } if
712} bind def 730} bind def
713/.fontnamestring { % <fontname> .fontnamestring <string|name> 731
714 dup type dup /nametype eq {
715 pop .namestring
716 } {
717 /stringtype ne { pop () } if
718 } ifelse
719} bind def
720/.substitutefontname { % <fontname> <properties> .substitutefontname 732/.substitutefontname { % <fontname> <properties> .substitutefontname
721 % <altname|null> 733 % <altname|null>
722 % Look for properties and/or a face name in the font name. 734 % Look for properties and/or a face name in the font name.
@@ -724,7 +736,7 @@ buildfontdict 3 /.buildfont3 cvx put
724 % base font; otherwise, use the default font. 736 % base font; otherwise, use the default font.
725 % Note that the "substituted" font name may be the same as 737 % Note that the "substituted" font name may be the same as
726 % the requested one; the caller must check this. 738 % the requested one; the caller must check this.
727 exch .fontnamestring { 739 exch //.fontnamestring exec {
728 defaultfontname /Helvetica-Oblique /Helvetica-Bold /Helvetica-BoldOblique 740 defaultfontname /Helvetica-Oblique /Helvetica-Bold /Helvetica-BoldOblique
729 /Helvetica-Narrow /Helvetica-Narrow-Oblique 741 /Helvetica-Narrow /Helvetica-Narrow-Oblique
730 /Helvetica-Narrow-Bold /Helvetica-Narrow-BoldOblique 742 /Helvetica-Narrow-Bold /Helvetica-Narrow-BoldOblique
@@ -734,12 +746,12 @@ buildfontdict 3 /.buildfont3 cvx put
734 } 3 1 roll 746 } 3 1 roll
735 % Stack: facelist properties fontname 747 % Stack: facelist properties fontname
736 % Look for a face name. 748 % Look for a face name.
737 .substitutefaces { 749 //.substitutefaces {
738 2 copy 0 get search { 750 2 copy 0 get search {
739 pop pop pop 751 pop pop pop
740 % Stack: facelist properties fontname [(pattern) family properties] 752 % Stack: facelist properties fontname [(pattern) family properties]
741 dup 2 get 4 -1 roll or 3 1 roll 753 dup 2 get 4 -1 roll or 3 1 roll
742 1 get .substitutefamilies exch get 754 1 get //.substitutefamilies exch get
743 4 -1 roll pop 3 1 roll 755 4 -1 roll pop 3 1 roll
744 } { 756 } {
745 pop pop 757 pop pop
@@ -748,7 +760,7 @@ buildfontdict 3 /.buildfont3 cvx put
748 1 index length mod get exec 760 1 index length mod get exec
749} bind def 761} bind def
750/.substitutefont { % <fontname> .substitutefont <altname> 762/.substitutefont { % <fontname> .substitutefont <altname>
751 dup 0 exch .fontnameproperties .substitutefontname 763 dup 0 exch //.fontnameproperties exec .substitutefontname
752 % Only accept fonts known in the Fontmap. 764 % Only accept fonts known in the Fontmap.
753 Fontmap 1 index known not 765 Fontmap 1 index known not
754 { 766 {
@@ -814,7 +826,7 @@ FAKEFONTS not { (%END FAKEFONTS) .skipeof } if
814 counttomark 1 sub { .aliasfont } repeat end 826 counttomark 1 sub { .aliasfont } repeat end
815 % <fontname> mark <font> 827 % <fontname> mark <font>
816 exch pop exch pop 828 exch pop exch pop
817} odef 829} bind odef
818/findfont { 830/findfont {
819 .findfont 831 .findfont
820} bind def 832} bind def
@@ -860,7 +872,7 @@ FAKEFONTS not { (%END FAKEFONTS) .skipeof } if
860 } { 872 } {
861 dup .substitutefont 873 dup .substitutefont
862 2 copy eq { pop defaultfontname } if 874 2 copy eq { pop defaultfontname } if
863 .checkalias 875 //.checkalias exec
864 QUIET not { 876 QUIET not {
865 SHORTERRORS { 877 SHORTERRORS {
866 (%%[) print 1 index =only 878 (%%[) print 1 index =only
@@ -886,8 +898,8 @@ $error /SubstituteFont { } put
886 //null 0 1 FONTPATH length 1 sub { 898 //null 0 1 FONTPATH length 1 sub {
887 FONTPATH 1 index get //null ne { exch pop exit } if pop 899 FONTPATH 1 index get //null ne { exch pop exit } if pop
888 } for dup //null ne { 900 } for dup //null ne {
889 dup 0 eq { .scanfontbegin } if 901 dup 0 eq { //.scanfontbegin exec} if
890 FONTPATH 1 index get .scanfontdir 902 FONTPATH 1 index get //.scanfontdir exec
891 FONTPATH exch //null put //true 903 FONTPATH exch //null put //true
892 } { 904 } {
893 pop //false 905 pop //false
@@ -897,11 +909,10 @@ $error /SubstituteFont { } put
897% scanning of FONTPATH. 909% scanning of FONTPATH.
898/.dofindfont { % mark <fontname> .dofindfont % mark <alias> ... <font> 910/.dofindfont { % mark <fontname> .dofindfont % mark <alias> ... <font>
899 .tryfindfont not { 911 .tryfindfont not {
900
901 % We didn't find the font. If we haven't scanned 912 % We didn't find the font. If we haven't scanned
902 % all the directories in FONTPATH, scan the next one 913 % all the directories in FONTPATH, scan the next one
903 % now and look for the font again. 914 % now and look for the font again.
904 .scannextfontdir { 915 //.scannextfontdir exec {
905 % Start over with an empty alias list. 916 % Start over with an empty alias list.
906 counttomark 1 sub { pop } repeat % mark <fontname> 917 counttomark 1 sub { pop } repeat % mark <fontname>
907 .dofindfont 918 .dofindfont
@@ -927,6 +938,7 @@ $error /SubstituteFont { } put
927 } if 938 } if
928 % Substitute for the font. Don't alias. 939 % Substitute for the font. Don't alias.
929 % Same stack as at the beginning of .dofindfont. 940 % Same stack as at the beginning of .dofindfont.
941
930 $error /SubstituteFont get exec 942 $error /SubstituteFont get exec
931 % 943 %
932 % igorm: I guess the surrounding code assumes that .stdsubstfont 944 % igorm: I guess the surrounding code assumes that .stdsubstfont
@@ -935,72 +947,11 @@ $error /SubstituteFont { } put
935 % used in .dofindfont and through .stdsubstfont 947 % used in .dofindfont and through .stdsubstfont
936 % just to represent a simple iteration, 948 % just to represent a simple iteration,
937 % which accumulates the aliases after the mark. 949 % which accumulates the aliases after the mark.
938 .stdsubstfont 950 //.stdsubstfont exec
939 } ifelse 951 } ifelse
940 } ifelse 952 } ifelse
941 } if 953 } if
942} bind def 954} bind def
943% Try to find a font using only the present contents of Fontmap.
944/.tryfindfont { % <fontname> .tryfindfont <font> true
945 % <fontname> .tryfindfont false
946 //.FontDirectory 1 index .fontknownget
947 { % Already loaded
948 exch pop //true
949 }
950 {
951 dup Fontmap exch .knownget
952 { //true //true }
953 { % Unknown font name. Look for a file with the
954 % same name as the requested font.
955 dup .tryloadfont
956 { exch pop //true //false }
957 {
958 % if we can't load by name check the native font map
959 dup .nativeFontmap exch .knownget
960 { //true //true }
961 { //false //false } ifelse
962 } ifelse
963 } ifelse
964
965 { % Try each element of the Fontmap in turn.
966 pop
967 //false exch % (in case we exhaust the list)
968 % Stack: fontname false fontmaplist
969 { exch pop
970 dup type /nametype eq
971 { % Font alias
972 .checkalias .tryfindfont exit
973 }
974 { dup dup type dup /arraytype eq exch /packedarraytype eq or exch xcheck and
975 { % Font with a procedural definition
976 exec % The procedure will load the font.
977 % Check to make sure this really happened.
978 //.FontDirectory 1 index .knownget
979 { exch pop //true exit }
980 if
981 }
982 { % Font file name
983 //true .loadfontloop { //true exit } if
984 }
985 ifelse
986 }
987 ifelse //false
988 }
989 forall
990 % Stack: font true -or- fontname false
991 { //true
992 }
993 { % None of the Fontmap entries worked.
994 % Try loading a file with the same name
995 % as the requested font.
996 .tryloadfont
997 }
998 ifelse
999 }
1000 if
1001 }
1002 ifelse
1003 } bind def
1004 955
1005% any user of .putgstringcopy must use bind and executeonly 956% any user of .putgstringcopy must use bind and executeonly
1006/.putgstringcopy % <dict> <name> <string> .putgstringcopy - 957/.putgstringcopy % <dict> <name> <string> .putgstringcopy -
@@ -1014,25 +965,6 @@ $error /SubstituteFont { } put
1014 } executeonly ifelse 965 } executeonly ifelse
1015} .bind executeonly odef % must be bound and hidden for .forceput 966} .bind executeonly odef % must be bound and hidden for .forceput
1016 967
1017% Attempt to load a font from a file.
1018/.tryloadfont { % <fontname> .tryloadfont <font> true
1019 % <fontname> .tryloadfont false
1020 dup .nametostring
1021 % Hack: check for the presence of the resource machinery.
1022 /.genericrfn where {
1023 pop
1024 pop dup .fonttempstring /FontResourceDir getsystemparam .genericrfn
1025 {//false .loadfontloop} .internalstopped {//false} if {
1026 //true
1027 } {
1028 dup .nametostring
1029 {//true .loadfontloop} .internalstopped {//false} if
1030 } ifelse
1031 } {
1032 {//true .loadfontloop} .internalstopped {//false} if
1033 } ifelse
1034} bind def
1035
1036/.loadfontloop { % <fontname> <filename> <libflag> .loadfontloop 968/.loadfontloop { % <fontname> <filename> <libflag> .loadfontloop
1037 % <font> true 969 % <font> true
1038 % -or- 970 % -or-
@@ -1102,7 +1034,7 @@ $error /SubstituteFont { } put
1102 } if 1034 } if
1103 1035
1104 % Check to make sure the font was actually loaded. 1036 % Check to make sure the font was actually loaded.
1105 dup 3 index .fontknownget 1037 dup 3 index //.fontknownget exec
1106 { dup /PathLoad 4 index //.putgstringcopy 1038 { dup /PathLoad 4 index //.putgstringcopy
1107 4 1 roll pop pop pop //true exit 1039 4 1 roll pop pop pop //true exit
1108 } executeonly if 1040 } executeonly if
@@ -1113,7 +1045,7 @@ $error /SubstituteFont { } put
1113 exch dup % Stack: origfontname fontdirectory path path 1045 exch dup % Stack: origfontname fontdirectory path path
1114 (r) file .findfontname 1046 (r) file .findfontname
1115 { % Stack: origfontname fontdirectory path filefontname 1047 { % Stack: origfontname fontdirectory path filefontname
1116 2 index 1 index .fontknownget 1048 2 index 1 index //.fontknownget exec
1117 { % Yes. Stack: origfontname fontdirectory path filefontname fontdict 1049 { % Yes. Stack: origfontname fontdirectory path filefontname fontdict
1118 dup 4 -1 roll /PathLoad exch //.putgstringcopy 1050 dup 4 -1 roll /PathLoad exch //.putgstringcopy
1119 % Stack: origfontname fontdirectory filefontname fontdict 1051 % Stack: origfontname fontdirectory filefontname fontdict
@@ -1136,7 +1068,7 @@ $error /SubstituteFont { } put
1136 % Stack: fontdict 1068 % Stack: fontdict
1137 } executeonly 1069 } executeonly
1138 if pop % Stack: origfontname fontdirectory path 1070 if pop % Stack: origfontname fontdirectory path
1139 } 1071 } executeonly
1140 if pop pop % Stack: origfontname 1072 if pop pop % Stack: origfontname
1141 1073
1142 % The font definitely did not load correctly. 1074 % The font definitely did not load correctly.
@@ -1149,7 +1081,88 @@ $error /SubstituteFont { } put
1149 } loop % end of loop 1081 } loop % end of loop
1150 1082
1151 } bind executeonly odef % must be bound and hidden for .putgstringcopy 1083 } bind executeonly odef % must be bound and hidden for .putgstringcopy
1152currentdict /.putgstringcopy .forceundef 1084
1085% Attempt to load a font from a file.
1086/.tryloadfont { % <fontname> .tryloadfont <font> true
1087 % <fontname> .tryloadfont false
1088 dup //.nametostring exec
1089 % Hack: check for the presence of the resource machinery.
1090 /.genericrfn where {
1091 pop
1092 pop dup //.fonttempstring /FontResourceDir getsystemparam .genericrfn
1093 {//false .loadfontloop} .internalstopped {//false} if {
1094 //true
1095 } {
1096 dup //.nametostring exec
1097 {//true .loadfontloop} .internalstopped {//false} if
1098 } ifelse
1099 } {
1100 {//true .loadfontloop} .internalstopped {//false} if
1101 } ifelse
1102} bind def
1103
1104% Try to find a font using only the present contents of Fontmap.
1105/.tryfindfont { % <fontname> .tryfindfont <font> true
1106 % <fontname> .tryfindfont false
1107 //.FontDirectory 1 index //.fontknownget exec
1108 { % Already loaded
1109 exch pop //true
1110 }
1111 {
1112 dup Fontmap exch .knownget
1113 { //true //true }
1114 { % Unknown font name. Look for a file with the
1115 % same name as the requested font.
1116 dup //.tryloadfont exec
1117 { exch pop //true //false }
1118 {
1119 % if we can't load by name check the native font map
1120 dup .nativeFontmap exch .knownget
1121 { //true //true }
1122 { //false //false } ifelse
1123 } ifelse
1124 } ifelse
1125
1126 { % Try each element of the Fontmap in turn.
1127 pop
1128 //false exch % (in case we exhaust the list)
1129 % Stack: fontname false fontmaplist
1130 { exch pop
1131 dup type /nametype eq
1132 { % Font alias
1133 //.checkalias exec
1134 .tryfindfont exit
1135 }
1136 { dup dup type dup /arraytype eq exch /packedarraytype eq or exch xcheck and
1137 { % Font with a procedural definition
1138 exec % The procedure will load the font.
1139 % Check to make sure this really happened.
1140 //.FontDirectory 1 index .knownget
1141 { exch pop //true exit }
1142 if
1143 }
1144 { % Font file name
1145 //true .loadfontloop { //true exit } if
1146 }
1147 ifelse
1148 }
1149 ifelse //false
1150 }
1151 forall
1152 % Stack: font true -or- fontname false
1153 { //true
1154 }
1155 { % None of the Fontmap entries worked.
1156 % Try loading a file with the same name
1157 % as the requested font.
1158 //.tryloadfont exec
1159 }
1160 ifelse
1161 }
1162 if
1163 }
1164 ifelse
1165 } bind def
1153 1166
1154% Define a procedure to load all known fonts. 1167% Define a procedure to load all known fonts.
1155% This isn't likely to be very useful. 1168% This isn't likely to be very useful.
@@ -1191,9 +1204,9 @@ FAKEFONTS { exch } if pop def % don't bind, .current/setglobal get redefined
1191/.loadinitialfonts 1204/.loadinitialfonts
1192 { NOFONTMAP not 1205 { NOFONTMAP not
1193 { /FONTMAP where 1206 { /FONTMAP where
1194 { pop [ FONTMAP .pathlist ] 1207 { pop [ FONTMAP //.pathlist exec]
1195 { dup VMDEBUG findlibfile 1208 { dup VMDEBUG findlibfile
1196 { exch pop .loadFontmap } 1209 { exch pop //.loadFontmap exec }
1197 { /undefinedfilename signalerror } 1210 { /undefinedfilename signalerror }
1198 ifelse 1211 ifelse
1199 } 1212 }
@@ -1207,7 +1220,7 @@ FAKEFONTS { exch } if pop def % don't bind, .current/setglobal get redefined
1207 pop pop 1220 pop pop
1208 defaultfontmap_content { .definefontmap } forall 1221 defaultfontmap_content { .definefontmap } forall
1209 } { 1222 } {
1210 .loadFontmap 1223 //.loadFontmap exec
1211 } ifelse 1224 } ifelse
1212 } { 1225 } {
1213 pop pop 1226 pop pop
@@ -1271,3 +1284,18 @@ FAKEFONTS { exch } if pop def % don't bind, .current/setglobal get redefined
1271 { .makemodifiedfont 1284 { .makemodifiedfont
1272 dup /FontName get exch definefont pop 1285 dup /FontName get exch definefont pop
1273 } bind def 1286 } bind def
1287
1288% Undef these, not needed outside this file
1289[
1290 % /.fonttempstring /.scannextfontdir - are also used in gs_res.ps, so are undefined there
1291 % /.fontnameproperties - is used in pdf_font.ps
1292 % /.scanfontheaders - used in gs_cff.ps, gs_ttf.ps
1293 /.loadfontloop /.tryloadfont /.findfont /.pathlist /.loadFontmap /.lowerstring
1294 /.splitfilename /.scanfontdict /.scanfontbegin
1295 /.scanfontskip /.scan1fontstring
1296 /.scan1fontfirst /.scanfontdir
1297 /.setnativefontmapbuilt /.aliasfont
1298 /.setloadingfont /.substitutefaces /.substituteproperties /.substitutefamilies
1299 /.nametostring /.fontnamestring /.checkalias /.fontknownget /.stdsubstfont
1300 /.putgstringcopy
1301] {systemdict exch .forceundef} forall
diff --git a/Resource/Init/gs_res.ps b/Resource/Init/gs_res.ps
index b7115622c..d1f9f92ce 100644
--- a/Resource/Init/gs_res.ps
+++ b/Resource/Init/gs_res.ps
@@ -961,7 +961,7 @@ userdict /.localcsdefaults //false put
961 dup type /nametype eq { .namestring } if 961 dup type /nametype eq { .namestring } if
962 dup type /stringtype ne { //false exit } if 962 dup type /stringtype ne { //false exit } if
963 % Check the resource directory. 963 % Check the resource directory.
964 dup .fonttempstring /FontResourceDir getsystemparam .genericrfn 964 dup //.fonttempstring /FontResourceDir getsystemparam .genericrfn
965 status { 965 status {
966 pop pop pop pop //true exit 966 pop pop pop pop //true exit
967 } if 967 } if
@@ -969,7 +969,7 @@ userdict /.localcsdefaults //false put
969 % as the font. 969 % as the font.
970 findlibfile { closefile //true exit } if 970 findlibfile { closefile //true exit } if
971 % Scan a FONTPATH directory and try again. 971 % Scan a FONTPATH directory and try again.
972 .scannextfontdir not { //false exit } if 972 //.scannextfontdir exec not { //false exit } if
973 } loop 973 } loop
974} bind def 974} bind def
975 975
@@ -1008,7 +1008,7 @@ currentdict /.fontstatusaux .undef
1008 } ifelse 1008 } ifelse
1009} bind executeonly 1009} bind executeonly
1010/ResourceForAll { 1010/ResourceForAll {
1011 { .scannextfontdir not { exit } if } loop 1011 { //.scannextfontdir exec not { exit } if } loop
1012 /Generic /Category findresource /ResourceForAll get exec 1012 /Generic /Category findresource /ResourceForAll get exec
1013} bind executeonly 1013} bind executeonly
1014/.ResourceFileStatus { 1014/.ResourceFileStatus {
@@ -1171,6 +1171,7 @@ end % level2dict
1171[ 1171[
1172 /.default_resource_dir 1172 /.default_resource_dir
1173 /.resource_dir_name 1173 /.resource_dir_name
1174 /.fonttempstring /.scannextfontdir % from gs_fonts.ps
1174] 1175]
1175{systemdict exch .forceundef} forall 1176{systemdict exch .forceundef} forall
1176 1177