home *** CD-ROM | disk | FTP | other *** search
/ jppd.dyndns.org / jppd.dyndns.org.tar / jppd.dyndns.org / QUERYPRO / Impressora_PDF / converter.exe / GPLGS / gs_cidfm.ps < prev    next >
Text File  |  2004-09-14  |  5KB  |  125 lines

  1. %    Copyright (C) 2000 artofcode LLC.  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_cidfm.ps,v 1.5.2.1 2004/09/13 07:22:23 igor Exp $
  14. % Redefine CIDFont category with cidfmap .
  15.  
  16. languagelevel 2 .setlanguagelevel
  17.  
  18. 4 dict begin
  19. /CategoryName /CIDFont def
  20.  
  21. /MapFileName (cidfmap) def
  22.  
  23. /IsMyRecord      % <raw_record> -> <raw_record> bool
  24. { % Only for client's needs.
  25.   dup type /nametype eq
  26. } bind def
  27.  
  28. /RecordVirtualMethods 3 dict begin
  29.  
  30.   /MakeInstance   % <Name> <record> MakeInstance <Name> <Instance> <size>
  31.   { % We know that currentdict is the category.
  32.     /Substitute get FindResource            % /Name <<CIDFont>>
  33.     dup length dict copy                    % /Name <<CIDFont>>
  34.     1 index ResourceStatus pop exch pop     % /Name <<CIDFont>> size
  35.   } bind def
  36.  
  37.   /GetFilePath  % <scratch> <Name> <record> GetFilePath <filepath>
  38.   { % We know that currentdict is the category.
  39.     exch pop
  40.     /Substitute get exch ResourceFileName
  41.   } bind def
  42.  
  43.   /GetSize   % <Name> <record> GetSize <size>
  44.   { % We know that currentdict is the category.
  45.     /Substitute get ResourceStatus {
  46.       exch pop exch pop
  47.     } {
  48.       /undefinedresource signalerror
  49.     } ifelse
  50.   } bind def
  51.  
  52.   /GetCSI   % <record> GetCSI null
  53.   { pop null
  54.   } bind def
  55.  
  56.   /IsActive % <record> IsActive <bool>
  57.   { pop true
  58.   } bind def
  59.  
  60. currentdict end def
  61.  
  62. /VerifyMap  % <raw_map> VerifyMap -
  63. { % Checks for vicious substitution cycles.
  64.   dup length dict copy                  % <<map>>
  65.   dup length dict                       % <<map>> <<temp>>
  66.   { % Choose a random record :
  67.     true 2 index {                      % <<map>> <<temp>> true /Name /Subs
  68.       3 2 roll pop false exit           % <<map>> <<temp>> /Name /Subs false
  69.     } forall
  70.     { exit                              % <<map>> <<temp>>
  71.     } if                                % <<map>> <<temp>> /Name /Subs
  72.     % Move the substitution chain to <<temp>>, checking for a cycle :
  73.     3 index 2 index undef               % <<map>> <<temp>> /Name /Subs
  74.     exch 2 index exch 0 put             % <<map>> <<temp>> /Subs
  75.     { //IsMyRecord exec not {
  76.         % Not a substitution, the chain terminates.
  77.         pop exit                        % <<map>> <<temp>>
  78.       } if                              % <<map>> <<temp>> /Subs
  79.       1 index 1 index known {
  80.         (Vicious substitution cycle in map file with the entry ) print =string cvs print ( .) =
  81.         /VerifyMap cvx /undefinedresource signalerror
  82.       } if                              % <<map>> <<temp>> /Subs
  83.       1 index 1 index 0 put
  84.       dup 3 index exch .knownget not {  % <<map>> <<temp>> /Subs
  85.         % No more substitutions, the chain terminates.
  86.         pop exit                        % <<map>> <<temp>>
  87.       } if                              % <<map>> <<temp>> /Subs /Subs1
  88.       exch                              % <<map>> <<temp>> /Subs1 /Subs
  89.       3 index exch undef                % <<map>> <<temp>> /Subs1
  90.     } loop
  91.     % Not cycled, now purge the <<temp>> :
  92.     { % Choose a random record :
  93.       true 1 index {                    % <<map>> <<temp>> true /Name /Subs
  94.         3 2 roll pop false exit         % <<map>> <<temp>> /Name /Subs false
  95.       } forall
  96.       { exit                            % <<map>> <<temp>>
  97.       } if                              % <<map>> <<temp>> /Name /Subs
  98.       % Remove it :
  99.       pop 1 index exch undef            % <<map>> <<temp>>
  100.     } loop
  101.   } loop
  102.   pop pop                               %
  103. } bind def
  104.  
  105. /PreprocessRecord  % <map> <Name> <raw_record> PreprocessRecord <map> <Name> <record> <bool>
  106. { //IsMyRecord exec {
  107.     1 dict begin
  108.     /Substitute exch def
  109.     /RecordVirtualMethods //RecordVirtualMethods def
  110.     currentdict end
  111.     true
  112.   } {
  113.     false
  114.   } ifelse
  115. } bind def
  116.  
  117. currentdict end 
  118.  
  119. /MappedCategoryRedefiner /ProcSet findresource /Redefine get exec
  120.  
  121. .setlanguagelevel
  122.