home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / gs-esp / 8.15 / lib / gs_fntem.ps < prev    next >
Encoding:
Text File  |  2006-07-06  |  10.6 KB  |  400 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_fntem.ps,v 1.4.2.2 2004/10/25 15:19:39 igor Exp $
  14. % A procset for Postscript font emulation
  15.  
  16. % The procedures must not depend on the presence of the
  17. % procset dictionary on the dictionary stack.
  18.  
  19. languagelevel 2 .setlanguagelevel
  20.  
  21. %========================= Process xlatmap ====================
  22. mark
  23. %% Replace 1 (xlatmap)
  24. (xlatmap) .runlibfile
  25. .dicttomark dup systemdict exch /.xlatmap_dict exch put
  26.  
  27. % Convert it into a plain text to simplify the processing in C :
  28. % *(fontkind\0\0\ *(charmap\0decoding\0) ) \0
  29.  
  30. () exch {
  31.   3 1 roll =string cvs concatstrings (\0\0) concatstrings
  32.   exch
  33.   { =string cvs concatstrings (\0) concatstrings
  34.   } forall
  35. } forall
  36. (\0) concatstrings
  37. systemdict exch /.xlatmap exch put
  38.  
  39. /FontEmulationProcs 10 dict begin
  40.  
  41. %-------------------------------Font--------------------------------
  42.  
  43.  
  44. /FontCommon  % - font_common -
  45. { currentdict /PaintType known not {
  46.     /PaintType 0 def
  47.   } if
  48.   currentdict /Encoding .knownget not {
  49.     //StandardEncoding
  50.   } if
  51.   dup type /nametype eq {
  52.     /Encoding findresource
  53.   } if
  54.   /Encoding exch def
  55. } bind def
  56.  
  57. /FontOptions 5 dict begin
  58.   /make_procs currentdict def
  59.   /NameKey /FontName def
  60.   /TypeKey /FontType def
  61.  
  62.   1
  63.   { /FontMatrix [0.001 0 0 0.001 0 0] def
  64.     /FontBBox [-128 -128 1024 1024] def % zfapi.ps refines it.
  65.     /Private 0 dict def
  66.     /CharStrings << /.notdef () >> def
  67.     //FontCommon exec
  68.   } bind def
  69.  
  70.   42
  71.   { /FontMatrix [1 0 0 1 0 0] def
  72.     /FontBBox [0 0 1 1] def % zfapi.ps refines it.
  73.     /CharStrings <<>> def
  74.     /sfnts [<00010000 0000 0000 0000 0000 0000>] def
  75.     /GlyphDirectory [] def
  76.     //FontCommon exec
  77.   } bind def
  78.  
  79.   %fixme : more font types.
  80.  
  81. currentdict end def
  82.  
  83. %---------------------------CIDFont---------------------------
  84.  
  85. /TranslateCSI   % <record> TranslateCSI <CSI>
  86. { RESMPDEBUG { (fntem TranslateCSI beg ) = } if
  87.   begin
  88.   << /Registry (Adobe) 
  89.      /Ordering CSI aload pop 
  90.      /Supplement exch 
  91.   >>
  92.   end
  93.   RESMPDEBUG { (fntem TranslateCSI end ) = } if
  94. } bind def
  95.  
  96. /CIDFontCommon
  97. { /CIDSystemInfo currentdict //TranslateCSI exec def
  98.   currentdict /CSI undef
  99.   /FontBBox [-128 -128 1024 1024] def % zfapi.ps refines it.
  100.   /CIDCount 1 def % ChooseDecoding will set a reasonable value.
  101. } bind def
  102.  
  103. % GFlyph substitution table for narrow, wide, proportional glyphs - 
  104. % used with TrueTypes.
  105.  
  106. currentpacking false setpacking
  107. /SubstNWP << 
  108.  
  109.   % Array format : orig_type, beg_CID, end_CID, subst_beg_CID, subst_type
  110.   % type = (n==narrow, w==wide, p==proportional).
  111.  
  112.   /Japan1
  113.   { p 1 94 231 n    
  114.  
  115.     p 17 26 780 w
  116.     p 34 59 790 w
  117.     p 66 91 816 w
  118.     w 842 842 7918 w  % fixme: These substitutions require to shift the glyph origin.
  119.     w 844 844 7919 w
  120.     w 846 846 7920 w
  121.     w 848 848 7921 w
  122.     w 850 850 7922 w
  123.     w 876 876 7923 w
  124.     w 908 908 7924 w
  125.     w 910 910 7925 w
  126.     w 912 912 7926 w
  127.     w 919 919 7927 w % was `w 914 914 7927 w'
  128.     w 925 925 7928 w
  129.     w 927 927 7929 w
  130.     w 929 929 7930 w
  131.     w 931 931 7931 w
  132.     w 933 933 7932 w
  133.     w 959 959 7933 w
  134.     w 991 991 7934 w
  135.     w 993 993 7935 w
  136.     w 995 995 7936 w
  137.     w 1002 1002 7937 w
  138.     w 1009 1009 7938 w
  139.     w 1010 1010 7939 w
  140.   } cvlit
  141.  
  142.   /Japan2 1 index
  143.  
  144.   /CNS1
  145.   { p 1 94 13648 n
  146.  
  147.     p 17 26 333 w
  148.     p 34 59 365 w
  149.     p 66 91 391 w
  150.   } cvlit
  151.  
  152.   /GB1
  153.   { p 2 94 814 n
  154.   
  155.     p 2 94 262 w
  156.  
  157.     p 1 1 7716 n
  158.   } cvlit
  159.  
  160.   /Korea1
  161.   { p  1 60 8094 n
  162.     p 62 94 8155 n
  163.  
  164.     p  2 59 264 w
  165.     p 63 94 325 w
  166.   } cvlit
  167.  
  168.   /Identity []
  169.  
  170. >> def
  171. setpacking
  172.  
  173. /CIDFontOptions 5 dict begin
  174.   /make_procs currentdict def
  175.   /NameKey /CIDFontName def
  176.   /TypeKey /CIDFontType def
  177.  
  178.   0
  179.   { //CIDFontCommon exec
  180.     /FDArray [
  181.       14 dict begin
  182.         /FontName CIDFontName =string cvs (%) concatstrings cvn def
  183.         /FontType 1 def
  184.         /FontMatrix [0.001 0 0 0.001 0 0 ] def
  185.         /PaintType 0 def
  186.         /Private 0 dict def
  187.         currentdict
  188.       end
  189.     ] def
  190.     /GlyphDirectory [] def
  191.     /GDBytes 1 def
  192.     /FDBytes 0 def
  193.   } bind def
  194.  
  195.   1
  196.   { //CIDFontCommon exec
  197.     /FontMatrix [1 0 0 1 0 0] def
  198.     /BuildGlyph {} def
  199.   } bind def
  200.  
  201.   2
  202.   { //CIDFontCommon exec
  203.     /FontMatrix [1 0 0 1 0 0] def
  204.     /GDBytes 2 def
  205.     /CIDMap <0000> def
  206.     /sfnts [<00010000 0000 0000 0000 0000 0000>] def
  207.     /Encoding [] def
  208.     /CharStrings << /.notdef 0 >> def
  209.   } bind def
  210.  
  211. currentdict end def
  212.  
  213. /complete_instance  % <font_name> <FontDict> <Options> complete_FAPI_Font <font_name> <FontDict>
  214. { begin
  215.   dup length dict copy
  216.   begin
  217.   1 index NameKey exch def
  218.   currentglobal true setglobal
  219.   make_procs TypeKey load .knownget {
  220.     exec
  221.   } { setglobal
  222.       /complete_instance cvx /invalidfont signalerror
  223.   } ifelse
  224.   setglobal
  225.   currentdict end
  226.   end
  227. } bind def
  228.  
  229. /GetFilePath    % <scratch> <Name> <record> GetFilePath <filepath>
  230. { exch pop                       % (scratch) <record>
  231.   /Path get                      % (scratch) (path)
  232.   exch copy
  233.   % What we make here it is not a complete PS resource.
  234.   % Unable to provide full conformity :
  235.   % the attempt to run this file may fail.
  236. } bind def
  237.  
  238. /GetSize        % <Name> <record> GetSize <size>
  239. { pop pop -1 % Unknown size.
  240.   % fixme: probably we could provide an estimation size for some fonts.
  241. } bind def
  242.  
  243. /RecordVirtualMethodsStub 3 dict begin
  244.   /GetFilePath //GetFilePath def
  245.   /GetSize //GetSize def
  246. currentdict end def
  247.  
  248. % ---------------------- Decoding helpers ----------------------------
  249.  
  250. /encodingnames mark
  251.  StandardEncoding /StandardEncoding
  252.  ISOLatin1Encoding /ISOLatin1Encoding
  253.  SymbolEncoding /SymbolEncoding
  254.  DingbatsEncoding /DingbatsEncoding
  255.  /resourceforall where
  256.   { pop (*) { cvn dup findencoding exch } 1024 string /Encoding resourceforall }
  257.  if
  258. .dicttomark def
  259.  
  260. /ChooseDecoding  % <font> ChooseDecoding <font>
  261. { { % A loop for 'exit' context.
  262.     dup /Decoding .knownget {
  263.       dup type /nametype eq {
  264.         1 index /CIDFontType known { /CIDDecoding } { /Decoding } ifelse
  265.         findresource 1 index exch /Decoding exch put
  266.       } {
  267.         pop
  268.       } ifelse
  269.       dup /CIDFontType known {
  270.         dup dup /Decoding get /CIDCount get /CIDCount exch put
  271.       } if
  272.       exit
  273.     } if
  274.     dup /CIDFontType known {
  275.       % This is a hooked CID font, no need for Decoding.
  276.       exit
  277.     } if
  278.     % This works when the renderer can't choose character by name,
  279.     % and we cannot determine the charset.
  280.     % Probably this branch is to be removed after UFST problem is fixed.
  281.     dup /Encoding get                                    % <<font>> encoding
  282.     dup type /nametype eq {
  283.       /Decoding findresource 1 index exch /Decoding exch put
  284.     } {
  285.       dup //encodingnames
  286.       exch .knownget {
  287.         exch pop
  288.         /Decoding findresource 1 index exch /Decoding exch put
  289.       } {
  290.         % unknown encoding, convert it to decoding :
  291.         dup length dict begin
  292.         /.notdef 0 def
  293.         0 1 currentdict length 1 sub
  294.         { dup 2 index exch get 
  295.           dup /.notdef ne {
  296.             exch def
  297.           } {
  298.             pop pop
  299.           } ifelse
  300.         } for
  301.         pop
  302.         currentdict end
  303.         1 index exch /Decoding exch put
  304.       } ifelse
  305.     } ifelse
  306.     exit
  307.   } loop
  308.   dup /CIDFontType known {
  309.     dup /SubstNWP .knownget not {
  310.       dup /CIDSystemInfo get /Ordering get cvn
  311.     } if
  312.     dup type /nametype eq {
  313.       //SubstNWP exch get                              % <<font>> [SubstNWP]
  314.     } if
  315.     1 index exch /SubstNWP exch put
  316.   } if
  317. } bind def
  318.  
  319. /PrintFontRef      % <string|name> <font> PrintFontRef <string|name> <font>
  320. { dup /FontName known { (Font ) } { (CIDFont ) } ifelse print
  321.   1 index =string cvs print
  322.   dup /FontName .knownget not {
  323.     dup /CIDFontName get
  324.   } if                               % <string|name> <font> <fontname>
  325.   dup 3 index ne {
  326.     ( \( aliased from ) print
  327.     =string cvs print ( \)) print
  328.   } {
  329.     pop
  330.   } ifelse
  331. } bind def
  332.  
  333. /GetFontType       % <font> GetFontType int
  334. { dup /CIDFontType .knownget {
  335.     exch pop 9 add
  336.   } {
  337.     /FontType get
  338.   } ifelse
  339. } bind def
  340.  
  341. /FindInArray    % <array> <elem> .array_find <bool>
  342. { false 3 1 roll
  343.   exch {                      % false elem elem_i
  344.     1 index eq {              % false elem
  345.        pop true exch
  346.     } if
  347.   } forall
  348.   pop
  349. } bind def
  350.  
  351. /ProvideUnicodeDecoding % <font> ProvideUnicodeDecoding <font>
  352. {
  353.   % If the font is maintained by FAPI, or if it is TT-emulated CID font,
  354.   % it already has /Decoding. But its value isn't guaranteeed to
  355.   % be an Unicode decoding. Since we can't determine whether 
  356.   % it is an Unicode decoding, we unconditionally load an appropriate Unicode decoding
  357.   % and attach it with /GlyphNames2Unicode entry.
  358.   %
  359.   % Another interesting case is when the font already has /GlyphNames2Unicode.
  360.   % The latter to be used instead. Note that /GlyphNames2Unicode
  361.   % appears only when type 32 fonts are disable (see .pdf_hook_DSC_Creator),
  362.   % but an automatic disabling is not implemented yet.
  363.  
  364.   currentglobal true setglobal exch
  365.   dup /FontInfo known not {
  366.     dup /FontInfo 1 dict put
  367.   } if
  368.   { % A loop just for 'exit' context.
  369.     dup /FontInfo get /GlyphNames2Unicode known {
  370.       exit
  371.     } if
  372.     dup /CIDFontType known {
  373.       dup mark exch                                              % bool <font> [ <font>
  374.       dup /CIDSystemInfo get /Ordering get (.Unicode)            % bool <font> [ <font> () ()
  375.       concatstrings cvn                                          % bool <font> [ <font> /Name
  376.       /CIDDecoding { findresource } stopped {
  377.         % Can't provide a decoding, giving up without creating /GlyphNames2Unicode.
  378.         cleartomark exit
  379.       } if                                                       % bool <font> [ <font> <D>
  380.       exch /FontInfo get exch                                    % bool <font> [ <FI> <D>
  381.       /GlyphNames2Unicode exch
  382.       .forceput % FontInfo can be read-only.
  383.       pop                                                        % bool <font>
  384.       exit
  385.     } if
  386.     dup /FontInfo get                                            % bool <font> <FI>
  387.     /GlyphNames2Unicode /Unicode /Decoding findresource
  388.     .forceput % FontInfo can be read-only.
  389.     exit
  390.   } loop
  391.   exch setglobal
  392. } bind def
  393.  
  394. currentdict end /ProcSet defineresource pop
  395.  
  396. .setlanguagelevel
  397.