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 8954 2008-08-08 04:22:38Z ray $
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 .argindex findfont
73
1 index dup type /arraytype eq { makefont } { scalefont } ifelse
75
} stopped { /selectfont .systemvar $error /errorname get signalerror } if
77
% undefinefont has to take local/global VM into account.
78
/undefinefont % <fontname> undefinefont -
79
{ .FontDirectory 1 .argindex .forceundef % FontDirectory is readonly
81
{ % Current mode is global; delete from local directory too.
82
//systemdict /LocalFontDirectory .knownget
83
{ 1 index .forceundef } % LocalFontDirectory is readonly
86
{ % Current mode is local; if there was a shadowed global
87
% definition, copy it into the local directory.
88
//systemdict /SharedFontDirectory .knownget
90
{ .FontDirectory 2 index 3 -1 roll { put } //superexec } % readonly
98
% If we load a font into global VM within an inner save, the restore
99
% will delete it from FontDirectory but not from SharedFontDirectory.
100
% We have to handle this by making restore copy missing entries from
101
% SharedFontDirectory to FontDirectory. Since this could slow down restore
102
% considerably, we define a new operator .forcecopynew for this purpose.
103
% Furthermore, if FAKEFONTS is in effect, we want global real fonts to
104
% override fake local ones. We handle this by brute force.
105
/restore % <save> restore -
106
{ dup //restore % bind even if NOBIND
107
/LocalFontDirectory .systemvar
110
% We want to delete a fake font from the local directory
111
% iff the global directory now has no definition for it,
112
% or a non-fake definition.
114
{ % Stack: lfd mark lfd key ... lfd key value
116
{ % This is a real local definition; don't do anything.
119
{ % This is a fake local definition, check for global.
120
//SharedFontDirectory 1 index .knownget
121
{ % A global definition exists, check for fake.
122
length 1 eq { pop } { 1 index } ifelse
124
{ % No global definition, delete the local one.
131
pop counttomark 2 idiv { .forceundef } repeat pop % readonly
134
//SharedFontDirectory exch .forcecopynew pop
135
.currentglobal .setglobal % Rebind FontDirectory according to current VM.