home *** CD-ROM | disk | FTP | other *** search
/ jppd.dyndns.org / jppd.dyndns.org.tar / jppd.dyndns.org / QUERYPRO / Impressora_PDF / converter.exe / GPLGS / gs_ciddc.ps < prev    next >
Text File  |  2003-12-13  |  7KB  |  197 lines

  1. %    Copyright (C) 1994, 1996, 1997, 1998, 1999, 2000 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_ciddc.ps,v 1.11.2.1 2003/12/12 22:07:58 giles Exp $
  14. % Define Decoding and CIDDecoding resource categories and related procsets.
  15.  
  16. languagelevel 2 .setlanguagelevel
  17. currentglobal true setglobal
  18.  
  19. %----------------ParseDecoding procset----------------------------
  20.  
  21. /ParseDecoding <<
  22.  
  23. /Parse    % <resource_name> <num_tokens> Parse -
  24. { dict begin                                  % /ResName
  25.   0                                           % /ResName nCode
  26.   { currentfile token not {
  27.       exit
  28.     } if                                      % /ResName nCode token
  29.     dup type /integertype eq {                % /ResName nCode
  30.        exch pop
  31.     } {
  32.       1 index def                             % /ResName nCode
  33.     } ifelse
  34.   } loop                                      % /ResName nCode
  35.   pop                                         % /ResName
  36.   currentdict end /Decoding                   % /ResName <<inst>> /Decoding
  37.   defineresource pop
  38. } bind
  39.  
  40. >> /ProcSet defineresource pop
  41.  
  42. %----------------Decoding category----------------------------
  43.  
  44. /Generic /Category findresource dup length dict copy
  45. dup /InstanceType /dicttype put
  46. /Decoding exch /Category defineresource pop
  47.  
  48. %----------------ParseCMap_Inverse procset----------------------------
  49.  
  50. /ParseCMap_Inverse <<
  51.   /findresource { pop } bind
  52.   /defineresource { pop pop } bind
  53.   /dict {}
  54.   /def { pop pop } bind
  55.   /dup null
  56.   /begin { pop } bind
  57.   /end {}
  58.   /currentdict null
  59.   /CMapName null
  60.   /usecmap { pop } bind
  61.   /begincmap {}
  62.   /endcmap {}
  63.   /begincodespacerange { pop mark } bind
  64.   /endcodespacerange { cleartomark } bind
  65.   /beginnotdefrange { pop mark } bind
  66.   /endnotdefrange { cleartomark } bind
  67.   /beginbfchar { pop mark } bind
  68.   /endbfchar { pop mark } bind
  69.   /beginbfrange { begincidrange }
  70.   /endbfrange { endcidrange }
  71.   /begincidchar { beginbfchar }
  72.   /endcidchar { endbfchar }
  73.   /begincidrange { pop mark } bind
  74.   /endcidrange  { cleartomark } bind
  75. >>  % Just keep it on stack for a while.
  76.  
  77. % Now we define another dict for local binding, than merge it with the previous one :
  78. dup length 5 add dict begin
  79.  
  80.   /.Ranges 40 dict def % Key = CID/256, value = array of 256 integer codes.
  81.   //.Ranges /CIDCount 0 put
  82.  
  83.   /.StringToInt     % <string> .StringToInt <integer>
  84.   { 0 exch { exch 8 bitshift add } forall
  85.   } bind def
  86.  
  87.   /.SetCouple    % <I> <b> .SetCouple -
  88.   { exch                                    % b I
  89.     dup 256 idiv                            % b I I0
  90.     dup //.Ranges exch known not {
  91.       dup //.Ranges exch 256 array put
  92.     } if                                    % b I I0
  93.     //.Ranges exch get                      % b I [Range]
  94.     exch 256 mod                            % b [Range] I1
  95.     3 2 roll put                            %
  96.   } bind def
  97.  
  98.   /endcidrange
  99.   { % Writes the inversed CMap to .Ranges
  100.     counttomark 3 idiv {                    % (b) (e) I
  101.       exch .StringToInt                     % (b) I e
  102.       3 2 roll .StringToInt                 % I e b
  103.       % Note : this code does't handle multidimentional CID ranges.
  104.       % fixme : optimize below.
  105.       dup 3 2 roll exch sub 1 add           % I b d
  106.       { 2 copy //.SetCouple exec            % I b
  107.         1 add exch 1 add exch
  108.       } repeat                              % I b
  109.       pop                                   % I
  110.       dup //.Ranges /CIDCount get gt {      % I
  111.         dup //.Ranges exch /CIDCount exch put
  112.       } if                                  % I
  113.       pop
  114.     } repeat
  115.     pop % mark
  116.   } bind def
  117.  
  118.   /.GetCIDDecoding         % - .GetCIDDEcoding <dict>
  119.   { //.Ranges dup length dict copy
  120.     //.Ranges //.PurgeDict exec
  121.     //.Ranges /CIDCount 0 put
  122.   } bind def
  123.  
  124. currentdict end
  125. exch copy % Merge the dicts - see above.
  126. /ProcSet defineresource pop
  127.  
  128. %----------------CIDDecoding category----------------------------
  129. % Note that we put all instances in global memory - see FindResource.
  130.  
  131. /Generic /Category findresource dup length dict copy
  132. begin
  133.   /Category /CIDDecoding def
  134.   /InstanceType /dicttype def
  135.  
  136.   /.CMapChooser <<
  137.     % This lists CMaps to inverse and unite for creating a CIDDecoding.
  138.     % Choose by FAPIcidfmap.Registry concatenated with TrueType encoding ID.
  139.     % Font renderer must provide the glyph substitution internally.
  140.  
  141.     /CNS1.Big5       [ /ETen-B5-H /ETen-B5-V ]
  142.     /CNS1.Unicode    [ /UniCNS-UCS2-H /UniCNS-UCS2-V]
  143.     /GB1.GB2312      [ /GBK-EUC-H /GBK-EUC-V ]
  144.     /GB1.Unicode     [ /UniGB-UCS2-H /UniGB-UCS2-V ]
  145.     /Japan1.ShiftJIS [ /90ms-RKSJ-H /90ms-RKSJ-V ]
  146.     /Japan1.Unicode  [ /UniJIS-UCS2-H  /UniJIS-UCS2-V]
  147.     /Japan2.ShiftJIS [ /90ms-RKSJ-H /90ms-RKSJ-V ]
  148.     /Japan2.Unicode  [ /UniHojo-UCS2-H ]
  149.     /Korea1.Johab    [ /KSC-Johab-V /KSC-Johab-H ]
  150.     /Korea1.Wansung  [ /KSCms-UHC-V /KSCms-UHC-H ]
  151.     /Korea1.Unicode  [ /UniKS-UCS2-H /UniKS-UCS2-V ]
  152.   >> def
  153.  
  154.   /.MakeInstance    % <name> .MakeInstance <inst>
  155.   { dup                                              % /Name /Name
  156.     //.CMapChooser exch .knownget not {
  157.       (Can't build /) print =string cvs print ( /CIDDecoding resource. See gs_ciddc.ps . ) =
  158.       /findresource cvx /undefinedresource signalerror
  159.     } if                                             % /Name [CMaps]
  160.     exch pop                                         % [CMaps]
  161.     /CMap /Category findresource                     % [CMaps] <CMapCategory>
  162.     /ParseCMap_Inverse /ProcSet findresource         % [CMaps] <CMapCategory> <PCI>
  163.     3 2 roll {                                       % <CMapCategory> <PCI> /CMapName
  164.       3 2 roll begin                                 % <PCI> /CMapName
  165.       dup .ResourceFile not {
  166.         (Can't find CMap ) print =string cvs print ( building a CIDDecoding resource. ) =
  167.         /findresource cvx /undefinedresource signalerror
  168.       } if
  169.       currentdict end exch                           % <PCI> /CMapName <CMapCategory> file
  170.  
  171.       3 index begin
  172.       cvx exec                                       % <PCI> /CMapName <CMapCategory>
  173.       end
  174.       exch pop exch                                  % <CMapCategory> <PCI>
  175.     } forall
  176.     exch pop begin                                   %
  177.     .GetCIDDecoding
  178.     end
  179.   } bind def
  180.  
  181.   /FindResource      % <name> FindResource <dict>
  182.   { currentglobal exch                               % bGlobal /InstName
  183.     true setglobal
  184.     dup //.MakeInstance exec                         % bGlobal /InstName <Inst>
  185.     DefineResource                                   % bGlobal <Inst>
  186.     exch setglobal                                   % <Inst>
  187.   } bind def
  188.  
  189. currentdict end
  190. /CIDDecoding exch /Category defineresource pop
  191.  
  192. setglobal
  193. .setlanguagelevel
  194.