home *** CD-ROM | disk | FTP | other *** search
/ swCHIP 1991 January / swCHIP_95-1.bin / utility / gs333ini / gs3.33 / gs_dps1.ps < prev    next >
Text File  |  1995-12-09  |  7KB  |  226 lines

  1. %    Copyright (C) 1990, 1991, 1993, 1994 Aladdin Enterprises.  All rights reserved.
  2. % This file is part of Aladdin Ghostscript.
  3. % Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  4. % or distributor accepts any responsibility for the consequences of using it,
  5. % or for whether it serves any particular purpose or works at all, unless he
  6. % or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  7. % License (the "License") for full details.
  8. % Every copy of Aladdin Ghostscript must include a copy of the License,
  9. % normally in a plain ASCII text file named PUBLIC.  The License grants you
  10. % the right to copy, modify and redistribute Aladdin Ghostscript, but only
  11. % under certain conditions described in the License.  Among other things, the
  12. % License requires that the copyright notice and this notice be preserved on
  13. % all copies.
  14.  
  15. % Initialization file for analogs of Display PostScript functions
  16. % that are also included in Level 2.
  17. % When this is run, systemdict is still writable,
  18. % but (almost) everything defined here goes into level2dict.
  19.  
  20. level2dict begin
  21.  
  22. % ------ Virtual memory ------ %
  23.  
  24. /currentshared /.currentglobal load def
  25. /scheck /.gcheck load def
  26. %****** FOLLOWING IS WRONG ******
  27. /shareddict currentdict /globaldict .knownget not { 20 dict } if def
  28.  
  29. % Global and LocalFontDirectory must remain in systemdict
  30. % even if we temporarily exit Level 2 mode.
  31.  
  32. end                % level2dict
  33. systemdict begin
  34.  
  35. /SharedFontDirectory FontDirectory .gcheck
  36.  { .currentglobal false .setglobal
  37.    /LocalFontDirectory FontDirectory dup maxlength dict copy def
  38.    .setglobal FontDirectory
  39.  }
  40.  { /LocalFontDirectory FontDirectory def
  41.    50 dict
  42.  }
  43. ifelse def
  44.  
  45. end                % systemdict
  46. level2dict begin
  47.  
  48. % setshared must rebind FontDirectory to the appropriate one of
  49. % Local or SharedFontDirectory.
  50.  
  51. /.setglobal
  52.  { .setglobal
  53.    //systemdict /FontDirectory .currentglobal
  54.     { //SharedFontDirectory }
  55.     { //systemdict /LocalFontDirectory get }    % can't embed ref to local VM
  56.    ifelse .forceput
  57.  } .bind odef        % must bind .forceput and .setglobal
  58.             % even if NOBIND in effect
  59. /setshared /.setglobal load def
  60. .currentglobal setshared
  61.  
  62. % ------ Fonts ------ %
  63.  
  64. /selectfont
  65.  { exch findfont exch
  66.    dup type /arraytype eq { makefont } { scalefont } ifelse
  67.    setfont
  68.  } odef
  69. % Undefinefont has to take local/global VM into account.
  70. /undefinefont
  71.  { FontDirectory 1 index undef
  72.    .currentglobal
  73.     {        % Current mode is global; delete from local directory too.
  74.       systemdict /LocalFontDirectory .knownget
  75.        { exch undef }
  76.        { pop }
  77.       ifelse
  78.     }
  79.     {        % Current mode is local; if there was a shadowed global
  80.         % definition, copy it into the local directory.
  81.       systemdict /SharedFontDirectory .knownget
  82.        { 1 index .knownget
  83.       { FontDirectory 3 1 roll put }
  84.       { pop }
  85.      ifelse
  86.        }
  87.       if
  88.     }
  89.    ifelse
  90.  } odef
  91.  
  92. % If we load a font into global VM within an inner save, the restore
  93. % will delete it from FontDirectory but not from SharedFontDirectory.
  94. % We have to handle this by making restore copy missing entries from
  95. % SharedFontDirectory to FontDirectory.  Since this could slow down restore
  96. % considerably, we define a new operator .dictcopynew for this purpose.
  97. /restore
  98.  { //restore
  99.    //SharedFontDirectory //systemdict /LocalFontDirectory get .dictcopynew pop
  100.  } bind odef
  101.  
  102. % ------ Halftones ------ %
  103.  
  104. /.makestackdict
  105.     { { counttomark -1 roll } forall .dicttomark
  106.     } bind def
  107. /currenthalftone
  108.     { mark .currenthalftone
  109.        { { exch pop }        % halftone
  110.          { /HalftoneType 1        % screen
  111.         { /Frequency /Angle /SpotFunction }
  112.            .makestackdict
  113.          }
  114.          { /HalftoneType 2        % colorscreen
  115.         { /RedFrequency /RedAngle /RedSpotFunction
  116.           /GreenFrequency /GreenAngle /GreenSpotFunction
  117.           /BlueFrequency /BlueAngle /BlueSpotFunction
  118.           /GrayFrequency /GrayAngle /GraySpotFunction
  119.         }
  120.            .makestackdict
  121.          }
  122.        }
  123.       exch get exec
  124.     } odef
  125. % Define sethalftone so it converts all other types to type 5.
  126. /.sethalftoneRGBV    % <dict> <type> <keys> <keysRGBV>
  127.     { 4 -1 roll exch { 1 index exch get exch } forall 15 1 roll
  128.       14 -2 roll mark 15 1 roll { /Gray /Blue /Green /Red }
  129.        {        % stack: v0 v1 v2 type keys comp
  130.          mark
  131.          2 index 0 get 8 -1 roll
  132.          4 index 1 get 9 -1 roll
  133.          6 index 2 get 10 -1 roll
  134.             % stack: type keys comp mark k0 v0 k1 v1 k2 v2
  135.          /HalftoneType 10 index .dicttomark
  136.          counttomark 2 roll
  137.        }
  138.       forall pop pop
  139.       /Default 1 index .dicttomark .sethalftone5
  140.     } bind def
  141. /sethalftone
  142.     { dup /HalftoneType get 1 sub
  143.        {  { mark /Default 2 index .dicttomark .sethalftone5 }
  144.           { 1 { /Frequency /Angle /SpotFunction }
  145.         { /RedFrequency /RedAngle /RedSpotFunction
  146.           /GreenFrequency /GreenAngle /GreenSpotFunction
  147.           /BlueFrequency /BlueAngle /BlueSpotFunction
  148.           /GrayFrequency /GrayAngle /GraySpotFunction
  149.         } .sethalftoneRGBV
  150.           }
  151.           { mark /Default 2 index .dicttomark .sethalftone5 }
  152.           { 3 { /Width /Height /Thresholds }
  153.         { /RedWidth /RedHeight /RedThresholds
  154.           /GreenWidth /GreenHeight /GreenThresholds
  155.           /BlueWidth /BlueHeight /BlueThresholds
  156.           /GrayWidth /GrayHeight /GrayThresholds
  157.         } .sethalftoneRGBV
  158.           }
  159.           { dup .sethalftone5 }
  160.        } exch get exec
  161.     } odef
  162. % Redefine setscreen and setcolorscreen to recognize halftone dictionaries.
  163. /setscreen
  164.     { dup type /dicttype eq
  165.        { sethalftone pop pop }
  166.        { //setscreen }
  167.       ifelse
  168.     } odef
  169. /setcolorscreen
  170.     { dup type /dicttype eq
  171.        { sethalftone 11 { pop } repeat }
  172.        { //setcolorscreen }
  173.       ifelse
  174.     } odef
  175.  
  176. % ------ User objects ------ %
  177.  
  178. /.localarray where
  179.  { pop }
  180.  { /.localarray
  181.     { currentglobal false setglobal
  182.       exch array exch setglobal
  183.     } bind def
  184.  }
  185. ifelse
  186. /defineuserobject
  187.     { userdict /.UserObjects known
  188.        { 1 index userdict /.UserObjects get length ge
  189.           { 1 index 1 add .localarray userdict /.UserObjects get
  190.         1 index copy pop
  191.         userdict /.UserObjects 3 -1 roll put
  192.           }
  193.          if
  194.        }
  195.        { userdict /.UserObjects 3 index 1 add .localarray put
  196.        }
  197.       ifelse
  198.       userdict /.UserObjects get 3 1 roll put
  199.     } odef
  200. /execuserobject
  201.     { userdict /.UserObjects get exch get exec
  202.     } odef
  203. /undefineuserobject
  204.     { userdict /.UserObjects get exch null put
  205.     } odef
  206.  
  207. % ------ User paths ------ %
  208.  
  209. /upath
  210.     { [ exch {/ucache cvx} if pathbbox /setbbox cvx
  211.       {/moveto cvx} {/lineto cvx} {/curveto cvx} {/closepath cvx}
  212.       pathforall ] cvx
  213.     } odef
  214.  
  215. % Dummy definitions for cache control operators
  216.  
  217. /ucachestatus
  218.     { mark 0 0 0 0 0 } odef
  219. /setucacheparams
  220.     { cleartomark } odef
  221.  
  222. end                % level2dict
  223.