home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 256.lha / GhostScript_v1.2 / ghost.ps < prev    next >
Text File  |  1989-06-14  |  11KB  |  311 lines

  1. %    Copyright (C) 1989 Aladdin Enterprises.  All rights reserved.
  2. %    Distributed by Free Software Foundation, Inc.
  3. %
  4. % This file is part of Ghostscript.
  5. %
  6. % Ghostscript is distributed in the hope that it will be useful, but
  7. % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  8. % to anyone for the consequences of using it or for whether it serves any
  9. % particular purpose or works at all, unless he says so in writing.  Refer
  10. % to the Ghostscript General Public License for full details.
  11. %
  12. % Everyone is granted permission to copy, modify and redistribute
  13. % Ghostscript, but only under the conditions described in the Ghostscript
  14. % General Public License.  A copy of this license is supposed to have been
  15. % given to you along with Ghostscript so you can know your rights and
  16. % responsibilities.  It should be in a file named COPYING.  Among other
  17. % things, the copyright notice and this notice must be preserved on all
  18. % copies.
  19.  
  20. % Initialization file for GhostScript, version 1.2.
  21. % When this is run, systemdict is still writable.
  22.  
  23. % Define the device size and aspect ratio.
  24. %%% FOLLOWING IS FOR X WINDOWS
  25. %{       /.device.width 8.5 72 mul cvi def
  26. %        /.device.height 11 72 mul def
  27. %        /.pixel.size 1 def      % pixel width in points
  28. %        /.aspect.ratio 1 def    % pixel height/width
  29. %} pop
  30. %%% FOLLOWING IS FOR EGA
  31. %{       /.device.width 640 def
  32. %        /.device.height 350 def
  33. %        /.pixel.size 1 def
  34. %        /.aspect.ratio 14 11 div def
  35. %} pop
  36. %%% FOLLOWING IS FOR AMIGA
  37. %{       /.device.width 704 def
  38. %        /.device.height 470 def
  39. %        /.pixel.size 0.5 def
  40. %        /.aspect.ratio 11 10 div def
  41. %} exec
  42. % FOLLOWING IS FOR AMIGA
  43. %{       /.device.width 2448 def
  44. %        /.device.height 3204 def
  45. %        /.pixel.size 1 def
  46. %        /.aspect.ratio 1 def
  47. %} exec
  48.  
  49. % Acquire the debugging flags.
  50. currentdict /DEBUG known   /DEBUG exch def
  51. currentdict /NODISPLAY known   not /DISPLAYING exch def
  52.  
  53. %%%%%%
  54. DEBUG {vmstatus pop exch pop (        ) cvs print (\n) print flush} if
  55. %%%%%%
  56.  
  57. % Acquire systemdict and userdict.
  58. % Note that the dictionary stack only has 1 element at this point!
  59. /systemdict currentdict def
  60. /userdict 100 dict def
  61. /statusdict 20 dict def
  62. userdict begin          % 2 elements now
  63. systemdict begin
  64.  
  65. % Define true and false.
  66. /true 0 0 eq def
  67. /false 0 1 eq def
  68.  
  69. % Define the predefined procedures, in alphabetical order.
  70. /[      /mark load def
  71. /]      {counttomark array astore exch pop} bind def
  72. /=      {=only (\n) print} bind def
  73. /abs    {dup 0 lt {neg} if} bind def
  74. /defaultmatrix
  75.         {currentdevice pop pop pop} bind def
  76. %.framedevice does all of framedevice except initclip and initmatrix.
  77. /framedevice
  78.         {.framedevice initclip initmatrix} bind def
  79. /handleerror
  80.         {errordict /handleerror get exec} bind def
  81. /identmatrix
  82.         {{1.0 0.0 0.0 1.0 0.0 0.0} cvlit exch copy} bind def
  83. /initgraphics
  84.         {initmatrix newpath initclip 1 setlinewidth 0 setlinecap 0 setlinejoin
  85.          {} 0 setdash 0 setgray 10 setmiterlimit} bind def
  86. /initmatrix
  87.         {.tempmatrix defaultmatrix setmatrix} bind def
  88. %.nulldevice does all of nulldevice except initclip and initmatrix.
  89. /nulldevice
  90.         {.nulldevice initclip initmatrix} bind def
  91. /matrix {6 array identmatrix} bind def
  92. /prompt {(GS>) print flush} def
  93. /pstack {0 1 count 3 sub {index ==} for} bind def
  94. /run    {(r) file cvx execute} bind def %%%%%% TEMPORARY %%%%%%
  95. %.setgray is the same as setgray without the transfer function.
  96. /setgray
  97.         {currenttransfer exec .setgray} bind def
  98. /stack  {0 1 count 3 sub {index =} for} bind def
  99. /start  { (Ghostscript ) print version print (\n) print flush } def
  100. %.typenumber is a non-standard operator.
  101. /type   {.typenumber
  102.                 {arraytype booleantype dicttype filetype fonttype
  103.                  integertype marktype nametype nulltype operatortype
  104.                  packedarraytype realtype savetype stringtype colortype}
  105.          exch get} def
  106. /version
  107.         (1.2) def
  108. % Define auxiliary procedures needed for the above.
  109. /=only  {dup type /stringtype ne
  110.         {(                                        ) cvs} if print} bind def
  111. /.identmatrix           % a read-only identity matrix
  112.         matrix readonly def
  113. /.tempmatrix            % a temporary matrix
  114.         matrix def
  115.  
  116. % Define the procedure used by the C executive for executing user input,
  117. % and also by the run operator.
  118. % This is called with a procedure or file on the operand stack.
  119. /execute
  120.         {stopped $error /newerror get and {handleerror} if} bind def
  121.  
  122. %%%%%%
  123. DEBUG {vmstatus pop = pop flush} if
  124. %%%%%%
  125.  
  126. % Create the error handling machinery.
  127. % The interpreter knows the names ErrorNames and ErrorObject.
  128. {/unknown /dictfull /dictstackoverflow /dictstackunderflow
  129.  /execstackoverflow /interrupt /invalidaccess /invalidexit
  130.  /invalidfileaccess /invalidfont /invalidrestore /ioerror
  131.  /limitcheck /nocurrentpoint /rangecheck /stackoverflow
  132.  /stackunderflow /syntaxerror /timeout /typecheck
  133.  /undefined /undefinedfilename /undefinedresult /unmatchedmark
  134.  /VMerror
  135. } cvlit readonly
  136. dup length 3 add dict           % ErrorNames, ErrorObject, handleerror
  137. /errordict exch def
  138. errordict begin
  139.   /ErrorNames exch def
  140.   { $error /newerror get { = flush quit } if
  141.     countdictstack array dictstack
  142.     $error begin
  143.       /newerror true def
  144.       /dstack exch def
  145.       /errorname exch def
  146.       countexecstack array execstack /estack exch def
  147.       count array astore /ostack exch def
  148.       errordict /ErrorObject get /command exch def
  149.     end
  150.     stop
  151.   }
  152.   ErrorNames
  153.    { [ 1 index 3 index /exec load ] cvx def
  154.    } forall
  155.   pop
  156.   /handleerror
  157.    { (Error: ) print
  158.      $error begin
  159.        errorname ==only
  160.        ( in ) print
  161.        /command load ==
  162.        (  ostack:) print
  163.          ostack {( ) print =only} forall
  164.        (\n  estack: ) print
  165.          estack {( ) print =only} forall
  166.        (\n  dstack:) print
  167.          dstack {dup ( ) print length =only (/) print maxlength =only} forall
  168.        (\n) print
  169.        /newerror false def
  170.        flush
  171.      end
  172.    } bind def
  173. end
  174. /$error 6 dict def              % newerror, errorname, command, 3 stacks
  175. $error begin
  176.   /newerror false def
  177. end
  178.  
  179. % Define the == procedure.
  180. /==     {==only (\n) print} bind def
  181. /.dict 12 dict dup
  182. begin def
  183.   /.buf 128 string def
  184.   /.cvp {.buf cvs print} bind def
  185.   /.print
  186.         {dup type .dict exch known
  187.          {dup type exec} {(-) print type .cvp (-) print} ifelse}
  188.         bind def
  189.   /integertype /.cvp load def
  190.   /realtype /.cvp load def
  191.   /booleantype /.cvp load def
  192.   /nametype {dup xcheck not {(/) print} if .cvp} bind def
  193.   /arraytype
  194.         {dup xcheck {(})({)} {(])([)} ifelse print exch () exch
  195.          {exch print .print ( )} forall pop print} bind def
  196.   /operatortype
  197.         {systemdict
  198.          {2 index eq {exch pop exit} {pop} ifelse}
  199.          forall =only} bind def
  200.   /stringtype
  201.         {(\() print
  202.          {/.ch exch def
  203.           .ch 32 lt .ch 127 ge or .ch 40 eq or .ch 41 eq or
  204.           {(\\) print .ch 8#1000 add 8 .buf cvrs 1 3 getinterval print}
  205.           {( ) dup 0 .ch put print}
  206.           ifelse}
  207.          forall (\)) print} bind def
  208. {0 begin .print end} bind dup 0 .dict put
  209. end
  210. /==only exch def
  211.  
  212. %%%%%%
  213. DEBUG {vmstatus pop = pop flush} if
  214. %%%%%%
  215.  
  216. % Define the font directory.
  217. /FontDirectory 20 dict def
  218.  
  219. % Define the standard encoding vector.
  220. /StandardEncoding {
  221. % \00x
  222.         /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  223.         /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  224.         /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  225.         /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  226. % \04x
  227.         /space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quoteright
  228.         /parenleft /parenright /asterisk /plus /comma /hyphen /period /slash
  229.         /zero /one /two /three /four /five /six /seven
  230.         /eight /nine /colon /semicolon /less /equal /greater /question
  231. % \10x
  232.         /at /A /B /C /D /E /F /G
  233.         /H /I /J /K /L /M /N /O
  234.         /P /Q /R /S /T /U /V /W
  235.         /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore
  236. % \14x
  237.         /quoteleft /a /b /c /d /e /f /g
  238.         /h /i /j /k /l /m /n /o
  239.         /p /q /r /s /t /u /v /w
  240.         /x /y /z /braceleft /bar /braceright /asciitilde /.notdef
  241. % \20x
  242.         /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  243.         /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  244.         /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  245.         /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  246. % \24x
  247.         /.notdef /exclamdown /cent /sterling /fraction /yen /florin /section
  248.         /currency /quotesingle /quotedblleft /guillemotleft /guilsingleft /guilsingright /fi /fl
  249.         /.notdef /endash /dagger /daggerdbl /periodcentered /.notdef /paragraph /bullet
  250.         /quotesinglbase /quotedblbase /quotedblright /guillemotright /ellipsis /perthousand /.notdef /questiondown
  251. % \30x
  252.         /.notdef /grave /acute /circumflex /tilde /macron /breve /dotaccent
  253.         /dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron
  254.         /emdash /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  255.         /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
  256. % \34x
  257.         /.notdef /AE /.notdef /ordfeminine /.notdef /.notdef /.notdef /.notdef
  258.         /Lslash /Oslash /OE /ordmasculine /.notdef /.notdef /.notdef /.notdef
  259.         /.notdef /ae /.notdef /.notdef /.notdef /dotlessi /.notdef /.notdef
  260.         /lslash /oslash /oe /germandbls /.notdef /.notdef /.notdef /.notdef
  261. } cvlit readonly def
  262.  
  263. % Close up systemdict.
  264. end
  265. systemdict readonly pop
  266.  
  267. % Establish a default upper limit in the character cache,
  268. % namely, 10 times the average expected character size.
  269. cachestatus 5 index 10 mul 2 index 1 max idiv           % bmax, cmax
  270.  mark exch dup 10 idiv exch setcacheparams
  271.  7 {pop} repeat
  272.  
  273. %%%%%%
  274. DEBUG {vmstatus pop = pop flush} if
  275. %%%%%%
  276.  
  277. % Load the standard font.
  278. (gfonts.ps) run
  279.  
  280. % Establish a default environment.
  281. % Map the screen height to an 11" page.
  282. % This is not necessarily the best compromise.
  283. DISPLAYING
  284.  { .device.height 72 11 mul div
  285.    [1 index .aspect.ratio mul 0 0 4 index neg 0 .device.height]
  286.    .device.width 8 idiv .device.height { } framedevice pop
  287.  }
  288.  { nulldevice
  289.  } ifelse
  290. 1 setflat
  291. 10 45 {dup mul exch dup mul add 1 exch sub} bind setscreen
  292. { } settransfer
  293. initgraphics
  294. DISPLAYING
  295.  { erasepage
  296.  } if
  297.  
  298. %%%%%%
  299. DEBUG {vmstatus pop = pop   systemdict length = flush} if
  300. %%%%%%
  301.  
  302. % The interpreter will run the initial procedure (start).
  303.  
  304. %
  305. %   Personal likes by tom
  306. %
  307. /save {gsave 9999} bind def
  308. /restore {pop grestore} bind def
  309. /clear {gsave 1 setgray clippath fill grestore} bind def
  310. /! {gsave clear run grestore} bind def
  311.