星火微课系统客户端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

ps2ai.ps 22KB

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