home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Updates / GhostScript / !GhostScr / 6_01 / lib / ps2ai.ps < prev    next >
Text File  |  2000-03-09  |  23KB  |  554 lines

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