home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / ghostscript / 8.64 / Resource / Init / gs_cidtt.ps < prev    next >
Encoding:
Text File  |  2009-04-17  |  5.0 KB  |  150 lines

  1. %    Copyright (C) 2000 Artifex Software, Inc.  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 9237 2008-11-23 20:36:12Z leonardo $
  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 22000 le {
  38.         CIDCount 2 mul string
  39.       } {
  40.         44000 string
  41.         CIDCount 44000 gt {
  42.        % need three strings
  43.            44000 string        % 22000 2 mul string
  44.            CIDCount 44000 sub 2 mul string
  45.         } {
  46.            CIDCount 22000 sub 2 mul string
  47.         } ifelse
  48.       } ifelse
  49.     ] def
  50.     % Now fill it :
  51.     Decoding TT_cmap SubstNWP GDBytes CIDMap .fillCIDMap
  52.   currentdict end
  53. } bind def
  54.  
  55. /load_sfnts  % <FontDict> load_sfnts <FontDict> 
  56. { % Read the True Type file from the path /Path, and buld /sfnts,
  57.   % skipping glyf and loca. 
  58.   dup /Path get                                            % <font> (path)
  59.   QUIET not {
  60.     (Loading a TT font from ) print dup print 
  61.     ( to emulate a CID font ) print 1 index /CIDFontName get =only ( ... ) print
  62.   } if
  63.   (r) file dup                                             % <font> file file
  64.   3 1 roll                                                 % file <font> file
  65.   1 index /SubfontID .knownget not { 0 } if                % file <font> file SubfontID
  66.   .load_tt_font_stripped exch copy                         % file <font>
  67.   QUIET not {
  68.     (Done.) =
  69.   } if
  70.   dup 3 1 roll                                             % <font> file <font>
  71.   exch /File exch put                                      % <font>
  72.   dup dup /CIDSystemInfo get /Ordering get (.)             % <font> () ()
  73.   2 index /Decoding get =string cvs                        % <font> () () ()
  74.   concatstrings concatstrings cvn /Decoding exch put       % <font>
  75.   dup dup /CIDSystemInfo get /Ordering get (-WMode)        % <font> <font> () ()
  76.   concatstrings cvn /SubstCID 
  77.   2 copy resourcestatus {
  78.     pop pop
  79.     findresource /subst_CID_on_WMode exch put              % <font>
  80.   } {
  81.     pop pop pop
  82.   } ifelse
  83.   //ChooseDecoding exec                                    % <font>
  84.   //GenerateCIDMap exec                                    % <font>
  85. } bind def
  86.  
  87. %-----------TrueType-specific methods for category redefinition : -----------
  88.  
  89. /RefinePath      % <FontDict> RefinePath <FontDict>
  90. { dup begin
  91.   Path .libfile {
  92.       dup .filename {
  93.         currentdict exch /Path exch put
  94.       } if
  95.       closefile
  96.   } {
  97.     (Can't find the font file ) print =
  98.     /findfont cvx /undefinedfilename signalerror
  99.   } ifelse
  100.   end
  101. } bind def
  102.  
  103. /complete_instance  % <font_name> <FontDict> <Options> complete_FAPI_Font <font_name> <FontDict>
  104. { 1 index /CIDFontType 2 put % Other types are not emulated yet.
  105.   //super.complete_instance exec
  106.   //RefinePath exec
  107.   //load_sfnts exec
  108. } bind def
  109.  
  110. /IsMyRecord      % <raw_record> -> <raw_record> bool
  111. { dup type /dicttype eq { dup /FileType .knownget { /TrueType eq } { false } ifelse } { false } ifelse
  112. } bind def
  113.  
  114. /IsActive       % <record> IsActive <bool>
  115. { pop true
  116. } bind def
  117.  
  118. /CIDFontRecordVirtualMethods //RecordVirtualMethodsStub dup length 3 add dict copy begin
  119.   /GetCSI //TranslateCSI def
  120.   /IsActive //IsActive def
  121.   /MakeInstance   % <Name> <record> MakeInstance <Name> <Instance> <size>
  122.   { currentglobal 3 1 roll true setglobal
  123.     //CIDFontOptions //complete_instance exec
  124.     2 copy //GetSize exec
  125.     4 3 roll setglobal
  126.   } bind def
  127. currentdict end def
  128.  
  129. % Redefine the /CIDFont category :
  130. 4 dict begin
  131.   /CategoryName /CIDFont def
  132.   /IsMapFileOptional true def
  133.   /VerifyMap  { pop } bind def
  134.   /PreprocessRecord  % <map> <Name> <raw_record> PreprocessRecord <map> <Name> <record> <bool>
  135.   { //IsMyRecord exec dup {
  136.       pop dup /RecordVirtualMethods //CIDFontRecordVirtualMethods put
  137.       true
  138.     } if
  139.   } bind def
  140. currentdict end
  141.  
  142. /MappedCategoryRedefiner /ProcSet findresource /Redefine get exec
  143.  
  144. end  % the temporary dictionary for local binding.
  145.  
  146. .setlanguagelevel
  147.