Debian Codegraph @

Resource/Init/gs_dps1.ps

raw
1 % Copyright (C) 2001-2023 Artifex Software, Inc.
2 % All Rights Reserved.
3 %
4 % This software is provided AS-IS with no warranty, either express or
5 % implied.
6 %
7 % This software is distributed under license and may not be copied,
8 % modified or distributed except as expressly authorized under the terms
9 % of the license contained in the file LICENSE in this distribution.
10 %
11 % Refer to licensing information at http://www.artifex.com or contact
12 % Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
13 % CA 94129, USA, for further information.
14 %
15
16 % Initialization file for most of the Display PostScript functions
17 % that are also included in Level 2.
18
19 level2dict begin
20
21 % ------ Virtual memory ------ %
22
23 /currentshared /.currentglobal load def
24 /scheck {.gcheck} .internalbind odef
25 %****** FOLLOWING IS WRONG ******
26 /shareddict currentdict /globaldict .knownget not { 20 dict } if def
27
28 % Global and LocalFontDirectory must remain in systemdict
29 % even if we temporarily exit Level 2 mode.
30
31 end % level2dict
32 systemdict begin
33
34 /SharedFontDirectory .FontDirectory .gcheck
35 { .currentglobal //false .setglobal
36 currentdict
37 /LocalFontDirectory .FontDirectory dup maxlength dict copy
38 .forceput % LocalFontDirectory is local, systemdict is global
39 .setglobal .FontDirectory
40 } executeonly
41 {
42 currentdict
43 /LocalFontDirectory .FontDirectory
44 .forceput % LocalFontDirectory is local, systemdict is global
45 50 dict
46 }executeonly
47 ifelse def
48
49 end % systemdict
50 level2dict begin
51
52 % setshared must rebind FontDirectory to the appropriate one of
53 % Local or SharedFontDirectory.
54
55 /.setglobal % <bool> .setglobal -
56 { dup .setglobal
57 //systemdict /FontDirectory .currentglobal
58 { //SharedFontDirectory }
59 { /LocalFontDirectory .systemvar } % can't embed ref to local VM
60 ifelse .forceput pop % LocalFontDirectory is local, systemdict is global
61 } .forcebind odef
62 % Don't just copy (load) the definition of .setglobal:
63 % it gets redefined for LL3.
64 /setshared { /.setglobal .systemvar exec } odef
65 .currentglobal setshared
66
67 % See below for changes in save and restore.
68
69 % ------ Fonts ------ %
70
71 /selectfont % <fontname> <size> selectfont -
72 {
73 {
74 1 .argindex findfont
75 1 index dup type /arraytype eq { makefont } { scalefont } ifelse
76 setfont pop pop
77 } stopped { /selectfont .systemvar $error /errorname get signalerror } if
78 } odef
79 % undefinefont has to take local/global VM into account.
80 /undefinefont % <fontname> undefinefont -
81 { //.FontDirectory 1 .argindex .forceundef % FontDirectory is readonly
82 .currentglobal
83 { % Current mode is global; delete from local directory too.
84 //systemdict /LocalFontDirectory .knownget
85 { 1 index .forceundef } executeonly % LocalFontDirectory is readonly
86 if
87 }
88 { % Current mode is local; if there was a shadowed global
89 % definition, copy it into the local directory.
90 //systemdict /SharedFontDirectory .knownget
91 { 1 index .knownget
92 { //.FontDirectory 2 index 3 -1 roll .forceput } % readonly
93 if
94 }
95 if
96 }
97 ifelse pop
98 } .forcebind odef
99
100 % If we load a font into global VM within an inner save, the restore
101 % will delete it from FontDirectory but not from SharedFontDirectory.
102 % We have to handle this by making restore copy missing entries from
103 % SharedFontDirectory to FontDirectory. Since this could slow down restore
104 % considerably, we define a new operator .forcecopynew for this purpose.
105 % Furthermore, if FAKEFONTS is in effect, we want global real fonts to
106 % override fake local ones. We handle this by brute force.
107 /restore % <save> restore -
108 { dup //restore
109 /LocalFontDirectory .systemvar
110 FAKEFONTS
111 { mark
112 % We want to delete a fake font from the local directory
113 % iff the global directory now has no definition for it,
114 % or a non-fake definition.
115 1 index dup
116 { % Stack: lfd mark lfd key ... lfd key value
117 length 1 gt
118 { % This is a real local definition; don't do anything.
119 pop
120 }
121 { % This is a fake local definition, check for global.
122 //SharedFontDirectory 1 index .knownget
123 { % A global definition exists, check for fake.
124 length 1 eq { pop } { 1 index } ifelse
125 }
126 { % No global definition, delete the local one.
127 1 index
128 }
129 ifelse
130 }
131 ifelse
132 } forall
133 pop counttomark 2 idiv { .forceundef } executeonly repeat pop % readonly
134 }
135 if
136 //SharedFontDirectory exch .forcecopynew pop
137 .currentglobal .setglobal % Rebind FontDirectory according to current VM.
138 pop
139 } .forcebind odef
140
141 end % level2dict