]> git.lizzy.rs Git - plan9front.git/blob - sys/lib/ghostscript/ps2ai.ps
sed: allow whitespace after ! negation (thanks k0ga)
[plan9front.git] / sys / lib / ghostscript / ps2ai.ps
1 %!
2 %    Copyright (C) 1994 , 1999 Aladdin Enterprises.  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 % For more information about licensing, please refer to
12 % http://www.ghostscript.com/licensing/. For information on
13 % commercial licensing, go to http://www.artifex.com/licensing/ or
14 % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
15 % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
16
17 % $Id: ps2ai.ps,v 1.4 2002/02/21 21:49:28 giles Exp $
18 %xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
19 %
20 %   ps2ai.ps - a postscript to editable adobe illustrator file filter
21 %
22 /vers {2.14} def                  %                    January 31, 1999
23
24 % conditional def ( if the key is already defined before, don't 
25 % redefine it. This can be used by other programs to overwrite
26 % some settings from externally
27 %  
28 /cdef { 1 index where { pop pop pop } { def } ifelse } def
29 %
30 %xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
31 %
32 % needs a postscript level 2 interpreter, like gnu ghostscript, to work
33 %
34 %      Usage:   gs -q -dNODISPLAY ps2ai.ps file.ps > file.aips
35 %                              or (see below)
36 %               gs -q -dNODISPLAY ps2ai.ps file.ps
37 %                              or
38 %               cat ps2ai.ps file.ps | lpr  (then look in log file)
39 %
40 % or from within gsview via:
41 %       Edit->Convert to vector format
42 %xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
43 %                            Options
44 %xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
45 %   Output Options: directly to a file or standard out
46 %
47 /jout false cdef            % true=file  false=stdout (default=false)
48 /joutput (ps2ai.out.aips) cdef      % Name of Output file
49 %
50 %xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
51 %
52 %              Other Options
53 %
54 /jtxt3 true cdef           % output text in AI3 form (false=ai88)
55                           % for coreldraw/photoshop readable output
56 /joutln false cdef         % use font outline  instead of font
57 /jerr false def            % use error handling (ie die gracefully)
58 /jbiterr false def         % attempt to handle bitmap fonts (kludge)
59 /jMacGS false def         % true if using MacGS (not fully implemented yet)
60 /jMacfix true def         % convert filled boxes to lines (only usefull with
61                           % laserwriter 8 postscript input)
62
63 %
64 %xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
65 %                    No options below here
66 %xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
67 %
68 %         - Notes -
69 %  ai uses cmykcolor, so level 1 interpreters don't work
70 %  ai doesn't use image/imagemask - so bitmaps don't work correctly
71 %  the output file has a header so it is viewable/printable/reconvertable
72 %
73 % Comments, suggestions, bug-fixes, etc send to:
74 %
75 %        Jason Olszewski (olszewsk@splash.princeton.edu)
76 %
77 % anonymous ftp: toby.princeton.edu /pub/olszewsk/ps2ai.ps
78 %       URL ftp://toby.princeton.edu/pub/olszewsk
79 %
80 %         - Fix History -
81 %  2.14 added cdef to allow overwriting of certain values from externally
82 %  2.13 check for bitmap fonts, work better with TeX,WinPS,etc
83 %  2.12 fixed initclip to US letter size page
84 %  2.11 added header support for *u/*U compound paths
85 %  2.1  option of font outline instead of text(gwhite@trevnx.bio.dfo.ca)
86 %  2.0  major change to complex path handling
87 %  1.9  fixed text leaking ascii (,),\
88 %  1.85 added default font to handle no setfont (Courier)
89 %  1.84 added even-odd fill/clip (D)
90 %  1.83 undefined PPD PageSize printer specific info
91 %  1.82 added kludge to save clipping status through a restore
92 %  1.81 added custom color/gray support to header (x/X, g/G)
93 %  1.8  added newpath if clippath is not consumed correctly(amiga)
94 %  1.79 eliminated scientific notation of numbers less than 0.0001
95 %  1.78 fixed transposed h & H
96 %  1.77 made laserwriter 8 fixes optional
97 %  1.76 added margin fix for unix AI (brown@wi.extrel.com)
98 %  1.75 added kludge to handle bitmap font errors (TeX, Windows.ps)
99 %  1.74 made grestore a little smarter
100 %  1.73 included header handle encoded fontname (/_fontname)
101 %  1.72 fixed problem with restore/clip info - (not enough Qs problem)
102 %  1.71 filter font names to remove previous encoding (|,_,etc)
103 %  1.7  change text format to AI3, works better with PS & CD
104 %  1.67 deal with weird makefonts 
105 %  1.66 handle to many bad stroke/fills (s s s w/o paths)
106 %  1.65 more useable with non-gs interpreters (defaultmatrix fix)
107 %  1.64 fixed "smart grestore" repeat bug
108 %  1.63 fixed ashow/awidthshow bug
109 %  1.62 check if cmykcolor is understood otherwise rgb
110 %  1.61 made grestore smarter (only print if different)
111 %  1.6  add better compatibility to CorelDraw and PhotoShop
112 %  1.53 make it more gs-backward compatible (clarke@lsl.co.uk)
113 %  1.52 handle clipping paths a little better (Posted)
114 %  1.51 improve mac lw8 output (lines instead of filled boxes)
115 %  1.5 handle some level 2 stuff (mac lw8)
116 %  1.4 fixed scaling of linewidth and dash
117 %  1.31 made trailer more AI88 friendly
118 %  1.3 add ablity to output to file directly
119 %  1.21 print matrix cleaner
120 %  1.2 fix rotated fonts, thanks to G.Cameron (g.cameron@biomed.abdn.ac.uk)
121 %  1.1 fix stroke/fill color difference (k vs K)
122 %  1.0 posted to comp.lang.postscript
123 %
124 %         - To Do List -
125 %  find real %%BoundingBox: llx lly urx ury
126 %  make MacGS friendly (line-endings)
127 %  handle eps w/o showpage:(append to end)
128 %  write out image data to external file
129 %
130 %xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
131 %                  Nothing of Interest below here
132 %xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
133 matrix identmatrix setmatrix %   make ctm [1 0 0 1 0 0]
134 /oldgsave {} def /oldgrestore {} def
135 /initgraphics {} def /initmatrix {} def 
136 % undefine PPD PageSizes to be more printer independant
137 /letter {} def /legal {} def /a4 {} def /b5 {} def /lettersmall {} def
138 /setpagedevice { pop } def % for level 2 PPD PageSizes
139 /Courier findfont 12 scalefont setfont % handle no setfont
140 /initclip {0 0 moveto 0 792 lineto 612 792 lineto 612 0 lineto closepath
141            clip newpath } def
142 /xdef {exch def} def
143 /trx {transform exch} def
144 /cbdef {cvx bind def} def
145 /jltz {dup abs 0.0001 lt {pop 0} if} def % get rid of scientific notation bug
146 /clstate false def        % closepath state
147 /dpth false def           % destroy path (ie newpath)
148 /fclp false def           % first paint after clip
149 /kscl {1.0} def           % default current scale X-factor
150 /gcnt {1} def             % graphics state counter
151 /spth {1} def             % multiple paths on stack
152 /jeol (\n) def            % default end-of-line
153 /jnump {0} def            % number of paths on stack
154 /jx {0} def /jy {0} def /j_ax {0} def
155 /j3ftxt true def
156 /clarry 10 array def
157 0 1 9 {clarry exch false put} for % initilize no clipping path
158 %
159 % handle cmyk color on level 1 interpreters
160 /setcmykcolor where {pop}
161  {/setcmykcolor {
162    /blk exch def /yel exch def /mag exch def /cyan exch def
163    /ccomp {add dup 1 gt {pop 1} if} def
164    /red {1 cyan blk ccomp sub} def
165    /green {1 mag blk ccomp sub} def
166    /blue {1 yel blk ccomp sub} def
167    red green blue setrgbcolor
168   } def
169 } ifelse
170 /currentcmykcolor where {pop}
171  {/currentcmykcolor {
172    currentrgbcolor /bval xdef /gval xdef /rval xdef
173    /rawC 1 rval sub def /rawM 1 gval sub def /rawY 1 bval sub def
174    rawC rawM ge { rawY rawM ge { /blk rawM def} if } if
175    rawC rawY ge { rawM rawY ge { /blk rawY def} if } if
176    rawY rawC ge { rawM rawC ge { /blk rawC def} if } if
177    rawY rawC eq { rawM rawC eq { /blk rawC def} if } if
178    /cyan  rawC blk sub  def
179    /mag  rawM blk sub  def
180    /yel  rawY blk sub  def
181    /blk blk def
182    cyan mag yel blk
183   } def
184 } ifelse
185 % If using Mac Ghostscript 
186 jMacGS { 
187 %        /jeol {(\r) jp} def
188         /jout true def
189         (%%Note: Loading ps2ai.ps\n) print
190        } if
191 /jstr 40 string def
192 jout {joutput (w) file /joutput xdef} if
193 %
194 %              Output
195 %
196 jout {/jp { joutput exch writestring } bind def }{/jp {print}bind def} ifelse
197 /jpnum {jltz ( ) jp =string cvs jp } bind def
198 /jpmat { dup /jarry exch def length 1 sub /j_num exch def
199  (\[) jp 0 1 j_num {jarry exch get jpnum} for (\]) jp } def
200 %
201 %              Stack to Paths converters
202 %
203 /ckpnt { % check which paint and clipping to use
204    dpth {  % if there are multiple paths on the stack
205   clarry gcnt get fclp and {clstate {(h W\n) jp }{(H W\n) jp } ifelse} if
206   spth 0 eq {clstate {(n\n) jp }{(N\n) jp } ifelse} if
207   spth 1 eq {clstate {(s\n) jp }{(S\n) jp } ifelse} if
208   spth 2 eq {clstate {(f\n) jp }{(F\n) jp } ifelse} if
209      } if
210 } def
211 /jpm {
212   ckpnt
213   /dpth true def
214   transform 2 copy /yst xdef /xst xdef exch jpnum jpnum ( m\n) jp } bind def
215 /jpl { trx jpnum jpnum ( l\n) jp } bind def
216 /jpc {  6 4 roll trx jpnum jpnum 4 2 roll trx jpnum jpnum trx
217     jpnum jpnum ( c\n) jp } bind def
218 /jpp {xst jpnum yst jpnum ( l\n) jp /clstate true def} def
219 /cntpaths { % count paths on stack
220   oldgsave
221   {pop pop /jnump jnump 1 add def} {pop pop} {6 {pop} repeat}{} pathforall
222   oldgrestore
223 } def
224 /ppforall {
225  cntpaths % find out how many paths are on the stack
226  jnump 1 gt { (*u\n) jp } if
227  {jpm}{jpl}{jpc}{jpp} pathforall 
228   ckpnt
229  jnump 1 gt { (*U\n) jp } if
230  /jnump 0 def /clstate false def /dpth false def /fclp false def
231   oldnewpath
232 } bind def
233 %
234 %              Painting Operators
235 %
236 /oldnewpath [/newpath load] cbdef
237 /newpath { (\n) jp /spth 0 def ppforall} def 
238 /stroke { (\n) jp /spth 1 def ppforall } def 
239 /fill   {(\n) jp /spth 2 def ppforall } def 
240 /eofill {(1 D\n) jp fill (0 D\n) jp} def
241 /clip {clarry gcnt get {(Q\nq\n) jp}{(q\n) jp} ifelse 
242                    /fclp true def clarry gcnt true put} def
243 /eoclip {(1 D\n) jp clip (0 D\n) jp} def
244 %
245 %               Text Operators
246 %
247 /oldshow [/show load] cbdef
248 /curpt {stringwidth pop jx add jy} def 
249 /jNN {dup 0 eq {pop oldgsave currentfont /FontMatrix get setmatrix kscl
250                 oldgrestore} if
251 } def
252 /curftmatrix {
253  currentfont /FontMatrix get dup 0 get jNN abs /norm exch def 
254  dup 0 get norm div exch dup
255  1 get norm div exch dup 2 get norm div exch dup 3 get norm div exch dup
256  4 get exch 5 get 6 array astore matrix currentmatrix matrix concatmatrix
257 } def
258 % AI does not support negitive font sizes
259 /curftsize {currentfont /FontMatrix get 0 get jNN abs 1000 mul} def
260 /hstr (X) def
261 /vbar (|) 0 get def /undsc (_) 0 get def
262 /ftnamefix { % handle font names with |,_ (previously encoded)
263 jstr cvs
264 { %forall
265         dup vbar eq {pop}{ %ifelse
266             dup undsc eq {pop}{ %ifelse
267                     hstr exch 0 exch put hstr jp
268             } ifelse
269         } ifelse
270    } forall   flush
271 } bind def
272 %/curftname {currentfont /FontName get ftnamefix}def
273 /curftname { currentfont /FontName known {currentfont /FontName get}
274            { (Times-Roman)} ifelse ftnamefix } def
275 /lftpar (\() 0 get def
276 /rhtpar (\)) 0 get def
277 /bckslsh (\\) 0 get def
278 /handft { % handle strings with (,),\
279    (\() jp
280    { %forall
281         dup lftpar eq { (\\\() jp }{ %ifelse
282             dup rhtpar eq { (\\\)) jp }{ %ifelse
283                 dup bckslsh eq { (\\\\) jp }{ %ifelse
284                     hstr exch 0 exch put hstr jp
285                 } ifelse
286             } ifelse
287         } ifelse
288    } forall (\)) jp flush
289 } bind def
290 % AI 3 text format pieces
291 jtxt3 {
292 /j3txt { j3ftxt {(0 Ts 100 Tz 0 Tt 0 TA 0 0 5 TC 100 100 200 TW 0 0 0 Ti\n) jp
293                 (0 Ta 0 Tq 0 0 TI 0 Tc 0 Tw\n) jp} if } def
294 /show {oldgsave  (0 To\n) jp 
295   currentpoint 2 copy /jy exch def /jx exch def translate 
296   curftmatrix /jitm exch def
297   0 1 5 {jitm exch get jpnum} for ( 0 Tp\n) jp (TP\n) jp
298   (0 Tr\n) jp (\/_) jp curftname  curftsize jpnum ( Tf\n) jp
299   (0) jp j_ax  curftsize div 100 mul jpnum ( 100 TC\n) jp %  percent(?)
300   dup curpt moveto mark exch handft ( Tx\n) jp (TO\n) jp /j3ftxt false def
301   cleartomark currentpoint oldgrestore moveto
302 } def  
303 /ashow {exch pop exch /j_ax exch def show /j_ax {0} def } def
304
305  {
306 /show {oldgsave (u\n) jp currentpoint 2 copy /jy exch def /jx exch def translate
307   (\/) jp curftname jstr cvs jp
308   curftsize dup jpnum  jpnum ( 0 0 z\n) jp
309   curftmatrix jpmat ( e\n) jp
310   dup curpt moveto mark exch handft ( t T U\n) jp
311   cleartomark currentpoint oldgrestore moveto} def
312 /ashow {oldgsave (u\n) jp currentpoint translate (\/) jp curftname jstr cvs jp
313   curftsize dup jpnum jpnum  exch kscl mul jpnum ( 0 z\n) jp
314   curftmatrix jpmat ( e\n) jp dup curpt moveto mark exch handft
315   ( t T U\n) jp cleartomark currentpoint oldgrestore moveto} def
316 } ifelse
317 /widthshow { show pop pop pop} def
318 /awidthshow {ashow pop pop pop} def
319 /kshow {show pop} def
320 %/show {true charpath fill} bind def   % get outline of charactor
321 joutln {/show { true charpath currentpoint 
322      /jy exch def /jx exch def fill jx jy moveto} bind def} if
323 %/show {oldshow} def    % do nothing different
324 %
325 %               Color Operators
326 %
327 /oldsetcmykcolor [/setcmykcolor load] cbdef
328 /setcmykcolor {oldsetcmykcolor 
329 currentcmykcolor 4 -1 roll jpnum 3 -1 roll jpnum 2 -1 roll jpnum jpnum ( k\n) jp
330 currentcmykcolor 4 -1 roll jpnum 3 -1 roll jpnum 2 -1 roll jpnum jpnum ( K\n) jp
331  } def
332 /oldsetgray [/setgray load] cbdef
333 /setgray {0 0 0 4 -1 roll 1 exch sub setcmykcolor} def
334 /oldsethsbcolor [/sethsbcolor load] cbdef
335 /sethsbcolor {oldsethsbcolor currentcmykcolor setcmykcolor} def
336 /oldsetrgbcolor [/setrgbcolor load] cbdef
337 /setrgbcolor {oldsetrgbcolor currentrgbcolor /bval xdef /gval xdef /rval xdef
338  /rawC 1 rval sub def /rawM 1 gval sub def /rawY 1 bval sub def
339  rawC rawM ge { rawY rawM ge { /blk rawM def} if } if
340  rawC rawY ge { rawM rawY ge { /blk rawY def} if } if
341  rawY rawC ge { rawM rawC ge { /blk rawC def} if } if
342  rawY rawC eq { rawM rawC eq { /blk rawC def} if } if
343  /cyan  rawC blk sub  def
344  /mag  rawM blk sub  def
345  /yel  rawY blk sub  def
346  /blk blk def
347  cyan mag yel blk setcmykcolor } def
348 %
349 %                State Operators
350 %
351 /oldsetlinewidth [/setlinewidth load] cbdef
352 /setlinewidth {kscl abs mul jltz  oldsetlinewidth
353  currentlinewidth jpnum ( w\n) jp } def
354 /oldsetlinecap [/setlinecap load] cbdef
355 /setlinecap {dup oldsetlinecap jpnum ( J\n) jp} def
356 /oldsetlinejoin [/setlinejoin load] cbdef
357 /setlinejoin {dup oldsetlinejoin jpnum ( j\n) jp} def
358 /oldsetmiterlimit [/setmiterlimit load] cbdef
359 /setmiterlimit {dup oldsetmiterlimit jpnum ( M\n) jp}def
360 /oldsetdash [/setdash load] cbdef
361 /setdash {exch [ exch {kscl abs mul} forall ] exch kscl abs mul oldsetdash
362   currentdash exch jpmat jpnum ( d\n) jp } def
363 /oldsetflat [/setflat load] cbdef
364 /setflat {dup oldsetflat jpnum ( i\n) jp } def
365 %
366 %                More State Operators
367 %
368 /kscl { % use just the x scale factor
369  oldgsave
370  matrix currentmatrix /jctm exch def
371  jctm 4 0 put jctm 5 0 put jctm setmatrix
372  1 0 moveto currentpoint transform
373  dup mul exch dup mul add sqrt 10000 mul round 10000 div
374  oldgrestore
375 } def
376 /currentstate {currentcmykcolor setcmykcolor
377  currentflat jpnum ( i) jp currentlinecap jpnum ( J) jp
378  currentlinejoin jpnum ( j) jp currentlinewidth jpnum ( w) jp
379  currentmiterlimit jpnum ( M ) jp currentdash exch jpmat jpnum ( d\n) jp 
380 } def
381 /jdifG {
382  currentcmykcolor /jok xdef /joy xdef /jom xdef /joc xdef
383  currentflat /jof xdef currentlinecap /jolc xdef currentlinejoin /jolj xdef
384  currentlinewidth /jolw xdef currentmiterlimit /joml xdef
385  currentdash /jood xdef /joad xdef
386  oldgrestore
387  currentcmykcolor /jnk xdef /jny xdef /jnm xdef /jnc xdef
388  currentflat /jnf xdef currentlinecap /jnlc xdef currentlinejoin /jnlj xdef
389  currentlinewidth /jnlw xdef currentmiterlimit /jnml xdef
390  currentdash /jnod xdef /jnad xdef
391  % compare old gstate to new gstate
392  joc jnc ne jom jnm ne joy jny ne jok jnk ne
393  jof jnf ne jolc jnlc ne jolj jnlj ne jolw jnlw ne joml jnml ne 
394  false joad {true exit} forall {pop pop true}{false} ifelse
395  false jnad {true exit} forall {pop pop true}{false} ifelse ne
396  jood jnod ne 10 {or} repeat {currentstate} if
397 } def
398 /oldgsave [/gsave load] cbdef
399 /gsave {oldgsave /gcnt gcnt 1 add def } def % clarry gcnt false put} def
400 %  (%%Note:gsave ) jp gcnt jpnum (\n) jp} def
401 /oldgrestore [/grestore load] cbdef
402 /grestore {dpth {newpath} if clarry gcnt get {(Q\n) jp clarry gcnt false put} if 
403  jdifG /gcnt gcnt 1 sub def } def
404 % oldgrestore currentstate } def
405 % (%%Note:grestore ) jp gcnt 1 add jpnum (\n) jp} def
406 /oldrestore [/restore load] cbdef
407 % a kludgy way of saving the clipping path status information
408 /restore {clarry aload pop 11 -1 roll oldrestore clarry astore pop} def
409 /showpage {  0 1 9 {clarry exch get {(Q\n) jp} if } for
410  (%%Note: If Error, make sure there are matched pairs of 'q's and 'Q's\n) jp
411  (%%Note: in the file. Add 'Q's before '%%Trailer' until equal\n) jp
412  (%%Trailer\n) jp
413  jtxt3 {(Adobe_IllustratorA_AI3 /terminate get exec\n) jp
414         (Adobe_typography_AI3 /terminate get exec\n) jp
415         (Adobe_customcolor /terminate get exec\n) jp
416         (Adobe_cshow /terminate get exec\n) jp
417         (Adobe_cmykcolor /terminate get exec\n) jp
418         (Adobe_packedarray /terminate get exec\n) jp
419 }{
420         (Adobe_Illustrator881 /terminate get exec\n) jp
421         (Adobe_customcolor /terminate get exec\n) jp
422         (Adobe_cshow /terminate get exec\n) jp
423         (Adobe_cmykcolor /terminate get exec\n) jp
424         (Adobe_packedarray /terminate get exec\n) jp 
425        } ifelse
426 ( showpage\n%EOF\n%%EndDocument\n) jp
427  jout {joutput closefile} if jMacGS not {quit} if /j3ftxt true def } def 
428 %
429 %                Error handling
430 %
431 errordict begin
432 % Attempt to handle the error caused by bitmap fonts (TeX,Windows.ps,etc)
433 % this is a big-time kludge
434 jbiterr {
435  /undefined {pop pop (Times-Roman)} def
436  /typecheck {pop pop} def
437 } if
438 jerr {
439  /handleerror {
440   (%%Note: ps2ai error, aborting rest of conversion\n) jp showpage
441  } def
442 } if
443 end
444 %
445 %                Mac LW 8 improvements
446 %
447 /jmacimp { % stroked line instead of thin filled boxes
448  /@a {  3 -1 roll 2 div dup 3 -1 roll add exch 3 -1 roll add exch moveto
449       3 -1 roll 2 div dup 3 -1 roll add exch 3 -1 roll exch sub exch lineto
450       abs setlinewidth  stroke pop pop} def
451  /@b { 3 -1 roll 2 div dup 3 -1 roll add exch 3 -1 roll add exch moveto
452       pop
453       3 -1 roll 2 div dup 3 -1 roll add exch 3 -1 roll add exch lineto
454       abs setlinewidth  stroke} def
455  /endp {showpage pm restore} def % because the restore stops clean up
456 } def
457 %
458 %                Handle (some) PS Level 2
459 %
460 /rectstroke { 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto
461   closepath stroke} def
462 /rectfill { 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto
463   fill } def
464 /rectclip { 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto neg 0 rlineto
465   closepath clip newpath jMacfix {jmacimp} if } def
466 %
467 % Add a header prolog to the output file so it is still view/print-able
468 %
469 (%!PS-Adobe-2.0 EPSF-1.2\n%%BoundingBox: 0 0 612 792\n) jp
470 (%%Title: Adobe Illustator 3 Editable Document\n) jp
471 (%%Creator: ps2ai.ps vers.) jp vers jpnum ( \(C\) 1993-94 Jason Olszewski\n) jp
472 (%%TemplateBox: 0 0 612 792\n) jp
473 jtxt3 {(%%AI3_Margin:0 0 0 0\n) jp } if
474 (%%EndComments\n) jp
475 (%%BeginProlog\n) jp
476 (/m {moveto} def /l {lineto} def /c {curveto} def\n) jp
477 (/S {stroke} def /F {fill} def\n) jp
478 (/s {closepath S} def /f {closepath F} def\n) jp
479 (/q {gsave} def /Q {grestore} def /W {clip} def /k {setcmykcolor} def\n) jp
480 (/i {setflat} def /J {setlinecap} def /j {setlinejoin} def\n) jp
481 (/w {setlinewidth} def /M {setmiterlimit} def /d {setdash} def\n) jp
482 (/u {gsave} def /U {grestore} def /K {k} def\n) jp
483 (/N {newpath} def /n {closepath N} def\n) jp
484 (/g {setgray} def /G {g} def\n) jp
485 (/x {pop pop k} def /X {x} def\n) jp
486 (/H {} def /h {H closepath} def /D {pop} def\n) jp
487 (/*u { /N {/spth 0 def}def /S{/spth 1 def}def /F {/spth 2 def} def} def\n) jp
488 (/*U { spth 0 eq {newpath} if spth 1 eq {stroke} if spth 2 eq {fill} if\n) jp
489 (     /N {newpath} def /S {stroke} def /F {fill} def  } def\n) jp
490 %(\n) jp
491 jtxt3 {
492  (/TC {pop pop pop} def /Tr {pop} def\n) jp
493  (/To {pop gsave} def /TO {grestore} def\n) jp
494  (/Tp {pop matrix astore concat} def  /TP {0 0 moveto} def\n) jp
495  (/a_str 40 string def /cnt 0 def /h_str (X) def /undsc (_) 0 get def\n) jp
496  (/fntfix {a_str cvs dup length 1 sub /f_str exch string def\n) jp
497  (  {dup undsc eq {pop}{f_str cnt 3 -1 roll put /cnt cnt 1 add def\n) jp
498  (  } ifelse } forall flush /cnt 0 def f_str cvn } bind def\n) jp
499
500  (/Tf {exch fntfix findfont exch scalefont setfont} def /Tx {show} def\n) jp
501 }{
502  (/z {pop pop pop exch findfont exch scalefont setfont} def\n) jp
503  (/e {concat 0 0 m} def /t {show} def /T {} def\n) jp
504 } ifelse
505 (\n) jp
506 jtxt3 {
507  (userdict /Adobe_packedarray 2 dict dup begin put\n) jp
508  (/initialize {} def /terminate {} def\n) jp
509  (userdict /Adobe_cmykcolor 2 dict dup begin put\n) jp
510  (/initialize {} def /terminate {} def\n) jp
511  (userdict /Adobe_cshow 2 dict dup begin put\n) jp
512  (/initialize {} def /terminate {} def\n) jp
513  (userdict /Adobe_customcolor 2 dict dup begin put\n) jp
514  (/initialize {} def /terminate {} def\n) jp
515  (userdict /Adobe_typography_AI3 2 dict dup begin put\n) jp
516  (/initialize {} def /terminate {} def\n) jp
517  (userdict /Adobe_IllustratorA_AI3 2 dict dup begin put\n) jp
518  (/initialize {} def /terminate {} def\n) jp
519 }{
520  (userdict /Adobe_packedarray 2 dict dup begin put\n) jp
521  (/initialize {} def /terminate {} def\n) jp
522  (userdict /Adobe_cmykcolor 2 dict dup begin put\n) jp
523  (/initialize {} def /terminate {} def\n) jp
524  (userdict /Adobe_cshow 2 dict dup begin put\n) jp
525  (/initialize {} def /terminate {} def\n) jp
526  (userdict /Adobe_customcolor 2 dict dup begin put\n) jp
527  (/initialize {} def /terminate {} def\n) jp
528  (userdict /Adobe_Illustrator881 2 dict dup begin put\n) jp
529  (/initialize {} def /terminate {} def\n) jp
530 } ifelse
531 (%%EndProlog\n) jp
532 (%%BeginSetup\n) jp
533 jtxt3 {
534  (Adobe_packedarray /initialize get exec\n) jp
535  (Adobe_cmykcolor /initialize get exec\n) jp
536  (Adobe_cshow /initialize get exec\n) jp
537  (Adobe_customcolor /initialize get exec\n) jp
538  (Adobe_typography_AI3 /initialize get exec\n) jp
539  (Adobe_IllustratorA_AI3 /initialize get exec\n) jp
540 }{
541  (Adobe_packedarray /initialize get exec\n) jp
542  (Adobe_cmykcolor /initialize get exec\n) jp
543  (Adobe_cshow /initialize get exec\n) jp
544  (Adobe_customcolor /initialize get exec\n) jp
545  (Adobe_Illustrator881 /initialize get exec\n) jp
546 } ifelse
547 (%%EndSetup\n) jp
548 0 0 0 1 oldsetcmykcolor
549 currentstate
550
551 jout {(%%Note: Load Postscript file to be converted now\n) print} if