File: gs_dps1.ps

package info (click to toggle)
gs 3.33-7
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 7,436 kB
  • ctags: 15,511
  • sloc: ansic: 92,150; asm: 684; sh: 486; makefile: 91
file content (219 lines) | stat: -rw-r--r-- 6,150 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
%    Copyright (C) 1990, 1991, 1993, 1994 Aladdin Enterprises.  All rights reserved.
% 
% This file is part of GNU Ghostscript.
% 
% GNU Ghostscript is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility to
% anyone for the consequences of using it or for whether it serves any
% particular purpose or works at all, unless he says so in writing.  Refer
% to the GNU Ghostscript General Public License for full details.
% 

% Initialization file for analogs of Display PostScript functions
% that are also included in Level 2.
% When this is run, systemdict is still writable,
% but (almost) everything defined here goes into level2dict.

level2dict begin

% ------ Virtual memory ------ %

/currentshared /.currentglobal load def
/scheck /.gcheck load def
%****** FOLLOWING IS WRONG ******
/shareddict currentdict /globaldict .knownget not { 20 dict } if def

% Global and LocalFontDirectory must remain in systemdict
% even if we temporarily exit Level 2 mode.

end				% level2dict
systemdict begin

/SharedFontDirectory FontDirectory .gcheck
 { .currentglobal false .setglobal
   /LocalFontDirectory FontDirectory dup maxlength dict copy def
   .setglobal FontDirectory
 }
 { /LocalFontDirectory FontDirectory def
   50 dict
 }
ifelse def

end				% systemdict
level2dict begin

% setshared must rebind FontDirectory to the appropriate one of
% Local or SharedFontDirectory.

/.setglobal
 { .setglobal
   //systemdict /FontDirectory .currentglobal
    { //SharedFontDirectory }
    { //systemdict /LocalFontDirectory get }	% can't embed ref to local VM
   ifelse .forceput
 } .bind odef		% must bind .forceput and .setglobal
			% even if NOBIND in effect
/setshared /.setglobal load def
.currentglobal setshared

% ------ Fonts ------ %

/selectfont
 { exch findfont exch
   dup type /arraytype eq { makefont } { scalefont } ifelse
   setfont
 } odef
% Undefinefont has to take local/global VM into account.
/undefinefont
 { FontDirectory 1 index undef
   .currentglobal
    {		% Current mode is global; delete from local directory too.
      systemdict /LocalFontDirectory .knownget
       { exch undef }
       { pop }
      ifelse
    }
    {		% Current mode is local; if there was a shadowed global
		% definition, copy it into the local directory.
      systemdict /SharedFontDirectory .knownget
       { 1 index .knownget
	  { FontDirectory 3 1 roll put }
	  { pop }
	 ifelse
       }
      if
    }
   ifelse
 } odef

% If we load a font into global VM within an inner save, the restore
% will delete it from FontDirectory but not from SharedFontDirectory.
% We have to handle this by making restore copy missing entries from
% SharedFontDirectory to FontDirectory.  Since this could slow down restore
% considerably, we define a new operator .dictcopynew for this purpose.
/restore
 { //restore
   //SharedFontDirectory //systemdict /LocalFontDirectory get .dictcopynew pop
 } bind odef

% ------ Halftones ------ %

/.makestackdict
	{ { counttomark -1 roll } forall .dicttomark
	} bind def
/currenthalftone
	{ mark .currenthalftone
	   { { exch pop }		% halftone
	     { /HalftoneType 1		% screen
		{ /Frequency /Angle /SpotFunction }
	       .makestackdict
	     }
	     { /HalftoneType 2		% colorscreen
		{ /RedFrequency /RedAngle /RedSpotFunction
		  /GreenFrequency /GreenAngle /GreenSpotFunction
		  /BlueFrequency /BlueAngle /BlueSpotFunction
		  /GrayFrequency /GrayAngle /GraySpotFunction
		}
	       .makestackdict
	     }
	   }
	  exch get exec
	} odef
% Define sethalftone so it converts all other types to type 5.
/.sethalftoneRGBV	% <dict> <type> <keys> <keysRGBV>
	{ 4 -1 roll exch { 1 index exch get exch } forall 15 1 roll
	  14 -2 roll mark 15 1 roll { /Gray /Blue /Green /Red }
	   {		% stack: v0 v1 v2 type keys comp
	     mark
	     2 index 0 get 8 -1 roll
	     4 index 1 get 9 -1 roll
	     6 index 2 get 10 -1 roll
			% stack: type keys comp mark k0 v0 k1 v1 k2 v2
	     /HalftoneType 10 index .dicttomark
	     counttomark 2 roll
	   }
	  forall pop pop
	  /Default 1 index .dicttomark .sethalftone5
	} bind def
/sethalftone
	{ dup /HalftoneType get 1 sub
	   {  { mark /Default 2 index .dicttomark .sethalftone5 }
	      { 1 { /Frequency /Angle /SpotFunction }
		{ /RedFrequency /RedAngle /RedSpotFunction
		  /GreenFrequency /GreenAngle /GreenSpotFunction
		  /BlueFrequency /BlueAngle /BlueSpotFunction
		  /GrayFrequency /GrayAngle /GraySpotFunction
		} .sethalftoneRGBV
	      }
	      { mark /Default 2 index .dicttomark .sethalftone5 }
	      { 3 { /Width /Height /Thresholds }
		{ /RedWidth /RedHeight /RedThresholds
		  /GreenWidth /GreenHeight /GreenThresholds
		  /BlueWidth /BlueHeight /BlueThresholds
		  /GrayWidth /GrayHeight /GrayThresholds
		} .sethalftoneRGBV
	      }
	      { dup .sethalftone5 }
	   } exch get exec
	} odef
% Redefine setscreen and setcolorscreen to recognize halftone dictionaries.
/setscreen
	{ dup type /dicttype eq
	   { sethalftone pop pop }
	   { //setscreen }
	  ifelse
	} odef
/setcolorscreen
	{ dup type /dicttype eq
	   { sethalftone 11 { pop } repeat }
	   { //setcolorscreen }
	  ifelse
	} odef

% ------ User objects ------ %

/.localarray where
 { pop }
 { /.localarray
	{ currentglobal false setglobal
	  exch array exch setglobal
	} bind def
 }
ifelse
/defineuserobject
	{ userdict /.UserObjects known
	   { 1 index userdict /.UserObjects get length ge
	      { 1 index 1 add .localarray userdict /.UserObjects get
		1 index copy pop
		userdict /.UserObjects 3 -1 roll put
	      }
	     if
	   }
	   { userdict /.UserObjects 3 index 1 add .localarray put
	   }
	  ifelse
	  userdict /.UserObjects get 3 1 roll put
	} odef
/execuserobject
	{ userdict /.UserObjects get exch get exec
	} odef
/undefineuserobject
	{ userdict /.UserObjects get exch null put
	} odef

% ------ User paths ------ %

/upath
	{ [ exch {/ucache cvx} if pathbbox /setbbox cvx
	  {/moveto cvx} {/lineto cvx} {/curveto cvx} {/closepath cvx}
	  pathforall ] cvx
	} odef

% Dummy definitions for cache control operators

/ucachestatus
	{ mark 0 0 0 0 0 } odef
/setucacheparams
	{ cleartomark } odef

end				% level2dict