1 % Copyright (C) 1997, 1999 Aladdin Enterprises. All rights reserved.
3 % This software is provided AS-IS with no warranty, either express or
6 % This software is distributed under license and may not be copied,
7 % modified or distributed except as expressly authorized under the terms
8 % of the license contained in the file LICENSE in this distribution.
10 % For more information about licensing, please refer to
11 % http://www.ghostscript.com/licensing/. For information on
12 % commercial licensing, go to http://www.artifex.com/licensing/ or
13 % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14 % San Rafael, CA 94903, U.S.A., +1(415)492-9861.
16 % $Id: gs_dps1.ps,v 1.4 2002/02/21 21:49:28 giles Exp $
17 % Initialization file for most of the Display PostScript functions
18 % that are also included in Level 2.
22 % ------ Virtual memory ------ %
24 /currentshared /.currentglobal load def
25 /scheck /.gcheck load def
26 %****** FOLLOWING IS WRONG ******
27 /shareddict currentdict /globaldict .knownget not { 20 dict } if def
29 % Global and LocalFontDirectory must remain in systemdict
30 % even if we temporarily exit Level 2 mode.
35 /SharedFontDirectory .FontDirectory .gcheck
36 { .currentglobal false .setglobal
37 /LocalFontDirectory .FontDirectory dup maxlength dict copy
38 .forcedef % LocalFontDirectory is local, systemdict is global
39 .setglobal .FontDirectory
41 { /LocalFontDirectory .FontDirectory
42 .forcedef % LocalFontDirectory is local, systemdict is global
50 % setshared must rebind FontDirectory to the appropriate one of
51 % Local or SharedFontDirectory.
53 /.setglobal % <bool> .setglobal -
55 //systemdict /FontDirectory .currentglobal
56 { //SharedFontDirectory }
57 { /LocalFontDirectory .systemvar } % can't embed ref to local VM
58 ifelse .forceput pop % LocalFontDirectory is local, systemdict is global
59 } .bind odef % must bind .forceput and .setglobal
60 % even if NOBIND in effect
61 % Don't just copy (load) the definition of .setglobal:
62 % it gets redefined for LL3.
63 /setshared { /.setglobal .systemvar exec } odef
64 .currentglobal setshared
66 % See below for changes in save and restore.
68 % ------ Fonts ------ %
70 /selectfont % <fontname> <size> selectfont -
72 1 index dup type /arraytype eq { makefont } { scalefont } ifelse
75 % undefinefont has to take local/global VM into account.
76 /undefinefont % <fontname> undefinefont -
77 { .FontDirectory 1 index .undef
79 { % Current mode is global; delete from local directory too.
80 //systemdict /LocalFontDirectory .knownget
84 { % Current mode is local; if there was a shadowed global
85 % definition, copy it into the local directory.
86 //systemdict /SharedFontDirectory .knownget
88 { .FontDirectory 2 index 3 -1 roll put }
96 % If we load a font into global VM within an inner save, the restore
97 % will delete it from FontDirectory but not from SharedFontDirectory.
98 % We have to handle this by making restore copy missing entries from
99 % SharedFontDirectory to FontDirectory. Since this could slow down restore
100 % considerably, we define a new operator .dictcopynew for this purpose.
101 % Furthermore, if FAKEFONTS is in effect, we want global real fonts to
102 % override fake local ones. We handle this by brute force.
103 /restore % <save> restore -
104 { dup //restore % bind even if NOBIND
105 /LocalFontDirectory .systemvar
108 % We want to delete a fake font from the local directory
109 % iff the global directory now has no definition for it,
110 % or a non-fake definition.
112 { % Stack: lfd mark lfd key ... lfd key value
114 { % This is a real local definition; don't do anything.
117 { % This is a fake local definition, check for global.
118 //SharedFontDirectory 1 index .knownget
119 { % A global definition exists, check for fake.
120 length 1 eq { pop } { 1 index } ifelse
122 { % No global definition, delete the local one.
129 pop counttomark 2 idiv { .undef } repeat pop
132 //SharedFontDirectory exch .dictcopynew pop
133 .currentglobal .setglobal % Rebind FontDirectory according to current VM.
137 % ------ Miscellaneous ------ %
139 /undef /.undef load def