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

  1. %    Copyright (C) 1997, 1999 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. % $Id: gs_dps1.ps,v 1.1 2000/03/09 08:40:39 lpd Exp $
  16. % Initialization file for most of the Display PostScript functions
  17. % that are also included in Level 2.
  18.  
  19. level2dict begin
  20.  
  21. % ------ Virtual memory ------ %
  22.  
  23. /currentshared /.currentglobal load def
  24. /scheck /.gcheck load def
  25. %****** FOLLOWING IS WRONG ******
  26. /shareddict currentdict /globaldict .knownget not { 20 dict } if def
  27.  
  28. % Global and LocalFontDirectory must remain in systemdict
  29. % even if we temporarily exit Level 2 mode.
  30.  
  31. end                % level2dict
  32. systemdict begin
  33.  
  34. /SharedFontDirectory .FontDirectory .gcheck
  35.  { .currentglobal false .setglobal
  36.    /LocalFontDirectory .FontDirectory dup maxlength dict copy
  37.    .forcedef    % LocalFontDirectory is local, systemdict is global
  38.    .setglobal .FontDirectory
  39.  }
  40.  { /LocalFontDirectory .FontDirectory
  41.    .forcedef    % LocalFontDirectory is local, systemdict is global
  42.    50 dict
  43.  }
  44. ifelse def
  45.  
  46. end                % systemdict
  47. level2dict begin
  48.  
  49. % setshared must rebind FontDirectory to the appropriate one of
  50. % Local or SharedFontDirectory.
  51.  
  52. /.setglobal        % <bool> .setglobal -
  53.  { dup .setglobal
  54.    //systemdict /FontDirectory .currentglobal
  55.     { //SharedFontDirectory }
  56.     { /LocalFontDirectory .systemvar }    % can't embed ref to local VM
  57.    ifelse .forceput pop    % LocalFontDirectory is local, systemdict is global
  58.  } .bind odef        % must bind .forceput and .setglobal
  59.             % even if NOBIND in effect
  60. % Don't just copy (load) the definition of .setglobal:
  61. % it gets redefined for LL3.
  62. /setshared { /.setglobal .systemvar exec } odef
  63. .currentglobal setshared
  64.  
  65. % See below for changes in save and restore.
  66.  
  67. % ------ Fonts ------ %
  68.  
  69. /selectfont        % <fontname> <size> selectfont -
  70.  { 1 index findfont
  71.    1 index dup type /arraytype eq { makefont } { scalefont } ifelse
  72.    setfont pop pop
  73.  } odef
  74. % undefinefont has to take local/global VM into account.
  75. /undefinefont        % <fontname> undefinefont -
  76.  { .FontDirectory 1 index .undef
  77.    .currentglobal
  78.     {        % Current mode is global; delete from local directory too.
  79.       //systemdict /LocalFontDirectory .knownget
  80.        { 1 index .undef }
  81.       if
  82.     }
  83.     {        % Current mode is local; if there was a shadowed global
  84.         % definition, copy it into the local directory.
  85.       //systemdict /SharedFontDirectory .knownget
  86.        { 1 index .knownget
  87.       { .FontDirectory 2 index 3 -1 roll put }
  88.      if
  89.        }
  90.       if
  91.     }
  92.    ifelse pop
  93.  } odef
  94.  
  95. % If we load a font into global VM within an inner save, the restore
  96. % will delete it from FontDirectory but not from SharedFontDirectory.
  97. % We have to handle this by making restore copy missing entries from
  98. % SharedFontDirectory to FontDirectory.  Since this could slow down restore
  99. % considerably, we define a new operator .dictcopynew for this purpose.
  100. % Furthermore, if FAKEFONTS is in effect, we want global real fonts to
  101. % override fake local ones.  We handle this by brute force.
  102. /restore        % <save> restore -
  103.  { dup //restore    % bind even if NOBIND
  104.    /LocalFontDirectory .systemvar
  105.    FAKEFONTS
  106.     { mark
  107.         % We want to delete a fake font from the local directory
  108.         % iff the global directory now has no definition for it,
  109.         % or a non-fake definition.
  110.       1 index dup
  111.        {        % Stack: lfd mark lfd key ... lfd key value
  112.      length 1 gt
  113.       {        % This is a real local definition; don't do anything.
  114.         pop
  115.       }
  116.       {        % This is a fake local definition, check for global.
  117.         //SharedFontDirectory 1 index .knownget
  118.          {        % A global definition exists, check for fake.
  119.            length 1 eq { pop } { 1 index } ifelse
  120.          }
  121.          {        % No global definition, delete the local one.
  122.            1 index
  123.          }
  124.         ifelse
  125.       }
  126.      ifelse
  127.        } forall
  128.       pop counttomark 2 idiv { .undef } repeat pop
  129.     }
  130.    if
  131.    //SharedFontDirectory exch .dictcopynew pop
  132.    .currentglobal .setglobal    % Rebind FontDirectory according to current VM.
  133.    pop
  134.  } bind odef
  135.  
  136. % ------ Miscellaneous ------ %
  137.  
  138. /undef /.undef load def
  139.  
  140. end                % level2dict
  141.