home *** CD-ROM | disk | FTP | other *** search
/ jppd.dyndns.org / jppd.dyndns.org.tar / jppd.dyndns.org / QUERYPRO / Actualizar / Impressora_PDF / converter.exe / GPLGS / gs_cidtt.ps < prev    next >
Text File  |  2003-02-13  |  5KB  |  134 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_cidtt.ps,v 1.8 2003/02/12 22:31:23 igor Exp $
  14. % Redefine CIDFont category with an emulation with True Type fonts.
  15.  
  16. languagelevel 2 .setlanguagelevel
  17.  
  18. 15 dict begin    % a temporary dictionary for local binding.
  19.  
  20. %------------------Copy the FontEmulationProcs here : -------------------
  21.  
  22. /FontEmulationProcs /ProcSet findresource {
  23.   def
  24. } forall
  25.  
  26. currentdict /super.complete_instance currentdict /complete_instance get put
  27.  
  28. %-------Auxiliary procedures for building CIDFontType 2 from TT file -----------
  29.  
  30. /GenerateCIDMap   % <font> GenerateCIDMap <font>
  31. { begin
  32.     % Obtain the maximal CID :
  33.     %   This implementation doesn't check whether glyphs really present.
  34.     Decoding /CIDCount get /CIDCount exch def
  35.     % Prepare the CIDMap structure :
  36.     /CIDMap [
  37.       CIDCount 32767 le {
  38.         CIDCount 2 mul string
  39.       } {
  40.         32767 2 mul string
  41.         CIDCount 32767 sub 2 mul string
  42.       } ifelse
  43.     ] def
  44.     % Now fill it :
  45.     Decoding TT_cmap SubstNWP GDBytes CIDMap .fillCIDMap
  46.   currentdict end
  47. } bind def
  48.  
  49. /load_sfnts  % <FontDict> load_sfnts <FontDict> 
  50. { % Read the True Type file from the path /Path, and buld /sfnts,
  51.   % skipping glyf and loca. 
  52.   dup /Path get                                            % <font> (path)
  53.   QUIET not {
  54.     (Loading a TT font from ) print dup print 
  55.     ( to emulate a CID font ) print 1 index /CIDFontName get =only ( ... ) print
  56.   } if
  57.   (r) file dup                                             % <font> file file
  58.   3 1 roll                                                 % file <font> file
  59.   1 index /SubfontID .knownget not { 0 } if                % file <font> file SubfontID
  60.   .load_tt_font_stripped exch copy                         % file <font>
  61.   QUIET not {
  62.     (Done.) =
  63.   } if
  64.   dup 3 1 roll                                             % <font> file <font>
  65.   exch /File exch put                                      % <font>
  66.   dup dup /CIDSystemInfo get /Ordering get (.)             % <font> () ()
  67.   2 index /Decoding get =string cvs                        % <font> () () ()
  68.   concatstrings concatstrings cvn /Decoding exch put       % <font>
  69.   //ChooseDecoding exec                                    % <font>
  70.   //GenerateCIDMap exec                                    % <font>
  71. } bind def
  72.  
  73. %-----------TrueType-specific methods for category redefinition : -----------
  74.  
  75. /RefinePath      % <FontDict> RefinePath <FontDict>
  76. { dup begin
  77.   Path .libfile {
  78.       dup .filename {
  79.         currentdict exch /Path exch put
  80.       } if
  81.       closefile
  82.   } {
  83.     (Can't find the font file ) print =
  84.     /findfont cvx /undefinedfilename signalerror
  85.   } ifelse
  86.   end
  87. } bind def
  88.  
  89. /complete_instance  % <font_name> <FontDict> <Options> complete_FAPI_Font <font_name> <FontDict>
  90. { 1 index /CIDFontType 2 put % Other types are not emulated yet.
  91.   //super.complete_instance exec
  92.   //RefinePath exec
  93.   //load_sfnts exec
  94. } bind def
  95.  
  96. /IsMyRecord      % <raw_record> -> <raw_record> bool
  97. { dup type /dicttype eq { dup /FileType .knownget { /TrueType eq } { false } ifelse } { false } ifelse
  98. } bind def
  99.  
  100. /IsActive       % <record> IsActive <bool>
  101. { pop true
  102. } bind def
  103.  
  104. /CIDFontRecordVirtualMethods //RecordVirtualMethodsStub dup length 3 add dict copy begin
  105.   /GetCSI //TranslateCSI def
  106.   /IsActive //IsActive def
  107.   /MakeInstance   % <Name> <record> MakeInstance <Name> <Instance> <size>
  108.   { //CIDFontOptions //complete_instance exec
  109.     2 copy //GetSize exec
  110.   } bind def
  111. currentdict end def
  112.  
  113. % Redefine the /CIDFont category :
  114. 4 dict begin
  115.   /CategoryName /CIDFont def
  116.   /IsMapFileOptional true def
  117.   /VerifyMap  { pop } bind def
  118.   /PreprocessRecord  % <map> <Name> <raw_record> PreprocessRecord <map> <Name> <record> <bool>
  119.   { //IsMyRecord exec dup {
  120.       pop dup /RecordVirtualMethods //CIDFontRecordVirtualMethods put
  121.       true
  122.     } if
  123.   } bind def
  124. currentdict end
  125.  
  126. /MappedCategoryRedefiner /ProcSet findresource /Redefine get exec
  127.  
  128. end  % the temporary dictionary for local binding.
  129.  
  130. .setlanguagelevel
  131.