home *** CD-ROM | disk | FTP | other *** search
/ jppd.dyndns.org / jppd.dyndns.org.tar / jppd.dyndns.org / QUERYPRO / Impressora_PDF / converter.exe / GPLGS / gs_dps1.ps < prev    next >
Text File  |  2002-02-22  |  5KB  |  142 lines

  1. %    Copyright (C) 1997, 1999 Aladdin Enterprises.  All rights reserved.
  2. % This software is provided AS-IS with no warranty, either express or
  3. % implied.
  4. % This software is distributed under license and may not be copied,
  5. % modified or distributed except as expressly authorized under the terms
  6. % of the license contained in the file LICENSE in this distribution.
  7. % For more information about licensing, please refer to
  8. % http://www.ghostscript.com/licensing/. For information on
  9. % commercial licensing, go to http://www.artifex.com/licensing/ or
  10. % contact Artifex Software, Inc., 101 Lucas Valley Road #110,
  11. % San Rafael, CA  94903, U.S.A., +1(415)492-9861.
  12.  
  13. % $Id: gs_dps1.ps,v 1.4 2002/02/21 21:49:28 giles Exp $
  14. % Initialization file for most of the Display PostScript functions
  15. % that are also included in Level 2.
  16.  
  17. level2dict begin
  18.  
  19. % ------ Virtual memory ------ %
  20.  
  21. /currentshared /.currentglobal load def
  22. /scheck /.gcheck load def
  23. %****** FOLLOWING IS WRONG ******
  24. /shareddict currentdict /globaldict .knownget not { 20 dict } if def
  25.  
  26. % Global and LocalFontDirectory must remain in systemdict
  27. % even if we temporarily exit Level 2 mode.
  28.  
  29. end                % level2dict
  30. systemdict begin
  31.  
  32. /SharedFontDirectory .FontDirectory .gcheck
  33.  { .currentglobal false .setglobal
  34.    /LocalFontDirectory .FontDirectory dup maxlength dict copy
  35.    .forcedef    % LocalFontDirectory is local, systemdict is global
  36.    .setglobal .FontDirectory
  37.  }
  38.  { /LocalFontDirectory .FontDirectory
  39.    .forcedef    % LocalFontDirectory is local, systemdict is global
  40.    50 dict
  41.  }
  42. ifelse def
  43.  
  44. end                % systemdict
  45. level2dict begin
  46.  
  47. % setshared must rebind FontDirectory to the appropriate one of
  48. % Local or SharedFontDirectory.
  49.  
  50. /.setglobal        % <bool> .setglobal -
  51.  { dup .setglobal
  52.    //systemdict /FontDirectory .currentglobal
  53.     { //SharedFontDirectory }
  54.     { /LocalFontDirectory .systemvar }    % can't embed ref to local VM
  55.    ifelse .forceput pop    % LocalFontDirectory is local, systemdict is global
  56.  } .bind odef        % must bind .forceput and .setglobal
  57.             % even if NOBIND in effect
  58. % Don't just copy (load) the definition of .setglobal:
  59. % it gets redefined for LL3.
  60. /setshared { /.setglobal .systemvar exec } odef
  61. .currentglobal setshared
  62.  
  63. % See below for changes in save and restore.
  64.  
  65. % ------ Fonts ------ %
  66.  
  67. /selectfont        % <fontname> <size> selectfont -
  68.  { 1 index findfont
  69.    1 index dup type /arraytype eq { makefont } { scalefont } ifelse
  70.    setfont pop pop
  71.  } odef
  72. % undefinefont has to take local/global VM into account.
  73. /undefinefont        % <fontname> undefinefont -
  74.  { .FontDirectory 1 index .undef
  75.    .currentglobal
  76.     {        % Current mode is global; delete from local directory too.
  77.       //systemdict /LocalFontDirectory .knownget
  78.        { 1 index .undef }
  79.       if
  80.     }
  81.     {        % Current mode is local; if there was a shadowed global
  82.         % definition, copy it into the local directory.
  83.       //systemdict /SharedFontDirectory .knownget
  84.        { 1 index .knownget
  85.       { .FontDirectory 2 index 3 -1 roll put }
  86.      if
  87.        }
  88.       if
  89.     }
  90.    ifelse pop
  91.  } odef
  92.  
  93. % If we load a font into global VM within an inner save, the restore
  94. % will delete it from FontDirectory but not from SharedFontDirectory.
  95. % We have to handle this by making restore copy missing entries from
  96. % SharedFontDirectory to FontDirectory.  Since this could slow down restore
  97. % considerably, we define a new operator .dictcopynew for this purpose.
  98. % Furthermore, if FAKEFONTS is in effect, we want global real fonts to
  99. % override fake local ones.  We handle this by brute force.
  100. /restore        % <save> restore -
  101.  { dup //restore    % bind even if NOBIND
  102.    /LocalFontDirectory .systemvar
  103.    FAKEFONTS
  104.     { mark
  105.         % We want to delete a fake font from the local directory
  106.         % iff the global directory now has no definition for it,
  107.         % or a non-fake definition.
  108.       1 index dup
  109.        {        % Stack: lfd mark lfd key ... lfd key value
  110.      length 1 gt
  111.       {        % This is a real local definition; don't do anything.
  112.         pop
  113.       }
  114.       {        % This is a fake local definition, check for global.
  115.         //SharedFontDirectory 1 index .knownget
  116.          {        % A global definition exists, check for fake.
  117.            length 1 eq { pop } { 1 index } ifelse
  118.          }
  119.          {        % No global definition, delete the local one.
  120.            1 index
  121.          }
  122.         ifelse
  123.       }
  124.      ifelse
  125.        } forall
  126.       pop counttomark 2 idiv { .undef } repeat pop
  127.     }
  128.    if
  129.    //SharedFontDirectory exch .dictcopynew pop
  130.    .currentglobal .setglobal    % Rebind FontDirectory according to current VM.
  131.    pop
  132.  } bind odef
  133.  
  134. % ------ Miscellaneous ------ %
  135.  
  136. /undef /.undef load def
  137.  
  138. end                % level2dict
  139.