Debian Codegraph @

freehep-graphicsio-ps/src/main/resources/org/freehep/graphicsio/ps/PSProlog.txt

raw
1 100 dict dup begin
2
3 %
4 % File: org/freehep/graphicsio.ps/PSProlog.txt
5 % Author: Charles Loomis
6 %
7
8 % Redefinitions which save some space in the output file. These are also
9 % the same as the PDF operators.
10 /q {gsave} def
11 /Q {grestore} def
12
13 /n {newpath} def
14 /m {moveto} def
15 /l {lineto} def
16 /c {curveto} def
17 /h {closepath} def
18
19 /re {4 -2 roll moveto
20 dup 0 exch rlineto exch 0 rlineto
21 neg 0 exch rlineto closepath} def
22
23 /f {fill} def
24 /f* {eofill} def
25 /F {gsave vg&FC fill grestore} def
26 /F* {gsave vg&FC eofill grestore} def
27
28 /s {closepath stroke} def
29 /S {stroke} def
30
31 /b {closepath gsave vg&FC fill grestore
32 gsave stroke grestore newpath} def
33 /B {gsave vg&FC fill grestore gsave stroke grestore newpath} def
34 /b* {closepath gsave vg&FC eofill grestore
35 gsave stroke grestore newpath} def
36 /B* {gsave vg&FC eofill grestore gsave stroke grestore newpath} def
37
38 /g {1 array astore /vg&fcolor exch def} def
39 /G {setgray} def
40 /k {4 array astore /vg&fcolor exch def} def
41 /K {setcmykcolor} def
42 /rg {3 array astore /vg&fcolor exch def} def
43 /RG {setrgbcolor} def
44
45 % Initialize the fill color.
46 0 0 0 rg
47
48 /vg&FC {mark vg&fcolor aload pop
49 counttomark 1 eq {G} if
50 counttomark 3 eq {RG} if
51 counttomark 4 eq {K} if
52 cleartomark } def
53
54 /vg&DFC {/vg&fcolor exch def} def
55
56 /vg&C {mark exch aload pop
57 counttomark 1 eq {G} if
58 counttomark 3 eq {RG} if
59 counttomark 4 eq {K} if
60 cleartomark } def
61
62 /w {setlinewidth} def
63 /j {setlinejoin} def
64 /J {setlinecap} def
65 /M {setmiterlimit} def
66 /d {setdash} def
67 /i {setflat} def
68
69 /W {clip} def
70 /W* {eoclip} def
71
72 % Setup the default graphics state.
73 % (black; 1 pt. linewidth; miter join; butt-ends; solid)
74 /defaultGraphicsState {0 g 1 w 0 j 0 J [] 0 d} def
75
76 % Emulation of the rectangle operators for PostScript implementations
77 % which do not implement all Level 2 features. This is an INCOMPLETE
78 % emulation; only the "x y width height rect..." form is emulated.
79 /*rf {gsave newpath re fill grestore} def
80 /*rs {gsave newpath re stroke grestore} def
81 /*rc {newpath re clip} def
82 /rf /rectfill where {pop /rectfill}{/*rf} ifelse load def
83 /rs /rectstroke where {pop /rectstroke}{/*rs} ifelse load def
84 /rc /rectclip where {pop /rectclip}{/*rc} ifelse load def
85
86 % Emulation of the selectfont operator. This includes a 20% increase in
87 % the fontsize which is necessary to get sizes similar to the Java fonts.
88 /*sf {exch findfont exch
89 dup type /arraytype eq {makefont}{scalefont} ifelse setfont} bind def
90 /sf /selectfont where {pop {1.2 mul selectfont}}{{1.2 mul *sf}} ifelse def
91
92 % Special version of stroke which allows the dash pattern to continue
93 % across path segments. (This may be needed for PostScript although
94 % modern printers seem to do this correctly.)
95 /vg&stroke {
96 currentdash pop length 0 eq
97 {stroke}
98 {
99 currentdash /vg&doffset exch def pop
100 flattenpath
101 {m vg&resetdash}
102 {2 copy
103 currentpoint
104 3 -1 roll sub dup mul
105 3 1 roll sub dup mul
106 add sqrt
107 3 1 roll l
108 currentdash 3 -1 roll add setdash}
109 {}
110 {h vg&resetdash}
111 pathforall
112 stroke
113 vg&resetdash
114 } ifelse
115 } def
116 /vg&resetdash {currentdash pop vg&doffset setdash} def
117
118 % Initialize variables for safety.
119 /delta 0 def
120 /xv 0 def /yv 0 def /width 0 def /height 0 def
121
122 % Initialize to portrait INTERNATIONAL (Letter-height, A4-width) page.
123 /pw 595 def /ph 791 def /po true def /ftp false def
124
125 % Initialize margins to 20 points.
126 /ml 20 def /mr 20 def /mt 20 def /mb 20 def
127
128 % Temporary matrices.
129 /smatrix 0 def /nmatrix 0 def
130
131 % set page size (usage: <page width><page height> setpagesize)
132 /setpagesize {/ph exch def /pw exch def} def
133
134 % set page orientation (usage: portrait or landscape)
135 /portrait {/po true def} def
136 /landscape {/po false def} def
137
138 % force natural size for image (usage: naturalsize)
139 /naturalsize {/ftp false def} def
140
141 % resize image to fill page (usage: fittopage)
142 /fittopage {/ftp true def} def
143
144 % set margins of the page (usage: <left><bottom><top><right> setmargins)
145 /setmargins {/mr exch def /mt exch def /mb exch def /ml exch def} def
146
147 % set the graphic's size (usage: <width><height> setsize)
148 /setsize {/gh exch def /gw exch def} def
149
150 % set the graphic's origin (usage: <x0><y0> setorigin)
151 /setorigin {/gy exch def /gx exch def} def
152
153 % calculate image center
154 /imagecenter {pw ml sub mr sub 2 div ml add
155 ph mt sub mb sub 2 div mb add} def
156
157 % calculate the necessary scaling
158 /imagescale {po {gw}{gh} ifelse pw ml sub mr sub div
159 po {gh}{gw} ifelse ph mt sub mb sub div
160 2 copy lt {exch} if pop
161 ftp not {1 2 copy lt {exch} if pop} if
162 1 exch div /sfactor exch def
163 /gw gw sfactor mul def /gh gh sfactor mul def} def
164
165 % calculate image origin
166 /imageorigin {pw ml sub mr sub 2 div ml add
167 po {gw}{gh} ifelse 2 div sub
168 ph mt sub mb sub 2 div mb add
169 po {gh}{gw} ifelse 2 div po {add}{sub} ifelse} def
170
171 % calculate the clipping origin
172 /cliporigin {pw ml sub mr sub 2 div ml add
173 po {gw}{gh} ifelse 2 div sub floor
174 ph mt sub mb sub 2 div mb add
175 po {gh}{gw} ifelse 2 div sub floor} def
176
177 % Set the clipping region to the bounding box.
178 /cliptobounds {cliporigin po {gw}{gh} ifelse 1 add
179 po {gh}{gw} ifelse 1 add rc} def
180
181 % set the base transformation matrix (usage: setbasematrix)
182 /setbasematrix {imageorigin translate
183 po {0}{90} ifelse rotate
184 sfactor sfactor neg scale
185 /defaultmatrix matrix currentmatrix def} def
186
187 % The lower-right bias in drawing 1 pt. wide lines.
188 /bias {q 0.5 0.5 translate} def
189 /unbias {Q} def
190
191 % Define the composite fonts used to print Unicode strings.
192 % Undefine particular values in an encoding array.
193 /vg&undef { {exch dup 3 -1 roll /.notdef put} forall } def
194 /vg&redef { {3 -1 roll dup 4 2 roll put} forall } def
195
196 % usage: key encoding basefontname vg&newbasefont font
197 /vg&newbasefont {
198 findfont dup length dict copy
199 begin
200 currentdict /FID undef
201 /Encoding exch def
202 dup /FontName exch def
203 currentdict
204 end
205 definefont
206 } def
207
208 % usage: key encoding basefontname vg&newskewedbasefont font
209 /vg&newskewedbasefont {
210 findfont dup length dict copy
211 begin
212 currentdict /FID undef
213 /Encoding exch def
214 dup /FontName exch def
215 exch FontMatrix exch matrix concatmatrix /FontMatrix exch def
216 currentdict
217 end
218 definefont
219 } def
220
221 % usage: basekey suffix vg&nconcat name
222 /vg&nconcat {
223 2 {dup length string cvs exch} repeat
224 dup length 3 -1 roll dup length 3 -1 roll add string
225 dup 0 4 -1 roll dup length 5 1 roll putinterval
226 dup 4 -2 roll exch putinterval cvn
227 } def
228
229 %usage: fontname vg&skewmatrix matrix
230 /vg&skewmatrix {
231 findfont dup /FontInfo known
232 {
233 /FontInfo get dup /ItalicAngle known
234 {
235 [ 1 0 4 -1 roll /ItalicAngle get neg dup sin exch cos div 1 0 0 ]
236 }
237 {pop matrix} ifelse
238 }
239 {pop matrix} ifelse
240 } def
241
242 % usage: newfontname basefontname vg&newcompositefont --
243 /vg&newcompositefont {
244 /vg&fstyle exch def
245 /vg&bfont exch def
246 /vg&fname exch def
247 <<
248 /FontStyleBits vg&fstyle
249 /FontType 0
250 /FontMatrix matrix
251 /FontName vg&fname
252 /FMapType 2
253 /Encoding [ 0 1 255 {pop 6} for ]
254 dup 16#00 0 put % Latin
255 dup 16#03 1 put % Greek
256 dup 16#20 2 put % Punctuation
257 dup 16#21 3 put % Arrows
258 dup 16#22 4 put % MathOps
259 dup 16#27 5 put % Dingbats
260
261 /FDepVector [
262 vg&bfont /-UC-Latin vg&nconcat UCLatinEncoding
263 vg&bfont vg&newbasefont
264
265 vg&bfont vg&skewmatrix
266 vg&bfont /-UC-Greek vg&nconcat UCGreekEncoding
267 /Symbol vg&newskewedbasefont
268
269 vg&bfont /-UC-Punctuation vg&nconcat UCPunctuationEncoding
270 vg&bfont vg&newbasefont
271
272 /Arrows-UC findfont
273 /MathOps-UC findfont
274 /Dingbats-UC findfont
275 /Undefined-UC findfont ]
276 >>
277 vg&fname exch definefont pop
278 } def
279
280 % Null encoding vector (all elements set to .notdef)
281 /NullEncoding [ 256 {/.notdef} repeat ] def
282
283 % Unicode Latin encoding (unicode codes \u0000-\u00ff)
284 /UCLatinEncoding
285 ISOLatin1Encoding dup length array copy
286 dup 16#60 /grave put
287 [ 16#90 16#91 16#92 16#93 16#94 16#95 16#96
288 16#97 16#98 16#9a 16#9b 16#9d 16#9e 16#9f
289 ] vg&undef
290 def
291
292 % Unicode Greek encoding (unicode codes \u0370-\u03ff)
293 /UCGreekEncoding
294 NullEncoding dup length array copy
295 << 16#91 /Alpha 16#92 /Beta 16#93 /Gamma 16#94 /Delta
296 16#95 /Epsilon 16#96 /Zeta 16#97 /Eta 16#98 /Theta
297 16#99 /Iota 16#9a /Kappa 16#9b /Lambda 16#9c /Mu
298 16#9d /Nu 16#9e /Xi 16#9f /Omicron 16#a0 /Pi
299 16#a1 /Rho 16#a3 /Sigma 16#a4 /Tau 16#a5 /Upsilon
300 16#a6 /Phi 16#a7 /Chi 16#a8 /Psi 16#a9 /Omega
301 16#b1 /alpha 16#b2 /beta 16#b3 /gamma 16#b4 /delta
302 16#b5 /epsilon 16#b6 /zeta 16#b7 /eta 16#b8 /theta
303 16#b9 /iota 16#ba /kappa 16#bb /lambda 16#bc /mu
304 16#bd /nu 16#be /xi 16#bf /omicron 16#c0 /pi
305 16#c1 /rho 16#c2 /sigma1 16#c3 /sigma 16#c4 /tau
306 16#c5 /upsilon 16#c6 /phi1 16#c7 /chi 16#c8 /psi
307 16#c9 /omega 16#7e /semicolon 16#87 /dotmath 16#d1 /theta1
308 16#d2 /Upsilon1 16#d5 /phi 16#d6 /omega1
309 >> vg&redef
310 def
311
312 % Unicode punctuation encoding (unicode codes \u2000-\u206f)
313 /UCPunctuationEncoding
314 NullEncoding dup length array copy
315 << 16#10 /hyphen 16#11 /hyphen 16#12 /endash
316 16#13 /emdash 16#18 /quoteleft 16#19 /quoteright
317 16#1a /quotesinglbase 16#1b /quotesingle 16#1c /quotedblleft
318 16#1d /quotedblright 16#1e /quotedblbase 16#1f /quotedbl
319 16#20 /dagger 16#21 /daggerdbl 16#22 /bullet
320 16#24 /period 16#26 /ellipsis 16#27 /periodcentered
321 16#30 /perthousand 16#44 /fraction
322 16#70 /zerosuperior 16#74 /foursuperior 16#75 /fivesuperior
323 16#76 /sixsuperior 16#77 /sevensuperior 16#78 /eightsuperior
324 16#79 /ninesuperior 16#7b /hyphensuperior 16#7d /parenleftsuperior
325 16#7e /parenrightsuperior
326 16#80 /zeroinferior 16#84 /fourinferior 16#85 /fiveinferior
327 16#81 /oneinferior 16#82 /twoinferior 16#83 /threeinferior
328 16#86 /sixinferior 16#87 /seveninferior 16#88 /eightinferior
329 16#89 /nineinferior 16#8b /hypheninferior 16#8d /parenleftinferior
330 16#8e /parenrightinferior
331 >> vg&redef
332 def
333
334 % Unicode mathematical operators encoding (unicode codes \u2200-\u22ff)
335 /UCMathOpsEncoding
336 NullEncoding dup length array copy
337 << 16#00 /universal 16#02 /partialdiff 16#03 /existential
338 16#05 /emptyset 16#06 /Delta 16#07 /gradient
339 16#08 /element 16#09 /notelement 16#0b /suchthat
340 16#0f /product 16#11 /summation 16#12 /minus
341 16#15 /fraction 16#17 /asteriskmath 16#19 /bullet
342 16#1a /radical 16#1d /proportional 16#1e /infinity
343 16#20 /angle 16#23 /bar 16#27 /logicaland
344 16#28 /logicalor 16#29 /intersection 16#2a /union
345 16#2b /integral 16#34 /therefore 16#36 /colon
346 16#3c /similar 16#45 /congruent 16#48 /approxequal
347 16#60 /notequal 16#61 /equivalence 16#64 /lessequal
348 16#65 /greaterequal 16#82 /propersubset 16#83 /propersuperset
349 16#86 /reflexsubset 16#87 /reflexsuperset 16#95 /circleplus
350 16#97 /circlemultiply 16#a5 /perpendicular 16#03 /existential
351 16#c0 /logicaland 16#c1 /logicalor 16#c2 /intersection
352 16#c3 /union 16#c4 /diamond 16#c5 /dotmath
353 >> vg&redef
354 def
355
356 % Unicode arrows encoding (unicode codes \u2190-\u21ff)
357 % Also includes those "Letterlike" unicode characters
358 % which are available in the symbol font. (unicode codes \u2100-\u214f)
359 /UCArrowsEncoding
360 NullEncoding dup length array copy
361 << 16#11 /Ifraktur 16#1c /Rfraktur 16#22 /trademarkserif
362 16#35 /aleph
363 16#90 /arrowleft 16#91 /arrowup 16#92 /arrowright
364 16#93 /arrowdown 16#94 /arrowboth 16#d0 /arrowdblleft
365 16#d1 /arrowdblup 16#d2 /arrowdblright 16#d3 /arrowdbldown
366 16#d4 /arrowdblboth
367 >> vg&redef
368 def
369
370 /ZapfDingbats findfont /Encoding get
371 dup length array copy /UCDingbatsEncoding exch def
372 16#20 1 16#7f {
373 dup 16#20 sub exch
374 UCDingbatsEncoding exch get
375 UCDingbatsEncoding 3 1 roll put
376 } for
377 16#a0 1 16#ff {
378 dup 16#40 sub exch
379 UCDingbatsEncoding exch get
380 UCDingbatsEncoding 3 1 roll put
381 } for
382 UCDingbatsEncoding [ 16#c0 1 16#ff {} for ] vg&undef
383 [ 16#00 16#05 16#0a 16#0b 16#28 16#4c 16#4e 16#53 16#54 16#55 16#57 16#5f
384 16#60 16#68 16#69 16#6a 16#6b 16#6c 16#6d 16#6e 16#6f 16#70 16#71 16#72
385 16#73 16#74 16#75 16#95 16#96 16#97 16#b0 16#bf
386 ] vg&undef pop
387
388 % Define the base fonts which don't change.
389 /Undefined-UC NullEncoding /Helvetica vg&newbasefont pop
390 /MathOps-UC UCMathOpsEncoding /Symbol vg&newbasefont pop
391 /Arrows-UC UCArrowsEncoding /Symbol vg&newbasefont pop
392 /Dingbats-UC UCDingbatsEncoding /ZapfDingbats vg&newbasefont pop
393
394 % Make the SansSerif composite fonts.
395 /SansSerif /Helvetica 16#00 vg&newcompositefont
396 /SansSerif-Bold /Helvetica-Bold 16#01 vg&newcompositefont
397 /SansSerif-Italic /Helvetica-Oblique 16#02 vg&newcompositefont
398 /SansSerif-BoldItalic /Helvetica-BoldOblique 16#03 vg&newcompositefont
399
400 % Make the Serif composite fonts.
401 /Serif /Times-Roman 16#00 vg&newcompositefont
402 /Serif-Bold /Times-Bold 16#01 vg&newcompositefont
403 /Serif-Italic /Times-Italic 16#02 vg&newcompositefont
404 /Serif-BoldItalic /Times-BoldItalic 16#03 vg&newcompositefont
405
406 % Make the Monospaced composite fonts.
407 /Monospaced /Courier 16#00 vg&newcompositefont
408 /Monospaced-Bold /Courier-Bold 16#01 vg&newcompositefont
409 /Monospaced-Italic /Courier-Oblique 16#02 vg&newcompositefont
410 /Monospaced-BoldItalic /Courier-BoldOblique 16#03 vg&newcompositefont
411
412 % Make the Dialog composite fonts.
413 /Dialog /Helvetica 16#00 vg&newcompositefont
414 /Dialog-Bold /Helvetica-Bold 16#01 vg&newcompositefont
415 /Dialog-Italic /Helvetica-Oblique 16#02 vg&newcompositefont
416 /Dialog-BoldItalic /Helvetica-BoldOblique 16#03 vg&newcompositefont
417
418 % Make the DialogInput composite fonts.
419 /DialogInput /Courier 16#00 vg&newcompositefont
420 /DialogInput-Bold /Courier-Bold 16#01 vg&newcompositefont
421 /DialogInput-Italic /Courier-Oblique 16#02 vg&newcompositefont
422 /DialogInput-BoldItalic /Courier-BoldOblique 16#03 vg&newcompositefont
423
424 % Make the Typewriter composite fonts (JDK 1.1 only).
425 /Typewriter /Courier 16#00 vg&newcompositefont
426 /Typewriter-Bold /Courier-Bold 16#01 vg&newcompositefont
427 /Typewriter-Italic /Courier-Oblique 16#02 vg&newcompositefont
428 /Typewriter-BoldItalic /Courier-BoldOblique 16#03 vg&newcompositefont
429
430
431 /cfontH {
432 dup /fontsize exch def /SansSerif exch sf
433 /vg&fontstyles [{cfontH} {cfontHB} {cfontHI} {cfontHBI}] def
434 } def
435 /cfontHB {
436 dup /fontsize exch def /SansSerif-Bold exch sf
437 /vg&fontstyles [{cfontH} {cfontHB} {cfontHI} {cfontHBI}] def
438 } def
439 /cfontHI {
440 dup /fontsize exch def /SansSerif-Italic exch sf
441 /vg&fontstyles [{cfontH} {cfontHB} {cfontHI} {cfontHBI}] def
442 } def
443 /cfontHBI {
444 dup /fontsize exch def /SansSerif-BoldItalic exch sf
445 /vg&fontstyles [{cfontH} {cfontHB} {cfontHI} {cfontHBI}] def
446 } def
447
448 /cfontT {
449 dup /fontsize exch def /Serif exch sf
450 /vg&fontstyles [{cfontT} {cfontTB} {cfontTI} {cfontTBI}] def
451 } def
452 /cfontTB {
453 dup /fontsize exch def /Serif-Bold exch sf
454 /vg&fontstyles [{cfontT} {cfontTB} {cfontTI} {cfontTBI}] def
455 } def
456 /cfontTI {
457 dup /fontsize exch def /Serif-Italic exch sf
458 /vg&fontstyles [{cfontT} {cfontTB} {cfontTI} {cfontTBI}] def
459 } def
460 /cfontTBI {
461 dup /fontsize exch def /Serif-BoldItalic exch sf
462 /vg&fontstyles [{cfontT} {cfontTB} {cfontTI} {cfontTBI}] def
463 } def
464
465 /cfontC {
466 dup /fontsize exch def /Typewriter exch sf
467 /vg&fontstyles [{cfontC} {cfontCB} {cfontCI} {cfontCBI}] def
468 } def
469 /cfontCB {
470 dup /fontsize exch def /Typewriter-Bold exch sf
471 /vg&fontstyles [{cfontC} {cfontCB} {cfontCI} {cfontCBI}] def
472 } def
473 /cfontCI {
474 dup /fontsize exch def /Typewriter-Italic exch sf
475 /vg&fontstyles [{cfontC} {cfontCB} {cfontCI} {cfontCBI}] def
476 } def
477 /cfontCBI {
478 dup /fontsize exch def /Typewriter-BoldItalic exch sf
479 /vg&fontstyles [{cfontC} {cfontCB} {cfontCI} {cfontCBI}] def
480 } def
481
482 % Darken or lighten the current color.
483 /darken {0.7 exch exp 3 copy
484 q 4 -1 roll vg&C
485 currentrgbcolor 3 {4 -2 roll mul} repeat
486 3 array astore Q} def
487
488 /displayColorMap
489 << /Cr [1.00 0.00 0.00] /Cg [0.00 1.00 0.00]
490 /Cb [0.00 0.00 1.00] /Cc [1.00 0.00 0.00 0.00]
491 /Cm [0.00 1.00 0.00 0.00] /Cy [0.00 0.00 1.00 0.00]
492 /Co [1.00 0.78 0.00] /Cp [1.00 0.67 0.67]
493 /Cw [1 ] /Cgrl [0.75]
494 /Cgr [0.50] /Cgrd [0.25]
495 /Ck [0 ]
496 /CGr [1.00 0.00 0.00] /CGg [0.00 1.00 0.00]
497 /CGb [0.00 0.00 1.00] /CGc [1.00 0.00 0.00 0.00]
498 /CGm [0.00 1.00 0.00 0.00] /CGy [0.00 0.00 1.00 0.00]
499 /CGo [1.00 0.78 0.00] /CGp [1.00 0.67 0.67]
500 /CGw [1 ] /CGgrl [0.75]
501 /CGgr [0.50] /CGgrd [0.25]
502 /CGk [0 ]
503 /CIr [1.00 0.00 0.00] /CIg [0.00 1.00 0.00]
504 /CIb [0.00 0.00 1.00] /CIc [1.00 0.00 0.00 0.00]
505 /CIm [0.00 1.00 0.00 0.00] /CIy [0.00 0.00 1.00 0.00]
506 /CIo [1.00 0.78 0.00] /CIp [1.00 0.67 0.67]
507 /CIw [1 ] /CIgrl [0.75]
508 /CIgr [0.50] /CIgrd [0.25]
509 /CIk [0 ]
510 >> def
511
512 /printColorMap
513 << /Cr [1.00 0.33 0.33] /Cg [0.33 1.00 0.33]
514 /Cb [0.33 0.33 1.00] /Cc [1.00 0.00 0.00 0.00]
515 /Cm [0.00 1.00 0.00 0.00] /Cy [0.00 0.00 1.00 0.00]
516 /Co [1.00 0.78 0.00] /Cp [1.00 0.67 0.67]
517 /Cw [1 ] /Cgrl [0.75]
518 /Cgr [0.50] /Cgrd [0.25]
519 /Ck [0 ]
520 /CGr [1.00 0.33 0.33] /CGg [0.33 1.00 0.33]
521 /CGb [0.33 0.33 1.00] /CGc [1.00 0.00 0.00 0.00]
522 /CGm [0.00 1.00 0.00 0.00] /CGy [0.00 0.00 1.00 0.00]
523 /CGo [1.00 0.78 0.00] /CGp [1.00 0.67 0.67]
524 /CGw [1 ] /CGgrl [0.75]
525 /CGgr [0.50] /CGgrd [0.25]
526 /CGk [0 ]
527 /CIr [1.00 0.33 0.33] /CIg [0.33 1.00 0.33]
528 /CIb [0.33 0.33 1.00] /CIc [1.00 0.00 0.00 0.00]
529 /CIm [0.00 1.00 0.00 0.00] /CIy [0.00 0.00 1.00 0.00]
530 /CIo [1.00 0.78 0.00] /CIp [1.00 0.67 0.67]
531 /CIw [1 ] /CIgrl [0.75]
532 /CIgr [0.50] /CIgrd [0.25]
533 /CIk [0 ]
534 >> def
535
536 /grayColorMap
537 << /Cr [0 ] /Cg [0 ]
538 /Cb [0 ] /Cc [0 ]
539 /Cm [0 ] /Cy [0 ]
540 /Co [0 ] /Cp [0 ]
541 /Cw [0 ] /Cgrl [0 ]
542 /Cgr [0 ] /Cgrd [0 ]
543 /Ck [0 ]
544 /CGr [0.75] /CGg [1 ]
545 /CGb [0.50] /CGc [0.75]
546 /CGm [0.50] /CGy [1 ]
547 /CGo [0.75] /CGp [1 ]
548 /CGw [0 ] /CGgrl [0.25]
549 /CGgr [0.50] /CGgrd [0.75]
550 /CGk [1 ]
551 /CIr [1 ] /CIg [1 ]
552 /CIb [1 ] /CIc [1 ]
553 /CIm [1 ] /CIy [1 ]
554 /CIo [1 ] /CIp [1 ]
555 /CIw [1 ] /CIgrl [1 ]
556 /CIgr [1 ] /CIgrd [1 ]
557 /CIk [1 ]
558 >> def
559
560 /bwColorMap
561 << /Cr [0 ] /Cg [0 ]
562 /Cb [0 ] /Cc [0 ]
563 /Cm [0 ] /Cy [0 ]
564 /Co [0 ] /Cp [0 ]
565 /Cw [0 ] /Cgrl [0 ]
566 /Cgr [0 ] /Cgrd [0 ]
567 /Ck [0 ]
568 /CGr [1 ] /CGg [1 ]
569 /CGb [1 ] /CGc [1 ]
570 /CGm [1 ] /CGy [1 ]
571 /CGo [1 ] /CGp [1 ]
572 /CGw [0 ] /CGgrl [1 ]
573 /CGgr [1 ] /CGgrd [1 ]
574 /CGk [1 ]
575 /CIr [1 ] /CIg [1 ]
576 /CIb [1 ] /CIc [1 ]
577 /CIm [1 ] /CIy [1 ]
578 /CIo [1 ] /CIp [1 ]
579 /CIw [1 ] /CIgrl [1 ]
580 /CIgr [1 ] /CIgrd [1 ]
581 /CIk [1 ]
582 >> def
583
584 %
585 % The following routines handle the alignment of and printing of
586 % tagged strings.
587 %
588
589 % Predefine the bounding box values.
590 /bbllx 0 def /bblly 0 def /bburx 0 def /bbury 0 def
591
592 % This routine pops the first unicode character off of a string and returns
593 % the remainder of the string, the character code of first character,
594 % and a "true" if the string was non-zero length.
595 % <string> popfirst <remaining string> <true>
596 % <null string> popfirst <false>
597 /popfirst {
598 dup length 1 gt
599 {dup 0 get /vg&fbyte exch def
600 dup 1 get /vg&cbyte exch def
601 dup length 2 sub 2 exch getinterval true}
602 {pop false} ifelse
603 } def
604
605 % This routine shows a single unicode character given the font and
606 % character codes.
607 % <font code> <char code> unicharshow --
608 /unicharshow {
609 2 string
610 dup 0 5 -1 roll put
611 dup 1 4 -1 roll put
612 internalshow
613 } def
614
615 % This is an internal routine to alternate between determining the
616 % bounding box for stringsize and showing the string for recshow.
617 % <string> internalshow --
618 /internalshow {show} def
619
620 % This is an internal routine to alternate between determining the
621 % bounding box for stringsize and stroking various ornaments.
622 % <string> internalstroke --
623 /internalstroke {S} def
624
625 % Sets up internalshow to use the null device to determine string size.
626 % -- nullinternalshow --
627 /nullinternalshow {/internalshow {false charpath flattenpath
628 pathbbox updatebbox} def} def
629
630 % Sets up internalstroke to use the null device to determine string size.
631 % -- nullinternalstroke --
632 /nullinternalstroke {
633 /internalstroke {flattenpath pathbbox updatebbox} def} def
634
635 % This routine tests to see if the character code matches the first
636 % character of a string.
637 % <char code> <string> testchar <char code> <true or false>
638 /testchar {exch dup 3 -1 roll 0 get eq} def
639
640 % Raise the text baseline for superscripts.
641 % -- raise --
642 /raise {
643 0 fontsize 2 div rmoveto
644 /fontsize fontsize 2 mul 3 div def
645 currentfont /FontName get fontsize sf
646 } def
647
648 % Un-raise the text baseline for superscripts.
649 % -- unraise --
650 /unraise {
651 /fontsize fontsize 1.5 mul def
652 0 fontsize 2 div neg rmoveto
653 } def
654
655 % Lower the text baseline for subscripts.
656 % -- lower --
657 /lower {
658 0 fontsize 3 div neg rmoveto
659 /fontsize fontsize 2 mul 3 div def
660 currentfont /FontName get fontsize sf
661 } def
662
663 % Un-lower the text baseline for subscripts.
664 % -- unlower --
665 /unlower {
666 /fontsize fontsize 1.5 mul def
667 0 fontsize 3 div rmoveto
668 } def
669
670 % Compare the top two elements on the stack and leave only the
671 % larger one.
672 /maxval {2 copy gt {pop} {exch pop} ifelse} def
673
674 % Tokenize a string. Do not use the usual PostScript token because
675 % parentheses will not be interpreted correctly because of rescanning
676 % of the string.
677 /vg&token {/vg&string exch def /vg&index -1 def /vg&level 0 def
678 0 2 vg&string length 2 sub {
679 dup dup 1 add exch vg&string exch get 8 bitshift vg&string 3 -1 roll get or
680 dup 16#f0fe eq {pop 1}{16#f0ff eq {-1}{0} ifelse} ifelse
681 /vg&level exch vg&level add def
682 vg&level 0 eq {/vg&index exch def exit} if pop
683 } for
684 vg&index 0 ge {
685 vg&string vg&index 2 add dup vg&string length exch sub getinterval
686 vg&index 2 gt {vg&string 2 vg&index 2 sub getinterval}{()} ifelse
687 true}
688 {false} ifelse
689 } bind def
690
691 % Recursively show an unicode string.
692 % <string> recshow --
693 /recshow {
694 popfirst
695 {
696 % Test to see if this is a string attribute.
697 vg&fbyte 16#f0 and 16#e0 eq
698 {
699 q
700
701 % Font style.
702 currentfont dup /FontStyleBits known {/FontStyleBits get}{pop 0} ifelse
703 vg&cbyte or vg&fontstyles exch get fontsize exch exec
704
705 vg&token pop recshow currentpoint Q m recshow
706 }
707 {
708 vg&fbyte 16#F8 and 16#F0 eq {
709
710 % Superscript and/or subscript.
711 vg&cbyte 16#00 eq {
712 vg&token pop exch vg&token pop 3 -1 roll
713 q raise recshow unraise currentpoint pop Q exch
714 q lower recshow unlower currentpoint pop Q
715 maxval currentpoint exch pop m recshow } if
716
717 % Strikeout.
718 vg&cbyte 16#01 eq {
719 vg&token pop currentpoint 3 -1 roll recshow
720 q 0 J vg&underline vg&uthick w
721 currentpoint 4 -2 roll fontsize 3 div add moveto
722 fontsize 3 div add lineto internalstroke Q
723 recshow} if
724
725 % Underline.
726 vg&cbyte 16#02 eq {
727 vg&token pop currentpoint 3 -1 roll recshow
728 q 0 J vg&underline vg&uthick w
729 currentpoint 4 -2 roll vg&uoffset add moveto
730 vg&uoffset add lineto internalstroke Q
731 recshow} if
732
733 % Dashed underline.
734 vg&cbyte 16#03 eq {
735 vg&token pop currentpoint 3 -1 roll recshow
736 q 0 J [ vg&uthick 5 mul vg&uthick 2 mul] 0 d
737 vg&underline vg&uthick w
738 currentpoint 4 -2 roll vg&uoffset add moveto
739 vg&uoffset add lineto internalstroke Q
740 recshow} if
741
742 % Dotted underline.
743 vg&cbyte 16#04 eq {
744 vg&token pop currentpoint 3 -1 roll recshow
745 q 1 J [ 0 vg&uthick 3 mul] 0 d
746 vg&underline vg&uthick w
747 currentpoint 4 -2 roll vg&uoffset add moveto
748 vg&uoffset add lineto internalstroke Q
749 recshow} if
750
751 % Thick underline.
752 vg&cbyte 16#05 eq {
753 vg&token pop currentpoint 3 -1 roll recshow
754 q 0 J vg&underline vg&uthick 2 mul w
755 currentpoint 4 -2 roll vg&uoffset vg&uthick 2 div sub add moveto
756 vg&uoffset vg&uthick 2 div sub add lineto internalstroke Q
757 recshow} if
758
759 % Gray thick underline.
760 vg&cbyte 16#06 eq {
761 vg&token pop currentpoint 3 -1 roll recshow
762 q 0 J vg&underline vg&uthick 2 mul w 0.5 setgray
763 currentpoint 4 -2 roll vg&uoffset vg&uthick 2 div sub add moveto
764 vg&uoffset vg&uthick 2 div sub add lineto internalstroke Q
765 recshow} if
766
767 % Overbar.
768 vg&cbyte 16#07 eq {
769 vg&token pop dup stringsize relative 4 1 roll pop pop exch
770 3 -1 roll recshow
771 q 0 J vg&underline vg&uthick w
772 vg&uoffset neg add dup currentpoint pop exch m l internalstroke Q
773 recshow} if
774 }
775 {
776 vg&fbyte vg&cbyte unicharshow recshow
777 } ifelse
778 } ifelse
779 } if
780 } def
781
782 % Get the underline position and thickness from the current font.
783 /vg&underline {
784
785 currentfont dup /FontType get 0 eq {/FDepVector get 0 get} if
786 dup dup /FontInfo known {
787 /FontInfo get dup
788 dup /UnderlinePosition known {
789 /UnderlinePosition get /vg&uoffset exch def
790 }
791 {
792 pop /vg&uoffset 0 def
793 } ifelse
794 dup /UnderlineThickness known {
795 /UnderlineThickness get /vg&uthick exch def
796 }
797 {
798 pop /vg&uthick 0 def
799 } ifelse
800 }
801 {
802 pop /vg&uoffset 0 def /vg&uthick 0 def
803 } ifelse
804 /FontMatrix get
805 currentfont dup /FontType get 0 eq
806 {/FontMatrix get matrix concatmatrix}{pop} ifelse
807 dup 0 vg&uoffset 3 -1 roll transform /vg&uoffset exch def pop
808 0 vg&uthick 3 -1 roll transform /vg&uthick exch def pop
809 } def
810
811 % Make a frame with the coordinates on the stack.
812 % <llx> <lly> <urx> <ury> frame --
813 /frame {4 copy m 3 1 roll exch l 4 -2 roll l l h} def
814
815 % Resets the accumulated bounding box to a degenerate box at the
816 % current point.
817 % -- resetbbox --
818 /resetbbox {
819 currentpoint 2 copy
820 /bbury exch def
821 /bburx exch def
822 /bblly exch def
823 /bbllx exch def
824 } def
825
826 % Update the accumulated bounding box.
827 % <llx'> <lly'> <urx'> <ury'> updatebbox --
828 /updatebbox {
829 dup bbury gt {/bbury exch def} {pop} ifelse
830 dup bburx gt {/bburx exch def} {pop} ifelse
831 dup bblly lt {/bblly exch def} {pop} ifelse
832 dup bbllx lt {/bbllx exch def} {pop} ifelse
833 } def
834
835 % Set the bounding box to the values on the stack.
836 % <llx'> <lly'> <urx'> <ury'> updatebbox --
837 /restorebbox {
838 /bbury exch def /bburx exch def /bblly exch def /bbllx exch def
839 } def
840
841 % Push the accumulated bounding box onto the stack.
842 % -- pushbbox <llx> <lly> <urx> <ury>
843 /pushbbox {bbllx bblly bburx bbury} def
844
845 % Make the relative bounding box relative to the currentpoint.
846 % <llx'> <lly'> <urx'> <ury'> inflate <llx> <lly> <urx> <ury>
847 /inflate {
848 2 {fontsize 0.2 mul add 4 1 roll} repeat
849 2 {fontsize 0.2 mul sub 4 1 roll} repeat
850 } def
851
852 % Make the relative bounding box relative to the currentpoint.
853 % <llx'> <lly'> <urx'> <ury'> relative <llx> <lly> <urx> <ury>
854 /relative {
855 currentpoint 3 -1 roll add 3 1 roll add exch 4 2 roll
856 currentpoint 3 -1 roll add 3 1 roll add exch 4 2 roll
857 } def
858
859 % Returns the size of a string appropriate for recshow.
860 % <string> stringsize <llx> <lly> <urx> <ury>
861 /stringsize {
862 pushbbox /internalshow load /internalstroke load 7 -1 roll
863 q
864 nulldevice 0 0 m
865 nullinternalshow nullinternalstroke
866 resetbbox
867 recshow
868 /internalstroke exch def /internalshow exch def
869 pushbbox 8 -4 roll restorebbox
870 Q
871 } def
872
873 % Calculate values for string positioning.
874 /calcval {4 copy
875 3 -1 roll sub /widy exch def sub neg /widx exch def
876 pop pop /dy exch def /dx exch def} def
877
878 % Utilities to position a string.
879 % First letter (U=upper, C=center, B=baseline, L=lower)
880 % Second letter (L=left, C=center, R=right)
881 /align [
882 {calcval dx neg widy dy add neg rmoveto} % UL
883 {calcval dx neg widy 2 div dy add neg rmoveto} % CL
884 {calcval dx neg 0 rmoveto} % BL
885 {calcval dx neg dy neg rmoveto} % LL
886 {calcval widx dx add neg widy dy add neg rmoveto} % UR
887 {calcval widx dx add neg widy 2 div dy add neg rmoveto} % CR
888 {calcval widx dx add neg 0 rmoveto} % BR
889 {calcval widx dx add neg dy neg rmoveto} % LR
890 {calcval widx 2 div dx add neg widy dy add neg rmoveto} % UC
891 {calcval widx 2 div dx add neg widy 2 div dy add neg rmoveto} % CC
892 {calcval widx 2 div dx add neg 0 rmoveto} % BC
893 {calcval widx 2 div dx add neg dy neg rmoveto} % LC
894 ] def
895
896 /vg&str {m q 1 -1 scale dup stringsize 4 copy align 11 -1 roll get exec
897 q inflate relative frame exch exec Q recshow Q} def
898
899 end /procDict exch def