gs_init.ps 59 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876
  1. % (C) 1989, 2000 Aladdin Enterprises. All rights reserved.
  2. %
  3. % This file is part of AFPL Ghostscript.
  4. %
  5. % AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author or
  6. % distributor accepts any responsibility for the consequences of using it, or
  7. % for whether it serves any particular purpose or works at all, unless he or
  8. % she says so in writing. Refer to the Aladdin Free Public License (the
  9. % "License") for full details.
  10. %
  11. % Every copy of AFPL Ghostscript must include a copy of the License, normally
  12. % in a plain ASCII text file named PUBLIC. The License grants you the right
  13. % to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14. % conditions described in the License. Among other things, the License
  15. % requires that the copyright notice and this notice be preserved on all
  16. % copies.
  17. % $Id: gs_init.ps,v 1.40.2.4 2002/02/01 03:25:45 raph Exp $
  18. % Initialization file for the interpreter.
  19. % When this is run, systemdict is still writable.
  20. % Comment lines of the form
  21. % %% Replace <n> <file(s)>
  22. % indicate places where the next <n> lines should be replaced by
  23. % the contents of <file(s)>, when creating a single merged init file.
  24. % The interpreter can call out to PostScript code. All procedures
  25. % called in this way, and no other procedures defined in these
  26. % initialization files, have names that begin with %, e.g.,
  27. % (%Type1BuildChar) cvn.
  28. % Check the interpreter revision. NOTE: the interpreter code requires
  29. % that the first non-comment token in this file be an integer.
  30. 704
  31. dup revision ne
  32. { (gs: Interpreter revision \() print revision 10 string cvs print
  33. (\) does not match gs_init.ps revision \() print 10 string cvs print
  34. (\).\n) print flush null 1 .quit
  35. }
  36. if pop
  37. % Acquire userdict, and set its length if necessary.
  38. /userdict where
  39. { pop userdict maxlength 0 eq }
  40. { true }
  41. ifelse
  42. systemdict exch
  43. { % userdict wasn't already set up by iinit.c.
  44. dup /userdict
  45. currentdict dup 200 .setmaxlength % userdict
  46. .forceput % userdict is local, systemdict is global
  47. }
  48. if begin
  49. % Define dummy local/global operators if needed.
  50. systemdict /.setglobal known
  51. { true .setglobal
  52. }
  53. { /.setglobal { pop } bind def
  54. /.currentglobal { false } bind def
  55. /.gcheck { pop false } bind def
  56. }
  57. ifelse
  58. % Define .languagelevel if needed.
  59. systemdict /.languagelevel known not { /.languagelevel 1 def } if
  60. % Optionally choose a default paper size other than U.S. letter.
  61. % (a4) /PAPERSIZE where { pop pop } { /PAPERSIZE exch def } ifelse
  62. % Turn on array packing for the rest of initialization.
  63. true setpacking
  64. % Define the old MS-DOS EOF character as a no-op.
  65. % This is a hack to get around the absurd habit of MS-DOS editors
  66. % of adding an EOF character at the end of the file.
  67. <1a> cvn { } def
  68. % Acquire the debugging flags.
  69. currentdict /DEBUG known /DEBUG exch def
  70. /VMDEBUG
  71. DEBUG {{print mark
  72. systemdict /level2dict known
  73. { .currentglobal dup false .setglobal vmstatus
  74. true .setglobal vmstatus 3 -1 roll pop
  75. 6 -2 roll pop .setglobal
  76. }
  77. { vmstatus 3 -1 roll pop
  78. }
  79. ifelse usertime 16#fffff and counttomark
  80. { ( ) print ( ) cvs print }
  81. repeat pop
  82. ( ) print systemdict length ( ) cvs print
  83. ( ) print countdictstack ( ) cvs print
  84. ( <) print count ( ) cvs print (>\n) print flush
  85. }}
  86. {{pop
  87. }}
  88. ifelse
  89. def
  90. currentdict /BATCH known /BATCH exch def
  91. currentdict /DELAYBIND known /DELAYBIND exch def
  92. currentdict /DISKFONTS known /DISKFONTS exch def
  93. currentdict /DOINTERPOLATE .knownget { /INTERPOLATE exch def } if
  94. currentdict /ESTACKPRINT known /ESTACKPRINT exch def
  95. currentdict /FAKEFONTS known /FAKEFONTS exch def
  96. currentdict /FIXEDMEDIA known /FIXEDMEDIA exch def
  97. currentdict /FIXEDRESOLUTION known /FIXEDRESOLUTION exch def
  98. currentdict /LOCALFONTS known /LOCALFONTS exch def
  99. currentdict /NOBIND known /NOBIND exch def
  100. /.bind /bind load def
  101. NOBIND { /bind { } def } if
  102. currentdict /NOCACHE known /NOCACHE exch def
  103. currentdict /NOCCFONTS known /NOCCFONTS exch def
  104. currentdict /NOCIE known /NOCIE exch def
  105. currentdict /NODISPLAY known not /DISPLAYING exch def
  106. currentdict /NOFONTMAP known /NOFONTMAP exch def
  107. currentdict /NOFONTPATH known /NOFONTPATH exch def
  108. currentdict /NOGC known /NOGC exch def
  109. currentdict /NOINTERPOLATE .knownget { /INTERPOLATE exch not def } if
  110. currentdict /NOPAGEPROMPT known /NOPAGEPROMPT exch def
  111. currentdict /NOPAUSE known /NOPAUSE exch def
  112. currentdict /NOPLATFONTS known /NOPLATFONTS exch def
  113. currentdict /NOPROMPT known /NOPROMPT exch def
  114. % The default value of ORIENT1 is true, not false.
  115. currentdict /ORIENT1 known not { /ORIENT1 true def } if
  116. currentdict /OSTACKPRINT known /OSTACKPRINT exch def
  117. currentdict /OUTPUTFILE known % obsolete
  118. { /OutputFile /OUTPUTFILE load def
  119. currentdict /OUTPUTFILE .undef
  120. } if
  121. currentdict /QUIET known /QUIET exch def
  122. % DELAYSAFER is effectively the same as newer NOSAFER
  123. currentdict /DELAYSAFER known { /DELAYSAFER true def /NOSAFER true def } if
  124. currentdict /PARANOIDSAFER known /PARANOIDSAFER exch def
  125. /SAFER currentdict /NOSAFER known {
  126. false
  127. } {
  128. currentdict /SAFER known PARANOIDSAFER or
  129. }
  130. ifelse def
  131. currentdict /SHORTERRORS known /SHORTERRORS exch def
  132. currentdict /STRICT known /STRICT exch def
  133. currentdict /TTYPAUSE known /TTYPAUSE exch def
  134. currentdict /WRITESYSTEMDICT known /WRITESYSTEMDICT exch def
  135. % Acquire environment variables.
  136. currentdict /DEVICE known not
  137. { (GS_DEVICE) getenv { /DEVICE exch def } if } if
  138. (START) VMDEBUG
  139. % Open the standard files, so they will be open at the outermost save level.
  140. (%stdin) (r) file pop
  141. (%stdout) (w) file pop
  142. (%stderr) (w) file pop
  143. /.currentuserparams where {
  144. pop mark
  145. % The Adobe implementations appear to have very large maximum
  146. % stack sizes. This turns out to actually make a difference,
  147. % since some badly-behaved files include extremely long procedures,
  148. % or construct huge arrays on the operand stack.
  149. % We reset the stack sizes now so that we don't have to worry
  150. % about overflowing the (rather small) built-in stack sizes
  151. % during initialization.
  152. /MaxDictStack 500
  153. /MaxExecStack 5000
  154. /MaxOpStack 50000
  155. .dicttomark .setuserparams
  156. } if
  157. % Define a procedure for skipping over an unneeded section of code.
  158. % This avoids allocating space for the skipped procedures.
  159. % We can't use readline, because that imposes a line length limit.
  160. /.skipeof % <string> .skipeof -
  161. { currentfile exch 1 exch .subfiledecode flushfile
  162. } .bind def
  163. % Define procedures to assist users who don't read the documentation.
  164. userdict begin
  165. /help
  166. { (Enter PostScript commands. '(filename) run' runs a file, 'quit' exits.\n)
  167. print flush
  168. } .bind def
  169. end
  170. % Define =string, which is used by some PostScript programs even though
  171. % it isn't documented anywhere.
  172. % Put it in userdict so that each context can have its own copy.
  173. userdict /=string 256 string put
  174. % Print the greeting.
  175. /printgreeting
  176. { mark
  177. product (Ghostscript) search
  178. { pop pop pop
  179. (This software comes with NO WARRANTY: see the file PUBLIC for details.\n)
  180. }
  181. { pop
  182. }
  183. ifelse
  184. (\n) copyright
  185. (\)\n) revisiondate 10 mod revisiondate 10 idiv 10 mod (-)
  186. revisiondate 100 idiv 10 mod revisiondate 1000 idiv 10 mod (-)
  187. revisiondate 10000 idiv ( \()
  188. revision 10 mod
  189. revision 100 mod 10 idiv (.)
  190. revision 100 idiv ( )
  191. product
  192. counttomark
  193. { (%stdout) (w) file exch 0 .writecvp
  194. } repeat pop
  195. } .bind def
  196. QUIET not { printgreeting flush } if
  197. % Define a special version of def for making operator procedures.
  198. /obind { % <name> <proc> obind <name> <oper>
  199. 1 index exch .makeoperator
  200. } .bind def
  201. /odef { % <name> <proc> odef -
  202. 1 index exch .makeoperator def
  203. } .bind def
  204. % Define a special version of def for storing local objects into global
  205. % dictionaries. Like .forceput, this exists only during initialization.
  206. /.forcedef { % <key> <value> .forcedef -
  207. currentdict 3 1 roll .forceput
  208. } .bind odef
  209. % Define procedures for accessing variables in systemdict and userdict
  210. % regardless of the contents of the dictionary stack.
  211. /.systemvar { % <name> .systemvar <value>
  212. //systemdict exch get
  213. } .bind odef
  214. /.userdict { % - .userdict <dict>
  215. /userdict .systemvar
  216. } .bind odef
  217. /.uservar { % <name> .uservar <value>
  218. .userdict exch get
  219. } .bind odef
  220. % If we're delaying binding, remember everything that needs to be bound later.
  221. DELAYBIND NOBIND not and
  222. { .currentglobal false .setglobal
  223. systemdict /.delaybind 1500 array .forceput
  224. .setglobal
  225. userdict /.delaycount 0 put
  226. % When we've done the delayed bind, we want to stop saving.
  227. % Detect this by the disappearance of .delaybind.
  228. /bind
  229. { /.delaybind .systemvar dup length 0 ne
  230. { .delaycount 2 index put
  231. .userdict /.delaycount .delaycount 1 add put
  232. }
  233. { pop .bind
  234. }
  235. ifelse
  236. } .bind def
  237. } if
  238. %**************** BACKWARD COMPATIBILITY ****************
  239. /hwsizedict mark /HWSize null .dicttomark readonly def
  240. /copyscanlines { % <device> <y> <string> copyscanlines <substr>
  241. 0 3 1 roll 3 index //hwsizedict .getdeviceparams
  242. exch pop exch pop aload pop 3 2 roll
  243. 0 exch null exch .getbitsrect exch pop
  244. } bind odef
  245. currentdict /hwsizedict .undef
  246. /getdeviceprops
  247. { null .getdeviceparams
  248. } bind odef
  249. /.putdeviceprops
  250. { null true counttomark 1 add 3 roll .putdeviceparams
  251. dup type /booleantype ne
  252. { dup mark eq { /unknown /rangecheck } if
  253. counttomark 4 add 1 roll cleartomark pop pop pop
  254. /.putdeviceprops load exch signalerror
  255. }
  256. if
  257. } bind odef
  258. /.currentfilladjust { .currentfilladjust2 pop } bind odef
  259. /.setfilladjust { dup .setfilladjust2 } bind odef
  260. /.writecvs { 0 .writecvp } bind odef
  261. %**************** DEPRECATED PROCEDURES ****************
  262. %**************** DO NOT USE THESE IN NEW CODE ****************
  263. /max { .max } bind def % use .max instead
  264. /min { .min } bind def % use .min instead
  265. /unread /.unread load def % use .peekstring instead
  266. %**************** END OF BACKWARD COMPATIBILITY SECTION ****************
  267. % Define predefined procedures substituting for operators,
  268. % in alphabetical order.
  269. userdict /#copies 1 put
  270. % Adobe implementations don't accept /[ or /], so we don't either.
  271. ([) cvn
  272. /mark load def
  273. (]) cvn
  274. {counttomark array astore exch pop} odef
  275. % .beginpage is redefined if setpagedevice is present.
  276. /.beginpage { } odef
  277. % In LanguageLevel 3, copypage erases the page.
  278. /copypage {
  279. .languagelevel 3 ge
  280. dup { 0 } { 1 } ifelse .endpage {
  281. .currentnumcopies 1 index .outputpage
  282. (>>copypage, press <return> to continue<<\n) .confirm
  283. dup { erasepage } if
  284. } if pop .beginpage
  285. } odef
  286. /currentmatrix {
  287. .currentmatrix 6 index astore pop
  288. } odef
  289. % .currentnumcopies is redefined in Level 2.
  290. /.currentnumcopies { #copies } odef
  291. /setcolorscreen where { pop % not in all Level 1 configurations
  292. /currentcolorscreen
  293. { .currenthalftone
  294. { { 60 exch 0 exch 3 copy 6 copy } % halftone - not possible
  295. { 3 copy 6 copy } % screen
  296. { } % colorscreen
  297. }
  298. exch get exec
  299. } odef
  300. } if
  301. /currentscreen
  302. { .currenthalftone
  303. { { 60 exch 0 exch } % halftone - not possible
  304. { } % screen
  305. { 12 3 roll 9 { pop } repeat } % colorscreen
  306. }
  307. exch get exec
  308. } odef
  309. /.echo /echo load def
  310. userdict /.echo.mode true put
  311. /echo {dup /.echo.mode exch store .echo} odef
  312. /eexec {
  313. % Rebind .currentresourcefile if it is the source for the eexec.
  314. dup 55665 //filterdict /eexecDecode get exec
  315. cvx exch .currentresourcefile eq
  316. //systemdict begin { {exec} .execasresource } { exec } ifelse
  317. % Only pop systemdict if it is still the top element,
  318. % because this is apparently what Adobe interpreters do.
  319. currentdict //systemdict eq { end } if
  320. } odef
  321. % .endpage is redefined if setpagedevice is present.
  322. /.endpage { 2 ne } odef
  323. % erasepage mustn't use gsave/grestore, because we call it before
  324. % the graphics state stack has been fully initialized.
  325. /erasepage
  326. { /currentcolor where
  327. { pop currentcolor currentcolorspace { setcolorspace setcolor } }
  328. { /currentcmykcolor where
  329. { pop currentcmykcolor { setcmykcolor } }
  330. { currentrgbcolor { setrgbcolor } }
  331. ifelse
  332. }
  333. ifelse 1 setgray .fillpage exec
  334. } odef
  335. % To satisfy the Genoa FTS, executive must be a procedure, not an operator.
  336. /executive
  337. { { prompt
  338. { (%statementedit) (r) file } stopped
  339. { pop pop $error /errorname get /undefinedfilename eq
  340. { .clearerror exit } if % EOF
  341. handleerror null % ioerror??
  342. }
  343. if
  344. cvx { .runexec } execute
  345. } loop
  346. } bind def
  347. /filter
  348. { //filterdict 1 index .knownget
  349. { exch pop exec }
  350. { /filter load /undefined signalerror }
  351. ifelse
  352. } odef
  353. /handleerror
  354. { /errordict .systemvar /handleerror get exec } bind def
  355. /identmatrix [1.0 0.0 0.0 1.0 0.0 0.0] readonly def
  356. /identmatrix
  357. { dup 0 //identmatrix putinterval } odef
  358. /languagelevel 1 def % gs_lev2.ps may change this
  359. /makeimagedevice { false makewordimagedevice } odef
  360. /matrix { 6 array identmatrix } odef
  361. /pathbbox
  362. { false .pathbbox
  363. } odef
  364. % .promptmsg is redefined if the interpreter includes readline support.
  365. /.promptmsg {
  366. (GS) print
  367. count 0 ne { (<) print count =only } if
  368. (>) print flush
  369. } bind def
  370. /prompt { flush flushpage NOPROMPT not { .promptmsg } if } bind def
  371. /pstack { 0 1 count 3 sub { index == } for } bind def
  372. /putdeviceprops
  373. { .putdeviceprops { erasepage } if } odef
  374. /quit { /quit load 0 .quit } odef
  375. /run { dup type /filetype ne { (r) file } if
  376. % We must close the file when execution terminates,
  377. % regardless of the state of the stack,
  378. % and then propagate an error, if any.
  379. cvx .runexec
  380. } odef
  381. % Execute a file.
  382. % Level 2 uses 2 .stop to clear the e-stack for a successful startjob:
  383. % we detect that here, since we need to handle this even if we start out
  384. % without job control in effect.
  385. %
  386. % What we push on the e-stack is the following to be executed in this order:
  387. % <lit-file|fileproc> .runexec1 <lit-file|fileproc> .runexec2
  388. /.runexec1 { % <file|fileproc> .runexec1 -
  389. dup type /filetype ne { cvx exec } if
  390. cvx null 2 .stopped
  391. % If we got back here from a startjob, just keep going.
  392. % startjob replaces the null on the o-stack with a procedure
  393. % to be executed when we get back here.
  394. dup null ne { exec true } { pop false } ifelse
  395. } bind def
  396. /.runexec2 { % <continue> <file|fileproc> .runexec2 -
  397. exch {
  398. .runexec
  399. } {
  400. dup type /filetype ne { cvx exec } if
  401. closefile
  402. } ifelse
  403. } bind def
  404. /.runexec { % <file|fileproc> .runexec -
  405. cvlit /.runexec1 cvx 1 index /.runexec2 cvx 4 .execn
  406. } bind def
  407. % The following is only for compatibility with Adobe interpreters.
  408. /setdash {
  409. 1 index length 11 gt { /setdash load /limitcheck signalerror } if
  410. //setdash
  411. } odef
  412. /setdevice
  413. { .setdevice { erasepage } if } odef
  414. /setlinecap {
  415. dup 2 gt { /setlinecap load /rangecheck signalerror } if
  416. .setlinecap
  417. } odef
  418. /setlinejoin {
  419. dup 2 gt { /setlinejoin load /rangecheck signalerror } if
  420. .setlinejoin
  421. } odef
  422. /setmatrix {
  423. dup aload pop .setmatrix pop
  424. } odef
  425. /showpage {
  426. 0 .endpage .doneshowpage {
  427. .currentnumcopies true .outputpage
  428. (>>showpage, press <return> to continue<<\n) .confirm
  429. erasepage
  430. } if initgraphics .beginpage
  431. } odef
  432. % Code output by Adobe Illustrator relies on the fact that
  433. % `stack' is a procedure, not an operator!!!
  434. /stack { 0 1 count 3 sub { index = } for } bind def
  435. /start { BATCH { null 0 .quit } { executive } ifelse } def
  436. % Internal uses of stopped that aren't going to do a stop if an error occurs
  437. % should use .internalstopped to avoid setting newerror et al.
  438. /.internalstopped { null 1 .stopped null ne } bind def
  439. /store { % Don't alter operands before completing.
  440. 1 index where { 2 index 2 index put pop pop } { def } ifelse
  441. } odef
  442. /.typenames mark .typenames counttomark packedarray exch pop def
  443. /type {
  444. //.typenames .type
  445. } odef
  446. currentdict /.typenames .undef
  447. % When running in Level 1 mode, this interpreter is supposed to be
  448. % compatible with PostScript "version" 54.0 (I think).
  449. /version (54.0) readonly def
  450. /.wheredict 10 dict def
  451. /.where /where load def
  452. /where {
  453. //.wheredict 1 index .knownget { exec } { .where } ifelse
  454. } odef
  455. % internaldict is defined in systemdict, but the dictionary is allocated
  456. % in local VM. However, the procedure must be global, since it is an
  457. % "operator" and must be bind-able into global procedures.
  458. % We make a procedure for creating it, since we must create a new one
  459. % for each context with private local VM.
  460. /.makeinternaldict {
  461. .currentglobal true .setglobal
  462. [ /dup .systemvar 1183615869 /eq .systemvar
  463. [ /pop .systemvar null ] cvx
  464. false .setglobal
  465. dup 1 10 dict .forceput % proc is global, dict is local
  466. true .setglobal
  467. [ /internaldict /cvx .systemvar /invalidaccess /signalerror cvx ] cvx
  468. /ifelse .systemvar
  469. ] cvx executeonly
  470. exch .setglobal
  471. } odef
  472. systemdict /internaldict dup .makeinternaldict .makeoperator
  473. .forceput % proc is local, systemdict is global
  474. % Move superexec to internaldict if superexec is defined.
  475. currentdict /superexec .knownget {
  476. 1183615869 internaldict /superexec 3 -1 roll put
  477. currentdict /superexec .undef
  478. } if
  479. % Define some additional built-in procedures (beyond the ones defined by
  480. % the PostScript Language Reference Manual).
  481. % Warning: these are not guaranteed to stay the same from one release
  482. % to the next!
  483. /concatstrings % (str1) (str2) concatstrings (str1str2)
  484. { exch dup length 2 index length add string % str2 str1 new
  485. dup dup 4 2 roll copy % str2 new new new1
  486. length 4 -1 roll putinterval
  487. } bind def
  488. /copyarray
  489. { dup length array copy } bind def
  490. % Copy a dictionary per the Level 2 spec even in Level 1.
  491. /.copydict % <fromdict> <todict> .copydict <todict>
  492. { dup 3 -1 roll { put dup } forall pop } bind def
  493. /copystring
  494. { dup length string copy } bind def
  495. /findlibfile {
  496. .libfile { dup .filename pop exch true } { false } ifelse
  497. } odef
  498. /.growdictlength % get size for growing a dictionary
  499. { length 3 mul 2 idiv 1 add
  500. } bind def
  501. /.growdict % grow a dictionary
  502. { dup .growdictlength .setmaxlength
  503. } bind def
  504. /.growput % put, grow the dictionary if needed
  505. { 2 index length 3 index maxlength eq
  506. { 3 copy pop known not { 2 index .growdict } if
  507. } if
  508. put
  509. } bind def
  510. % .localvmarray may be an operator: see zsysvm.c.
  511. /.localvmarray where {
  512. pop
  513. } {
  514. /.localvmarray {
  515. .currentglobal false .setglobal
  516. exch array exch .setglobal
  517. } bind def
  518. } ifelse
  519. /.localvmdict where {
  520. pop
  521. } {
  522. /.localvmdict {
  523. .currentglobal false .setglobal
  524. exch dict exch .setglobal
  525. } bind def
  526. } ifelse
  527. /.packtomark
  528. { counttomark packedarray exch pop } bind def
  529. /ppstack
  530. { 0 1 count 3 sub { index === } for } bind def
  531. /runlibfile
  532. { % We don't want to bind 'run' into this procedure,
  533. % since run may get redefined.
  534. findlibfile
  535. { exch pop /run .systemvar exec }
  536. { /undefinedfilename signalerror }
  537. ifelse
  538. } bind def
  539. /selectdevice
  540. { finddevice setdevice .setdefaultscreen } bind def
  541. /signalerror % <object> <errorname> signalerror -
  542. { /errordict .systemvar exch get exec } bind def
  543. % Define the =[only] procedures. Also define =print,
  544. % which is used by some PostScript programs even though
  545. % it isn't documented anywhere.
  546. /write=only {
  547. .writecvs
  548. } bind def
  549. /write= {
  550. 1 index exch write=only (\n) writestring
  551. } bind def
  552. /=only { (%stdout) (w) file exch write=only } bind def
  553. /= { =only (\n) print } bind def
  554. /=print /=only load def
  555. % Temporarily define == as = for the sake of runlibfile0.
  556. /== /= load def
  557. % The following procedures are documented.
  558. /copydevice { % <device> copydevice <newdevice>
  559. false .copydevice2
  560. } odef
  561. /finddevice { % <devicename> finddevice <device>
  562. /devicedict .systemvar exch get
  563. dup 1 get null eq {
  564. % This is the first request for this type of device.
  565. % Create a default instance now.
  566. % Stack: [proto null]
  567. .currentglobal true .setglobal exch
  568. dup dup 0 get copydevice 1 exch put
  569. exch .setglobal
  570. } if 1 get
  571. } bind def
  572. /findprotodevice { % <devicename> findprotodevice <protodevice>
  573. /devicedict .systemvar exch get 0 get
  574. } bind def
  575. % Run a resource file. This allows us to distinguish resource objects
  576. % from objects coming from input files.
  577. userdict /.currentresourcefile null put
  578. /.execasresource { % <file> <proc|runfile> .execasresource -
  579. /stopped .systemvar
  580. /.currentresourcefile .uservar
  581. % Stack: file proc -stopped- currfile
  582. .userdict /.currentresourcefile 5 index cvlit put
  583. 2 .execn % stopped <file>
  584. .userdict /.currentresourcefile 3 -1 roll put
  585. { stop } if
  586. } bind def
  587. /.runresource { % <file> .runresource -
  588. { /run .systemvar exec } .execasresource
  589. } bind def
  590. % Define procedures for getting and setting the current device resolution.
  591. /gsgetdeviceprop % <device> <propname> gsgetdeviceprop <value>
  592. { 2 copy mark exch null .dicttomark .getdeviceparams
  593. dup mark eq % if true, not found
  594. { pop dup /undefined signalerror }
  595. { 5 1 roll pop pop pop pop }
  596. ifelse
  597. } bind def
  598. /gscurrentresolution % - gscurrentresolution <[xres yres]>
  599. { currentdevice /HWResolution gsgetdeviceprop
  600. } bind def
  601. /gssetresolution % <[xres yres]> gssetresolution -
  602. { 2 array astore mark exch /HWResolution exch
  603. currentdevice copydevice putdeviceprops setdevice
  604. } bind def
  605. % Define auxiliary procedures needed for the above.
  606. /shellarguments % -> shell_arguments true (or) false
  607. { /ARGUMENTS where
  608. { /ARGUMENTS get dup type /arraytype eq
  609. { aload pop /ARGUMENTS null store true }
  610. { pop false }
  611. ifelse }
  612. { false } ifelse
  613. } bind def
  614. /.confirm {
  615. DISPLAYING NOPAUSE not TTYPAUSE or and {
  616. % Print a message (unless NOPAGEPROMPT or NOPROMPT is true)
  617. % and wait for the user to type something.
  618. % If the user just types a newline, flush it.
  619. NOPAGEPROMPT NOPROMPT or { pop } { print flush } ifelse
  620. .confirmread
  621. } {
  622. pop
  623. } ifelse
  624. } bind def
  625. /.confirmread {
  626. TTYPAUSE {
  627. (/dev/tty) (r) file dup read pop pop closefile
  628. } {
  629. .echo.mode false echo
  630. (%stdin) (r) file dup read {
  631. dup (\n) 0 get eq { pop pop } { unread } ifelse
  632. } {
  633. pop
  634. } ifelse echo
  635. } ifelse
  636. } bind def
  637. % Define the procedure used by .runfile, .runstdin and .runstring
  638. % for executing user input.
  639. % This is called with a procedure or executable file on the operand stack.
  640. /.execute { % <obj> .execute <stopped>
  641. stopped $error /newerror get and
  642. { handleerror flush true } { false } ifelse
  643. } bind def
  644. /execute { % <obj> execute -
  645. .execute pop
  646. } odef
  647. % Define an execute analogue of runlibfile0.
  648. /execute0 { % <obj> execute0 -
  649. .execute { /execute0 cvx 1 .quit } if
  650. } bind def
  651. % Define the procedure that the C code uses for running files
  652. % named on the command line.
  653. /.runfile {
  654. { runlibfile } execute0
  655. } def
  656. % Define the procedure that the C code uses for running piped input.
  657. % We don't use the obvious { (%stdin) run }, because we want the file to be
  658. % reopened if a startjob does a restore.
  659. /.runstdin {
  660. { { (%stdin) (r) file cvx } .runexec } execute0
  661. } bind def
  662. % Define the procedure that the C code uses for running commands
  663. % given on the command line with -c. We turn the string into a file so that
  664. % .runexec can do the right thing with a startjob.
  665. /.runstring {
  666. .currentglobal exch true .setglobal
  667. 0 () .subfiledecode
  668. exch .setglobal cvx { .runexec } execute0
  669. } bind def
  670. % Define the procedure that the C code uses to set up for executing
  671. % a string that may be received in pieces.
  672. /.runstringbegin {
  673. .currentglobal true .setglobal
  674. { .needinput } bind 0 () .subfiledecode
  675. exch .setglobal cvx .runexec
  676. } bind def
  677. % Define a special version of runlibfile that aborts on errors.
  678. /runlibfile0
  679. { cvlit dup /.currentfilename exch def
  680. { findlibfile not { stop } if }
  681. stopped
  682. { (Can't find \(or open\) initialization file ) print
  683. .currentfilename == flush /runlibfile0 cvx 1 .quit
  684. } if
  685. exch pop cvx stopped
  686. { (While reading ) print .currentfilename print (:\n) print flush
  687. handleerror /runlibfile0 1 .quit
  688. } if
  689. } bind def
  690. % Temporarily substitute it for the real runlibfile.
  691. /.runlibfile /runlibfile load def
  692. /runlibfile /runlibfile0 load def
  693. % Create the error handling machinery.
  694. % Define the standard error handlers.
  695. % The interpreter has created the ErrorNames array.
  696. /.unstoppederrorhandler % <command> <errorname> .unstoppederrorhandler -
  697. { % This is the handler that gets used for recursive errors,
  698. % or errors outside the scope of a 'stopped'.
  699. 2 copy SHORTERRORS
  700. { (%%[ Error: ) print =only flush
  701. (; OffendingCommand: ) print =only ( ]%%) =
  702. }
  703. { (Unrecoverable error: ) print =only flush
  704. ( in ) print = flush
  705. count 2 gt
  706. { (Operand stack:\n ) print
  707. count 1 sub -1 2 { ( ) print index =only flush } for
  708. () = flush
  709. } if
  710. }
  711. ifelse
  712. -1 0 1 //ErrorNames length 1 sub
  713. { dup //ErrorNames exch get 3 index eq
  714. { not exch pop exit } { pop } ifelse
  715. }
  716. for exch pop .quit
  717. } bind def
  718. /.errorhandler % <command> <errorname> .errorhandler -
  719. { % Detect an internal 'stopped'.
  720. 1 .instopped { null eq { pop pop stop } if } if
  721. $error /.inerror get 1 .instopped { pop } { pop true } ifelse
  722. { .unstoppederrorhandler
  723. } if % detect error recursion
  724. $error /globalmode .currentglobal false .setglobal put
  725. $error /.inerror true put
  726. $error /newerror true put
  727. $error exch /errorname exch put
  728. $error exch /command exch put
  729. $error /recordstacks get $error /errorname get /VMerror ne and
  730. { % Attempt to store the stack contents atomically.
  731. count array astore dup $error /ostack 4 -1 roll
  732. countexecstack array execstack $error /estack 3 -1 roll
  733. countdictstack array dictstack $error /dstack 3 -1 roll
  734. put put put aload pop
  735. }
  736. { $error /dstack .undef
  737. $error /estack .undef
  738. $error /ostack .undef
  739. }
  740. ifelse
  741. $error /position currentfile status
  742. { currentfile { fileposition } .internalstopped { pop null } if
  743. }
  744. { % If this was a scanner error, the file is no longer current,
  745. % but the command holds the file, which may still be open.
  746. $error /command get dup type /filetype eq
  747. { { fileposition } .internalstopped { pop null } if }
  748. { pop null }
  749. ifelse
  750. }
  751. ifelse put
  752. % During initialization, we don't reset the allocation
  753. % mode on errors.
  754. $error /globalmode get $error /.nosetlocal get and .setglobal
  755. $error /.inerror false put
  756. stop
  757. } bind def
  758. % Define the standard handleerror. We break out the printing procedure
  759. % (.printerror) so that it can be extended for binary output
  760. % if the Level 2 facilities are present.
  761. /.printerror
  762. { $error begin
  763. /command load errorname SHORTERRORS
  764. { (%%[ Error: ) print =only flush
  765. (; OffendingCommand: ) print =only
  766. errorinfo dup null eq {
  767. pop
  768. } {
  769. (;\nErrorInfo:) print
  770. dup type /arraytype eq
  771. { { ( ) print =only } forall }
  772. { ( ) print =only }
  773. ifelse
  774. } ifelse
  775. ( ]%%) = flush
  776. }
  777. { (Error: ) print ==only flush
  778. ( in ) print ==only flush
  779. errorinfo dup null eq {
  780. pop
  781. } {
  782. (\nAdditional information: ) print ==only flush
  783. } ifelse
  784. .printerror_long
  785. }
  786. ifelse
  787. .clearerror
  788. end
  789. flush
  790. } bind def
  791. /.printerror_long % long error printout,
  792. % $error is on the dict stack
  793. { % Push the (anonymous) stack printing procedure.
  794. % <heading> <==flag> <override-name> <stackname> proc
  795. {
  796. currentdict exch .knownget % stackname defined in $error?
  797. {
  798. 4 1 roll % stack: <stack> <head> <==flag> <over>
  799. errordict exch .knownget % overridename defined?
  800. {
  801. exch pop exch pop exec % call override with <stack>
  802. }
  803. {
  804. exch print exch % print heading. stack <==flag> <stack>
  805. 1 index not { () = } if
  806. { 1 index { (\n ) } { ( ) } ifelse print
  807. dup type /dicttype eq
  808. {
  809. (--dict:) print
  810. dup rcheck {
  811. dup length =only (/) print dup maxlength =only
  812. dup wcheck not { ((ro)) print } if
  813. } if
  814. /gcheck where {
  815. pop gcheck { ((G)) } { ((L)) } ifelse print
  816. } {
  817. pop
  818. } ifelse (--) print
  819. }
  820. {
  821. dup type /stringtype eq 2 index or
  822. { ==only } { =only } ifelse
  823. } ifelse
  824. } forall
  825. pop
  826. }
  827. ifelse % overridden
  828. }
  829. { pop pop pop
  830. }
  831. ifelse % stack known
  832. }
  833. (\nOperand stack:) OSTACKPRINT /.printostack /ostack 4 index exec
  834. (\nExecution stack:) ESTACKPRINT /.printestack /estack 4 index exec
  835. (\nBacktrace:) true /.printbacktrace /backtrace 4 index exec
  836. (\nDictionary stack:) false /.printdstack /dstack 4 index exec
  837. () =
  838. pop % printing procedure
  839. errorname /VMerror eq
  840. { (VM status:) print mark vmstatus
  841. counttomark { ( ) print counttomark -1 roll dup =only } repeat
  842. cleartomark () =
  843. } if
  844. .languagelevel 2 ge
  845. { (Current allocation mode is ) print
  846. globalmode { (global\n) } { (local\n) } ifelse print
  847. } if
  848. .oserrno dup 0 ne
  849. { (Last OS error: ) print
  850. errorname /VMerror ne
  851. { dup .oserrorstring { = pop } { = } ifelse }
  852. { = }
  853. ifelse
  854. }
  855. { pop
  856. }
  857. ifelse
  858. position null ne
  859. { (Current file position is ) print position = }
  860. if
  861. } bind def
  862. % Define a procedure for clearing the error indication.
  863. /.clearerror
  864. { $error /newerror false put
  865. $error /errorname null put
  866. $error /errorinfo null put
  867. 0 .setoserrno
  868. } bind def
  869. % Define $error. This must be in local VM.
  870. .currentglobal false .setglobal
  871. /$error 40 dict .forcedef % $error is local, systemdict is global
  872. % newerror, errorname, command, errorinfo,
  873. % ostack, estack, dstack, recordstacks,
  874. % binary, globalmode,
  875. % .inerror, .nosetlocal, position,
  876. % plus extra space for badly designed error handers.
  877. $error begin
  878. /newerror false def
  879. /recordstacks true def
  880. /binary false def
  881. /globalmode .currentglobal def
  882. /.inerror false def
  883. /.nosetlocal true def
  884. /position null def
  885. end
  886. % Define errordict similarly. It has one entry per error name,
  887. % plus handleerror. However, some astonishingly badly written PostScript
  888. % files require it to have at least one empty slot.
  889. /errordict ErrorNames length 2 add dict
  890. .forcedef % errordict is local, systemdict is global
  891. .setglobal % contents of errordict are global
  892. errordict begin
  893. ErrorNames
  894. { mark 1 index systemdict /.errorhandler get /exec load .packtomark cvx def
  895. } forall
  896. % The handlers for interrupt and timeout are special; there is no
  897. % 'current object', so they push their own name.
  898. { /interrupt /timeout }
  899. { mark 1 index dup systemdict /.errorhandler get /exec load .packtomark cvx def
  900. } forall
  901. /handleerror
  902. { /.printerror .systemvar exec
  903. } bind def
  904. end
  905. % Define the [write]==[only] procedures.
  906. /.dict 8 dict dup
  907. begin def
  908. /.cvp {1 index exch 1 .writecvp} bind def
  909. /.p {1 index exch writestring} bind def
  910. /.p1 {2 index exch writestring} bind def
  911. /.p2 {3 index exch writestring} bind def
  912. /.print
  913. { dup type .dict exch .knownget { exec } { .cvp } ifelse
  914. } bind def
  915. /arraytype
  916. {dup rcheck
  917. {() exch dup xcheck
  918. {({) .p2
  919. {exch .p1
  920. 1 index exch .print pop ( )} forall
  921. (})}
  922. {([) .p2
  923. {exch .p1
  924. 1 index exch .print pop ( )} forall
  925. (])}
  926. ifelse exch pop .p}
  927. {.cvp}
  928. ifelse} bind def
  929. /packedarraytype /arraytype load def
  930. {//.dict begin .print pop end}
  931. bind
  932. end
  933. /write==only exch def
  934. /write== {1 index exch write==only (\n) writestring} bind def
  935. /==only { (%stdout) (w) file exch write==only } bind def
  936. /== {==only (\n) print} bind def
  937. % Define [write]===[only], an extension that prints dictionaries
  938. % in readable form and doesn't truncate strings.
  939. /.dict /write==only load 0 get dup length 2 add dict .copydict dup
  940. begin def
  941. /dicttype
  942. { dup rcheck
  943. { (<< ) .p1
  944. { 2 index 3 -1 roll .print pop ( ) .p1
  945. 1 index exch .print pop ( ) .p
  946. }
  947. forall (>>) .p
  948. }
  949. { .cvp
  950. }
  951. ifelse
  952. } bind def
  953. /stringtype
  954. { 1 index exch 2 .writecvp
  955. } bind def
  956. {//.dict begin .print pop end}
  957. bind
  958. end
  959. /write===only exch def
  960. /write=== {1 index exch write===only (\n) writestring} bind def
  961. /===only { (%stdout) (w) file exch write===only } bind def
  962. /=== { ===only (\n) print } bind def
  963. (END PROCS) VMDEBUG
  964. % Define the font directory.
  965. /FontDirectory false .setglobal 100 dict true .setglobal
  966. .forcedef % FontDirectory is local, systemdict is global
  967. % Define the encoding dictionary.
  968. /EncodingDirectory 16 dict def % enough for Level 2 + PDF standard encodings
  969. % Define .findencoding. (This is redefined in Level 2.)
  970. /.findencoding
  971. { //EncodingDirectory exch get exec
  972. } bind def
  973. /.defineencoding
  974. { //EncodingDirectory 3 1 roll put
  975. } bind def
  976. % If we've got the composite font extensions, define findencoding.
  977. % To satisfy the Genoa FTS, findencoding must be a procedure, not an operator.
  978. /rootfont where { pop /findencoding { .findencoding } def } if
  979. % Define .registerencoding.
  980. % NOTE: the name registeredencodings is known to (initialized by and shared
  981. % with) the interpreter.
  982. /.registerencoding { % <index> <array> .registerencoding -
  983. % Check that the array is indexable.
  984. % (It might still be a string, but then the .namestring will fail.)
  985. dup 0 0 getinterval pop
  986. % Check that all the elements of the array are names.
  987. dup { .namestring pop } forall
  988. % Do the store.
  989. //registeredencodings 2 index 2 index readonly put pop pop
  990. } bind odef
  991. systemdict /registeredencodings .undef
  992. % Load StandardEncoding.
  993. %% Replace 1 (gs_std_e.ps)
  994. (gs_std_e.ps) dup runlibfile VMDEBUG
  995. % Load ISOLatin1Encoding.
  996. %% Replace 1 (gs_il1_e.ps)
  997. (gs_il1_e.ps) dup runlibfile VMDEBUG
  998. % Define stubs for the Symbol and Dingbats encodings.
  999. % Note that the first element of the procedure must be the file name,
  1000. % since gs_lev2.ps extracts it to set up the Encoding resource category.
  1001. /SymbolEncoding { /SymbolEncoding .findencoding } bind def
  1002. %% Replace 3 (gs_sym_e.ps)
  1003. EncodingDirectory /SymbolEncoding
  1004. { (gs_sym_e.ps) //systemdict begin runlibfile SymbolEncoding end }
  1005. bind put
  1006. /DingbatsEncoding { /DingbatsEncoding .findencoding } bind def
  1007. %% Replace 3 (gs_dbt_e.ps)
  1008. EncodingDirectory /DingbatsEncoding
  1009. { (gs_dbt_e.ps) //systemdict begin runlibfile DingbatsEncoding end }
  1010. bind put
  1011. (END FONTDIR/ENCS) VMDEBUG
  1012. % Construct a dictionary of all available devices.
  1013. % These are (read-only) device prototypes that can't be
  1014. % installed or have their parameters changed. For this reason,
  1015. % the value in the dictionary is actually a 2-element writable array,
  1016. % to allow us to create a default instance of the prototype on demand.
  1017. % Loop until the .getdevice gets a rangecheck.
  1018. errordict /rangecheck 2 copy get
  1019. errordict /rangecheck { pop stop } put % pop the command
  1020. 0 { {dup .getdevice exch 1 add} loop} .internalstopped pop
  1021. 1 add dict /devicedict 1 index def
  1022. begin % 2nd copy of count is on stack
  1023. { dup .devicename exch
  1024. dup wcheck { dup } { null } ifelse 2 array astore def
  1025. } repeat
  1026. end
  1027. put % errordict /rangecheck
  1028. .clearerror
  1029. /devicenames devicedict { pop } forall devicedict length packedarray def
  1030. % Determine the default device.
  1031. /defaultdevice DISPLAYING
  1032. { systemdict /DEVICE .knownget
  1033. { devicedict 1 index known not
  1034. { (Unknown device: ) print =
  1035. flush /defaultdevice cvx 1 .quit
  1036. }
  1037. if
  1038. }
  1039. { 0 .getdevice .devicename
  1040. }
  1041. ifelse
  1042. }
  1043. { /nullpage
  1044. }
  1045. ifelse
  1046. /.defaultdevicename 1 index def
  1047. finddevice % make a copy
  1048. def
  1049. devicedict /Default devicedict .defaultdevicename get put
  1050. (END DEVS) VMDEBUG
  1051. % Define statusdict, for the benefit of programs
  1052. % that think they are running on a LaserWriter or similar printer.
  1053. %% Replace 1 (gs_statd.ps)
  1054. (gs_statd.ps) runlibfile
  1055. (END STATD) VMDEBUG
  1056. % Load the standard font environment.
  1057. %% Replace 1 (gs_fonts.ps)
  1058. (gs_fonts.ps) runlibfile
  1059. (END GS_FONTS) VMDEBUG
  1060. % Define the default halftone screen and BG/UCR functions now, so that
  1061. % it will bind in the original definitions of set[color]screen.
  1062. % We make this a procedure so we can call it again when switching devices.
  1063. % Use an ordered dither for low-resolution devices.
  1064. /.setloreshalftone { % <dpi> .setloreshalftone -
  1065. % The following 'ordered dither' spot function was contributed by
  1066. % Gregg Townsend. Thanks, Gregg!
  1067. 16.001 div 0 % not 16: avoids rounding problems
  1068. { 1 add 7.9999 mul cvi exch 1 add 7.9999 mul cvi 16 mul add <
  1069. 0E 8E 2E AE 06 86 26 A6 0C 8C 2C AC 04 84 24 A4
  1070. CE 4E EE 6E C6 46 E6 66 CC 4C EC 6C C4 44 E4 64
  1071. 3E BE 1E 9E 36 B6 16 96 3C BC 1C 9C 34 B4 14 94
  1072. FE 7E DE 5E F6 76 D6 56 FC 7C DC 5C F4 74 D4 54
  1073. 01 81 21 A1 09 89 29 A9 03 83 23 A3 0B 8B 2B AB
  1074. C1 41 E1 61 C9 49 E9 69 C3 43 E3 63 CB 4B EB 6B
  1075. 31 B1 11 91 39 B9 19 99 33 B3 13 93 3B BB 1B 9B
  1076. F1 71 D1 51 F9 79 D9 59 F3 73 D3 53 FB 7B DB 5B
  1077. 0D 8D 2D AD 05 85 25 A5 0F 8F 2F AF 07 87 27 A7
  1078. CD 4D ED 6D C5 45 E5 65 CF 4F EF 6F C7 47 E7 67
  1079. 3D BD 1D 9D 35 B5 15 95 3F BF 1F 9F 37 B7 17 97
  1080. FD 7D DD 5D F5 75 D5 55 FF 7F DF 5F F7 77 D7 57
  1081. 02 82 22 A2 0A 8A 2A AA 00 80 20 A0 08 88 28 A8
  1082. C2 42 E2 62 CA 4A EA 6A C0 40 E0 60 C8 48 E8 68
  1083. 32 B2 12 92 3A BA 1A 9A 30 B0 10 90 38 B8 18 98
  1084. F2 72 D2 52 FA 7A DA 5A F0 70 D0 50 F8 78 D8 58
  1085. > exch get 256 div
  1086. }
  1087. bind
  1088. % Use correct, per-plane screens for CMYK devices only.
  1089. //systemdict /setcolorscreen known processcolors 4 eq and
  1090. { 3 copy 6 copy //setcolorscreen }
  1091. { //setscreen }
  1092. ifelse
  1093. } bind def
  1094. /.setloresscreen { % <dpi> .setloresscreen -
  1095. .setloreshalftone
  1096. 0 array cvx settransfer % Genoa CET won't accept a packed array!
  1097. /setstrokeadjust where { pop true setstrokeadjust } if
  1098. } bind def
  1099. % Use a 45-degree spot screen for high-resolution devices.
  1100. /.sethireshalftone { % <dpi> .sethireshalftone <doscreen>
  1101. % According to information published by Hewlett-Packard,
  1102. % they use a 60 line screen on 300 DPI printers and
  1103. % an 85 line screen on 600 DPI printers.
  1104. % However, we use a 106 line screen, which produces smoother-
  1105. % looking shades but fewer of them (32 vs. 50).
  1106. % 46 was suggested as a good frequency value for printers
  1107. % between 200 and 400 DPI, so we use it for lower resolutions.
  1108. % Imagesetters need even higher frequency screens.
  1109. //systemdict /DITHERPPI known
  1110. { DITHERPPI
  1111. }
  1112. { dup cvi 100 idiv 15 .min
  1113. {null 46 46 60 60 60 106 106 106 106 133 133 133 133 133 150}
  1114. exch get
  1115. }
  1116. ifelse
  1117. 1 index 4.01 div .min % at least a 4x4 cell
  1118. 45
  1119. % The following screen algorithm is used by permission of the author.
  1120. { 1 add 180 mul cos 1 0.08 add mul exch 2 add 180 mul cos
  1121. 1 0.08 sub mul add 2 div % (C) 1989 Berthold K.P. Horn
  1122. }
  1123. bind
  1124. % Determine whether we have lots of process colors.
  1125. % If so, don't bother with color screening or gamma correction.
  1126. % Also don't do gamma correction on very high-resolution devices.
  1127. % (This should depend on dot gain, not resolution, but we don't
  1128. % currently have a way to determine this.)
  1129. currentdevice mark
  1130. /RedValues 0 /GreenValues 0 /BlueValues 0 /GrayValues 0
  1131. .dicttomark .getdeviceparams
  1132. counttomark 2 idiv 1 sub { exch pop min } repeat
  1133. exch pop exch pop 32 lt 4 index 800 lt and 5 1 roll
  1134. % Stack: doscreen dpi freq angle proc
  1135. % Ghostscript currently doesn't use correct, per-plane halftones
  1136. % unless setcolorscreen has been executed. Since these are
  1137. % computationally much more expensive than binary halftones,
  1138. % we check to make sure they are really warranted, i.e., we have
  1139. % a high-resolution CMYK device (i.e., not a display) with
  1140. % fewer than 5 bits per plane (i.e., not a true-color device).
  1141. 4 -1 roll 150 ge
  1142. { /setcolorscreen where
  1143. { pop //systemdict /COLORSCREEN known
  1144. { COLORSCREEN }
  1145. { 3 index }
  1146. ifelse
  1147. dup false ne
  1148. { 4 1 roll 3 copy 6 copy 13 -1 roll
  1149. % For really high-quality screening on printers, we need to
  1150. % give each plane its own screen angle. Unfortunately,
  1151. % this currently has very large space and time costs.
  1152. true eq % true => different angles,
  1153. % 0 => same angles
  1154. { { 45 90 15 75 } { 3 1 roll exch pop 12 3 roll } forall
  1155. }
  1156. if //setcolorscreen
  1157. }
  1158. { pop //setscreen % false => single binary screen
  1159. }
  1160. ifelse
  1161. }
  1162. { //setscreen % setcolorscreen not known
  1163. }
  1164. ifelse
  1165. }
  1166. { //setscreen % not high resolution
  1167. }
  1168. ifelse
  1169. } bind def
  1170. /.sethiresscreen { % <dpi> .sethiresscreen -
  1171. .sethireshalftone
  1172. % Stack: doscreen
  1173. { % Set the transfer function to lighten up the grays.
  1174. % We correct at the high end so that very light grays
  1175. % don't disappear completely if they darken <1 screen pixel.
  1176. % Parameter values closer to 1 are better for devices with
  1177. % less dot spreading; lower values are better with more spreading.
  1178. % The value 0.8 is a compromise that will probably please no one!
  1179. %
  1180. % Because of a bug in FrameMaker, we have to accept operands
  1181. % outside the valid range of [0..1].
  1182. { dup dup 0.0 gt exch 1.0 lt and
  1183. { 0.8 exp dup dup 0.9375 gt exch 0.999 lt and % > 15/16
  1184. { .currentscreenlevels 1 sub % tweak to avoid boundary
  1185. 1 exch div 1 exch sub .min
  1186. }
  1187. if
  1188. }
  1189. if
  1190. }
  1191. }
  1192. { % Set the transfer function to the identity.
  1193. 0 array cvx % Genoa CET won't accept a packed array!
  1194. }
  1195. ifelse settransfer
  1196. /setstrokeadjust where { pop false setstrokeadjust } if
  1197. % Increase fill adjustment so that we effectively use Adobe's
  1198. % any-part-of-pixel rule.
  1199. 0.5 .setfilladjust
  1200. } bind def
  1201. % Set the default screen and BG/UCR.
  1202. /.setdefaultbgucr {
  1203. systemdict /setblackgeneration known {
  1204. { pop 0 } dup setblackgeneration setundercolorremoval
  1205. } if
  1206. } bind def
  1207. /.useloresscreen { % - .useloresscreen <bool>
  1208. % Compute min(|dpi x|,|dpi y|) as the definition of the resolution.
  1209. 72 72 matrix defaultmatrix dtransform abs exch abs .min
  1210. dup 150 lt //systemdict /DITHERPPI known not and
  1211. } bind def
  1212. % The following implementation uses LL2 extensions, but only in stopped
  1213. % contexts so that with LL1, the .set??reshalftone will be used.
  1214. %
  1215. % - .getdefaulthalftone <halftonedict> true if default found
  1216. % false
  1217. /.getdefaulthalftone {
  1218. % try the device to see if it has a default halftone
  1219. { currentdevice /HalftoneDefault gsgetdeviceprop } stopped
  1220. { pop pop false } % no device property
  1221. { dup type /dicttype eq { true } { pop false } ifelse }
  1222. ifelse
  1223. % stack: <halftonedict> true if default found
  1224. % false not found
  1225. dup not
  1226. { % device did not provide a default, try Resource
  1227. pop { /Default /Halftone /findresource .systemvar exec } stopped
  1228. { pop pop false } { true } ifelse
  1229. }
  1230. if
  1231. } bind def
  1232. /.setdefaulthalftone {
  1233. .getdefaulthalftone
  1234. { sethalftone }
  1235. { % default not found
  1236. .useloresscreen { .setloreshalftone } { .sethireshalftone pop } ifelse
  1237. }
  1238. ifelse
  1239. } bind def
  1240. /.setdefaultscreen {
  1241. .useloresscreen { .setloresscreen } { .sethiresscreen } ifelse
  1242. .setdefaultbgucr
  1243. } bind def
  1244. % Load the initialization files for optional features.
  1245. %% Replace 4 INITFILES
  1246. systemdict /INITFILES known
  1247. { INITFILES { dup runlibfile VMDEBUG } forall
  1248. }
  1249. if
  1250. % If Level 2 (or higher) functionality is implemented, enable it now.
  1251. /.setlanguagelevel where {
  1252. pop 2 .setlanguagelevel
  1253. % If the resource machinery is loaded, fix up some things now.
  1254. /.fixresources where { pop .fixresources } if
  1255. } if
  1256. /ll3dict where {
  1257. pop 3 .setlanguagelevel
  1258. } if
  1259. (END INITFILES) VMDEBUG
  1260. % Create a null font. This is the initial font.
  1261. 8 dict dup begin
  1262. /FontMatrix [ 1 0 0 1 0 0 ] readonly def
  1263. /FontType 3 def
  1264. /FontName () def
  1265. /Encoding StandardEncoding def
  1266. /FontBBox { 0 0 0 0 } readonly def % executable is bogus, but customary ...
  1267. /BuildChar { pop pop 0 0 setcharwidth } bind def
  1268. /PaintType 0 def % shouldn't be needed!
  1269. end
  1270. /NullFont exch definefont setfont
  1271. % Define NullFont as the font.
  1272. /NullFont currentfont def
  1273. % Load initial fonts from FONTPATH directories, Fontmap file,
  1274. % and/or .getccfont as appropriate.
  1275. .loadinitialfonts
  1276. % Remove NullFont from FontDirectory, so it can't be accessed by mistake.
  1277. /undefinefont where {
  1278. pop /NullFont undefinefont
  1279. } {
  1280. FontDirectory /NullFont .undef
  1281. } ifelse
  1282. (END FONTS) VMDEBUG
  1283. % Restore the real definition of runlibfile.
  1284. /runlibfile /.runlibfile load def
  1285. currentdict /.runlibfile .undef
  1286. % Bind all the operators defined as procedures.
  1287. /.bindoperators % binds operators in currentdict
  1288. { % Temporarily disable the typecheck error.
  1289. errordict /typecheck 2 copy get
  1290. errordict /typecheck { pop } put % pop the command
  1291. currentdict
  1292. { dup type /operatortype eq
  1293. { % This might be a real operator, so bind might cause a typecheck,
  1294. % but we've made the error a no-op temporarily.
  1295. .bind % do a real bind even if NOBIND is set
  1296. }
  1297. if pop pop
  1298. } forall
  1299. put
  1300. } def
  1301. NOBIND DELAYBIND or not { .bindoperators } if
  1302. % Establish a default environment.
  1303. defaultdevice
  1304. % The following line used to skip setting of page size and resolution if
  1305. % NODISPLAY was selected. We think this was only to save time and memory,
  1306. % and it is a bad idea because it prevents setting the resolution in this
  1307. % situation, which pstoedit (among other programs) relies on.
  1308. %DISPLAYING not { setdevice (%END DISPLAYING) .skipeof } if
  1309. systemdict /DEVICEWIDTH known
  1310. systemdict /DEVICEHEIGHT known or
  1311. systemdict /DEVICEWIDTHPOINTS known or
  1312. systemdict /DEVICEHEIGHTPOINTS known or
  1313. systemdict /DEVICEXRESOLUTION known or
  1314. systemdict /DEVICEYRESOLUTION known or
  1315. systemdict /PAPERSIZE known or
  1316. not { (%END DEVICE) .skipeof } if
  1317. % Let DEVICE{WIDTH,HEIGHT}[POINTS] override PAPERSIZE.
  1318. systemdict /PAPERSIZE known
  1319. systemdict /DEVICEWIDTH known not and
  1320. systemdict /DEVICEHEIGHT known not and
  1321. systemdict /DEVICEWIDTHPOINTS known not and
  1322. systemdict /DEVICEHEIGHTPOINTS known not and
  1323. { % Convert the paper size to device dimensions.
  1324. true statusdict /.pagetypenames get
  1325. { PAPERSIZE eq
  1326. { PAPERSIZE load
  1327. dup 0 get /DEVICEWIDTHPOINTS exch def
  1328. 1 get /DEVICEHEIGHTPOINTS exch def
  1329. pop false exit
  1330. }
  1331. if
  1332. }
  1333. forall
  1334. { (Unknown paper size: ) print PAPERSIZE ==only (.) =
  1335. }
  1336. if
  1337. }
  1338. if
  1339. % Adjust the device parameters per the command line.
  1340. % It is possible to specify resolution, pixel size, and page size;
  1341. % since any two of these determine the third, conflicts are possible.
  1342. % We simply pass them to .setdeviceparams and let it sort things out.
  1343. mark /HWResolution null /HWSize null /PageSize null .dicttomark
  1344. .getdeviceparams .dicttomark begin
  1345. mark
  1346. % Check for resolution.
  1347. /DEVICEXRESOLUTION where dup
  1348. { exch pop HWResolution 0 DEVICEXRESOLUTION put }
  1349. if
  1350. /DEVICEYRESOLUTION where dup
  1351. { exch pop HWResolution 1 DEVICEYRESOLUTION put }
  1352. if
  1353. or { /HWResolution HWResolution } if
  1354. % Check for device sizes specified in pixels.
  1355. /DEVICEWIDTH where dup
  1356. { exch pop HWSize 0 DEVICEWIDTH put }
  1357. if
  1358. /DEVICEHEIGHT where dup
  1359. { exch pop HWSize 1 DEVICEHEIGHT put }
  1360. if
  1361. or { /HWSize HWSize } if
  1362. % Check for device sizes specified in points.
  1363. /DEVICEWIDTHPOINTS where dup
  1364. { exch pop PageSize 0 DEVICEWIDTHPOINTS put }
  1365. if
  1366. /DEVICEHEIGHTPOINTS where dup
  1367. { exch pop PageSize 1 DEVICEHEIGHTPOINTS put }
  1368. if
  1369. or { /PageSize PageSize } if
  1370. % Check whether any parameters were set.
  1371. dup mark eq { pop } { defaultdevice putdeviceprops } ifelse
  1372. end
  1373. %END DEVICE
  1374. % Set any device properties defined on the command line.
  1375. % If BufferSpace is defined but not MaxBitmap, set MaxBitmap to BufferSpace.
  1376. systemdict /BufferSpace known
  1377. systemdict /MaxBitmap known not and
  1378. { systemdict /MaxBitmap BufferSpace put
  1379. } if
  1380. dup getdeviceprops
  1381. counttomark 2 idiv
  1382. { systemdict 2 index known
  1383. { pop dup load counttomark 2 roll }
  1384. { pop pop }
  1385. ifelse
  1386. } repeat
  1387. counttomark dup 0 ne
  1388. { 2 add -1 roll putdeviceprops }
  1389. { pop pop }
  1390. ifelse
  1391. % If the initial device parameters are invalid, the setdevice may fail.
  1392. % Trap this and produce a reasonable error message.
  1393. { setdevice } % does an erasepage
  1394. DEBUG { exec false } { .internalstopped } ifelse {
  1395. (**** Unable to open the initial device, quitting.) = flush 1 .quit
  1396. } if
  1397. % If the media size is fixed, update the current page device dictionary.
  1398. FIXEDMEDIA
  1399. dup { pop systemdict /.currentpagedevice known } if
  1400. dup { pop .currentpagedevice exch pop } if
  1401. not { (%END MEDIA) .skipeof } if
  1402. currentpagedevice dup length dict .copydict
  1403. dup /Policies
  1404. % Stack: <pagedevice> <pagedevice> /Policies
  1405. 1 index /InputAttributes
  1406. 2 copy get dup length dict .copydict
  1407. % Stack: <pagedevice> <pagedevice> /Policies <pagedevice>
  1408. % /InputAttributes <inputattrs'>
  1409. dup 0 2 copy get dup length dict .copydict
  1410. % Stack: <pagedevice> <pagedevice> /Policies <pagedevice>
  1411. % /InputAttributes <inputattrs'> <inputattrs'> 0 <attrs0'>
  1412. dup /PageSize 7 index /PageSize get
  1413. put % PageSize in 0
  1414. put % 0 in InputAttributes
  1415. put % InputAttributes in pagedevice
  1416. % Also change the page size policy so we don't get an error.
  1417. % Stack: <pagedevice> <pagedevice> /Policies
  1418. 2 copy get dup length dict .copydict
  1419. % Stack: <pagedevice> <pagedevice> /Policies <policies'>
  1420. dup /PageSize 7 put % PageSize in Policies
  1421. put % Policies in pagedevice
  1422. .setpagedevice
  1423. %END MEDIA
  1424. %END DISPLAYING
  1425. (END DEVICE) VMDEBUG
  1426. % Establish a default upper limit in the character cache,
  1427. % namely, enough room for a 18-point character at the resolution
  1428. % of the default device, or for a character consuming 1% of the
  1429. % maximum cache size, whichever is larger.
  1430. mark
  1431. % Compute limit based on character size.
  1432. 18 dup dtransform
  1433. exch abs cvi 31 add 32 idiv 4 mul % X raster
  1434. exch abs cvi mul % Y
  1435. % Compute limit based on allocated space.
  1436. cachestatus pop pop pop pop pop exch pop 0.01 mul cvi
  1437. .max dup 10 idiv exch
  1438. setcacheparams
  1439. % Conditionally disable the character cache.
  1440. NOCACHE { 0 setcachelimit } if
  1441. (END CONFIG) VMDEBUG
  1442. % Initialize graphics.
  1443. .setdefaultscreen
  1444. initgraphics
  1445. % The interpreter relies on there being at least 2 entries
  1446. % on the graphics stack. Establish the second one now.
  1447. gsave
  1448. % Define some control sequences as no-ops.
  1449. % This is a hack to get around problems
  1450. % in some common PostScript-generating applications.
  1451. <04> cvn { } def % Apple job separator
  1452. <0404> cvn { } def % two of the same
  1453. <1b> cvn { } def % MS Windows LaserJet 4 prologue
  1454. % (UEL = ESC %-12345X)
  1455. <1b45> cvn { } def % PJL reset prologue (ESC E)
  1456. <1b451b> cvn { } def % PJL reset epilogue (ESC E + UEL)
  1457. <041b> cvn { } def % MS Windows LaserJet 4 epilogue (^D + UEL)
  1458. (\001M) cvn % TBCP initiator
  1459. { currentfile /TBCPDecode filter cvx exec
  1460. } bind def
  1461. /@PJL % H-P job control
  1462. { currentfile //=string readline { pop } if
  1463. } bind def
  1464. % If we want a "safer" system, disable some obvious ways to cause havoc.
  1465. .currentglobal true .setglobal
  1466. /SAFETY 2 dict
  1467. dup /safe false put
  1468. dup /tempfiles 10 dict readonly put
  1469. readonly def
  1470. .setglobal
  1471. % Convert a path name into a string suitable for filenameforall
  1472. % For example: (a\\b*?c) to (a\\\\b\\*\\?c)
  1473. /.makepathtemplate { % str1 -- str2
  1474. dup length dup add string 0 % result string up to twice the size
  1475. 0 1 4 index length 1 sub {
  1476. 3 index exch get
  1477. dup 92 eq { % \ -> \\
  1478. 2 index 2 index 92
  1479. put
  1480. exch 1 add exch
  1481. }
  1482. if
  1483. dup 42 eq { % * -> \*
  1484. 2 index 2 index 92
  1485. put
  1486. exch 1 add exch
  1487. }
  1488. if
  1489. dup 63 eq { % ? -> \?
  1490. 2 index 2 index 92
  1491. put
  1492. exch 1 add exch
  1493. }
  1494. if
  1495. 2 index 2 index 3 -1 roll put 1 add
  1496. } for
  1497. 0 exch getinterval exch pop
  1498. } bind def
  1499. /.locksafe {
  1500. SAFETY /safe get not {
  1501. <<
  1502. /PermitFileReading [
  1503. currentuserparams /PermitFileReading get aload pop
  1504. { .makepathtemplate
  1505. dup .filenamedirseparator concatstrings (*) concatstrings
  1506. exch % put string below this procedure
  1507. }
  1508. /LIBPATH .systemvar { 1 index exec } forall
  1509. /FONTPATH .systemvar { 1 index exec } forall
  1510. currentsystemparams /GenericResourceDir get 1 index exec
  1511. currentsystemparams /FontResourceDir get exch exec
  1512. ]
  1513. /LockFilePermissions true
  1514. >> setuserparams
  1515. }
  1516. if
  1517. mark /.LockSafetyParams true currentdevice .putdeviceprops pop pop
  1518. //SAFETY /safe //true .forceput % overrides readonly
  1519. } .bind executeonly odef
  1520. /.setsafe
  1521. {
  1522. SAFETY /safe get not {
  1523. <<
  1524. PARANOIDSAFER { % only PARANOIDSAFER locks down reading files
  1525. /PermitFileReading [ ]
  1526. } if
  1527. /PermitFileWriting [ (/fd/*) ]
  1528. /PermitFileControl [ ]
  1529. >> setuserparams
  1530. }
  1531. if
  1532. .locksafe
  1533. } .bind executeonly odef
  1534. /deletefile {
  1535. count 1 lt {
  1536. //deletefile /stackunderflow signalerror
  1537. }
  1538. if
  1539. dup { deletefile } stopped {
  1540. pop //deletefile $error /errorname get signalerror
  1541. } {
  1542. % deletefile succeeded. Remove from tempfile list if present
  1543. //SAFETY /tempfiles get exch cvn 2 copy known {
  1544. .forceundef
  1545. } {
  1546. pop pop
  1547. }
  1548. ifelse
  1549. }
  1550. ifelse
  1551. } .bind executeonly odef
  1552. % If a file is opened with .tempfile with SAFER not (yet) set,
  1553. % the file can be deleted later, even if SAFER is set.
  1554. /.tempfile {
  1555. .tempfile % filename file
  1556. //SAFETY /tempfiles get 2 index true .forceput
  1557. } .bind executeonly odef
  1558. % If we are running in SAFER mode, lock things down
  1559. SAFER { .setsafe } if
  1560. % If we delayed binding, make it possible to do it later.
  1561. /.bindnow {
  1562. //systemdict begin .bindoperators end
  1563. % Temporarily disable the typecheck error.
  1564. errordict /typecheck 2 copy get
  1565. errordict /typecheck { pop } put % pop the command
  1566. 0 1 .delaycount 1 sub { .delaybind exch get .bind pop } for
  1567. //systemdict /.delaybind {} .forceput % reclaim the space
  1568. //systemdict /.bindnow .forceundef % ditto
  1569. put
  1570. //systemdict /.forcedef .forceundef % remove temptation
  1571. //systemdict /.forceput .forceundef % ditto
  1572. //systemdict /.forceundef .forceundef % ditto
  1573. } .bind odef
  1574. % Turn off array packing, since some PostScript code assumes that
  1575. % procedures are writable.
  1576. false setpacking
  1577. (END INIT) VMDEBUG
  1578. /.currentuserparams where {
  1579. pop
  1580. % Remove real user params from psuserparams.
  1581. mark .currentuserparams counttomark 2 idiv {
  1582. pop psuserparams exch undef
  1583. } repeat pop
  1584. % Update the copy of the user parameters.
  1585. mark .currentuserparams counttomark 2 idiv {
  1586. userparams 3 1 roll .forceput % userparams is read-only
  1587. } repeat pop
  1588. % Turn on idiom recognition, if available.
  1589. currentuserparams /IdiomRecognition known {
  1590. /IdiomRecognition true .definepsuserparam
  1591. } if
  1592. psuserparams readonly pop
  1593. systemdict /.definepsuserparam undef
  1594. % Save a copy of userparams for use with save/restore
  1595. % (and, if implemented, context switching).
  1596. .currentglobal false .setglobal
  1597. mark userparams { } forall .dicttomark readonly
  1598. /userparams exch .forcedef % systemdict is read-only
  1599. .setglobal
  1600. } if
  1601. /.currentsystemparams where {
  1602. pop
  1603. % Remove real system params from pssystemparams.
  1604. mark .currentsystemparams counttomark 2 idiv {
  1605. pop pssystemparams exch .forceundef
  1606. } repeat pop
  1607. } if
  1608. % Conditionally turn image interpolation on or off.
  1609. currentdict /INTERPOLATE known not { (%END INTERPOLATE) .skipeof } if
  1610. /.interpolate {
  1611. dup /Interpolate .knownget not { //false } if
  1612. /INTERPOLATE .systemvar ne {
  1613. dup gcheck .currentglobal exch .setglobal
  1614. exch dup length dict copy
  1615. dup /Interpolate /INTERPOLATE .systemvar put
  1616. exch .setglobal
  1617. } if
  1618. } bind odef
  1619. /colorimage
  1620. { /INTERPOLATE .systemvar
  1621. { .currentglobal % w h bit [] {}...{} multi ncomp glob
  1622. //false .setglobal
  1623. 9 dict begin % w h bit [] {}...{} multi ncomp glob
  1624. 2 index { 1 index 7 add } { 8 } ifelse
  1625. copy gsave pop % preserve the arguments
  1626. { 0 /DeviceGray 0 /DeviceRGB /DeviceCMYK }
  1627. 1 index get setcolorspace % ... glob w h bit [] {}...{} multi ncomp
  1628. {0 1 0 1 0 1 0 1}
  1629. 1 index 2 mul 0 exch % ... glob w h bit [] {}...{} multi ncomp {0 1 ...} 0 2*ncomp
  1630. getinterval /Decode exch def % ... glob w h bit [] {}...{} multi ncomp
  1631. exch dup % ... glob w h bit [] {}...{} ncomp multi multi
  1632. /MultipleDataSources exch def % ... glob w h bit [] {}...{} ncomp multi
  1633. { array astore} { pop } ifelse % ... glob w h bit [] [{}...{}]
  1634. /DataSource exch def % ... glob w h bit []
  1635. /ImageMatrix exch def % ... glob w h bit
  1636. /BitsPerComponent exch def % ... glob w h
  1637. /Height exch def % ... glob w
  1638. /Width exch def % ... glob
  1639. /ImageType 1 def
  1640. /Interpolate //true def
  1641. .setglobal currentdict end % ... <<>>
  1642. image grestore
  1643. exch { 4 add } { 6 } ifelse
  1644. { pop } repeat % -
  1645. }
  1646. { colorimage
  1647. }
  1648. ifelse
  1649. } bind odef
  1650. /image
  1651. { dup type /dicttype eq
  1652. { dup /ImageType get 3 eq
  1653. { .currentglobal //false .setglobal exch
  1654. dup length dict copy begin .setglobal
  1655. /DataDict DataDict .interpolate def
  1656. /MaskDict MaskDict .interpolate def
  1657. currentdict end
  1658. }
  1659. { .interpolate
  1660. }
  1661. ifelse
  1662. image
  1663. }
  1664. { /INTERPOLATE .systemvar
  1665. { .currentglobal //false .setglobal
  1666. 8 dict begin .setglobal
  1667. /ImageType 1 def
  1668. /DataSource 1 index def
  1669. /ImageMatrix 2 index def
  1670. /BitsPerComponent 3 index def
  1671. /Decode {0 1} def
  1672. /Height 4 index def
  1673. /Width 5 index def
  1674. /Interpolate //true def
  1675. currentdict end
  1676. gsave /DeviceGray setcolorspace image grestore
  1677. 5 { pop } repeat
  1678. }
  1679. { image
  1680. }
  1681. ifelse
  1682. }
  1683. ifelse
  1684. } bind odef
  1685. /imagemask {
  1686. dup type /dicttype eq {
  1687. .interpolate imagemask
  1688. } {
  1689. /INTERPOLATE .systemvar {
  1690. .currentglobal //false .setglobal
  1691. 8 dict begin .setglobal
  1692. /ImageType 1 def
  1693. /DataSource 1 index def
  1694. /ImageMatrix 2 index def
  1695. /BitsPerComponent 1 def
  1696. 2 index { {1 0} } { {0 1} } ifelse /Decode exch def
  1697. /Height 4 index def
  1698. /Width 5 index def
  1699. /Interpolate //true def
  1700. currentdict end imagemask 5 { pop } repeat
  1701. } {
  1702. imagemask
  1703. } ifelse
  1704. } ifelse
  1705. } bind odef
  1706. currentdict /.interpolate undef
  1707. %END INTERPOLATE
  1708. % Establish local VM as the default.
  1709. false /setglobal where { pop setglobal } { .setglobal } ifelse
  1710. $error /.nosetlocal false put
  1711. (END GLOBAL) VMDEBUG
  1712. /.savelocalstate where {
  1713. % If we might create new contexts, save away copies of all dictionaries
  1714. % referenced from systemdict that are stored in local VM,
  1715. % and also save a copy of the initial gstate.
  1716. pop .savelocalstate
  1717. } {
  1718. % If we're *not* running in a multi-context system and FAKEFONTS is
  1719. % defined, add the fake fonts to LocalFontDirectory.
  1720. .definefakefonts % current VM is local
  1721. } ifelse
  1722. % Remove systemdict entries for things that have been bound in where used
  1723. % and that shouldn't be accessible by name, and close up systemdict.
  1724. currentdict /filterdict .undef
  1725. currentdict /.cidfonttypes .undef
  1726. currentdict /.colorrenderingtypes .undef
  1727. currentdict /.formtypes .undef
  1728. currentdict /.halftonetypes .undef
  1729. currentdict /.imagetypes .undef
  1730. currentdict /.imagemasktypes .undef
  1731. currentdict /.patterntypes .undef
  1732. currentdict /.shadingtypes .undef
  1733. currentdict /.wheredict .undef
  1734. end
  1735. % Clean up VM, and enable GC.
  1736. /vmreclaim where
  1737. { pop NOGC not { 2 vmreclaim 0 vmreclaim } if
  1738. } if
  1739. DELAYBIND not {
  1740. systemdict /.forcedef .undef % remove temptation
  1741. systemdict /.forceput .undef % ditto
  1742. systemdict /.forceundef .undef % ditto
  1743. } if
  1744. WRITESYSTEMDICT not { systemdict readonly pop } if
  1745. (END GC) VMDEBUG
  1746. % The Adobe AGM_Core used by Illustrator 9 has some code that breaks
  1747. % if the 'product' is not (Adobe PostScript Parser). A bug has been
  1748. % submitted to Adobe since this also fails with Acrobat Distiller.
  1749. % As a temporary work around, the following HACK will work for
  1750. % devices without spot color support. Once Ghostscript can
  1751. % support DeviceN and spot color separations this will need to
  1752. % be 'true' in some cases.
  1753. userdict /AGM_preserve_spots false put
  1754. % The interpreter will run the initial procedure (start).