home *** CD-ROM | disk | FTP | other *** search
/ swCHIP 1991 January / swCHIP_95-1.bin / utility / gs333ini / gs3.33 / gs_cidfn.ps < prev    next >
Text File  |  1995-12-09  |  4KB  |  114 lines

  1. %    Copyright (C) 1995 Aladdin Enterprises.  All rights reserved.
  2. % This file is part of Aladdin Ghostscript.
  3. % Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  4. % or distributor accepts any responsibility for the consequences of using it,
  5. % or for whether it serves any particular purpose or works at all, unless he
  6. % or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  7. % License (the "License") for full details.
  8. % Every copy of Aladdin Ghostscript must include a copy of the License,
  9. % normally in a plain ASCII text file named PUBLIC.  The License grants you
  10. % the right to copy, modify and redistribute Aladdin Ghostscript, but only
  11. % under certain conditions described in the License.  Among other things, the
  12. % License requires that the copyright notice and this notice be preserved on
  13. % all copies.
  14.  
  15. % ProcSet for implementing CID-keyed fonts.
  16. % When this is run, systemdict is still writable.
  17.  
  18. %**************** This file isn't even close to being usable.
  19. %**************** It has never been tested, and it has no support for CMaps.
  20. %**************** Don't even think of trying to actually use it.
  21.  
  22. /.setlanguagelevel where { pop 2 .setlanguagelevel } if
  23. .currentglobal true .setglobal
  24. /GS_CIDFont_ProcSet 2 dict dup begin
  25.  
  26. /StartData        % <cidfontdict> <(Binary)|(Hex)> <datalength>
  27.             %   StartData -
  28.  { 2 index begin    % CID font dict
  29.    20 dict begin    % temporary dict
  30.    /datalength exch def
  31.    (Hex) eq /hex exch def
  32.    /cidfont exch def
  33.    /startdata currentfile fileposition def
  34.    
  35.     % Read the character data into an array of strings.
  36.     % There's no particular reason to prefer long strings over short,
  37.     % so we just create a separate string for each character.
  38.  
  39.    /charstrings CIDCount array def
  40.    /fontindices FDArray length FDBytes 1 eq { string } { array } ifelse def
  41.    0 1 CIDCount 1 sub
  42.     { /cid exch def
  43.       currentfile FDBytes GDBytes add cid mul startdata add setfileposition
  44.       fontindices cid FDBytes readint put
  45.       /pos GDBytes readint def
  46.       FDBytes readint pop    % skip FD of next entry
  47.       GDBytes readint pos sub
  48.       dup 0 eq
  49.        { pop null }
  50.        { currentfile pos setfileposition string readstring pop }
  51.       ifelse
  52.       charstrings cid 3 -1 roll put
  53.     }
  54.    for
  55.  
  56.     % Process each font in the FDArray.
  57.     % For Type 3 fonts, just do a definefont with an empty Encoding.
  58.     % For Type 1 fonts, read the Subrs (don't bother to check for
  59.     % duplicates), and set CharStrings to the character data array.
  60.     % We don't support embedded Type 0 fonts, but it isn't clear
  61.     % whether they're allowed anyway.
  62.  
  63.    cidfont /Encoding [ FDArray
  64.     { dup /FontType get 1 eq
  65.        { dup /CharStrings charstrings put
  66.      /Private get
  67.      dup /SubrCount known
  68.       { begin /Subrs [    % Private
  69.         0 1 SubrCount 1 sub
  70.          { SDBytes mul SubrMapOffset add startdata add
  71.            currentfile exch setfileposition
  72.            /pos SDBytes readint def
  73.            SDBytes readint pos sub
  74.            currentfile pos setfileposition string readstring pop
  75.          }
  76.         ] readonly def end    % Private
  77.       }
  78.      if pop
  79.        }
  80.       if
  81.       dup /Encoding [] put
  82.       dup /FontName get exch definefont
  83.     }
  84.    forall ] readonly def
  85.  
  86.     % Install the rest of the data in the font.
  87.  
  88.    cidfont /FontType 0 put    % ???
  89.    cidfont /CharStrings charstrings readonly put
  90.    cidfont /FontIndices fontindices readonly put
  91.    FontName cidfont /CIDFont defineresource pop
  92.  
  93.     % Wrap up.
  94.  
  95.    end            % temporary dict
  96.    end            % CID font dict
  97.    end            % resource dict
  98.  } bind def
  99.  
  100. /readint        % <nbytes> readint <int>
  101.  { 0 exch { 8 bitshift currentfile read pop add } repeat
  102.  } bind def
  103.  
  104. end readonly def
  105.  
  106. /defineresource where
  107.  { pop /CIDFont GS_CIDFont_ProcSet /ProcSet defineresource pop }
  108. if
  109.  
  110. .setglobal
  111.