home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / OSK / APPS / gs403osk.tgz / gs403osk.tar / gs_cidfn.ps < prev    next >
Text File  |  1996-09-22  |  4KB  |  123 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 is not ready for use:
  19. %   - It doesn't include the actual character mapper (BuildGlyph).
  20. %   - It loads the entire font into RAM.
  21. %   - It has never been tested on a real font.
  22.  
  23. /.setlanguagelevel where { pop 2 .setlanguagelevel } if
  24. .currentglobal true .setglobal
  25.  
  26. /GS_CIDInit_ProcSet 30 dict dup begin
  27.  
  28. % ---------------- CIDFont operators ---------------- %
  29.  
  30. /StartData      % <cidfontdict> <(Binary)|(Hex)> <datalength>
  31.             %   StartData -
  32.  { 2 index begin    % CID font dict
  33.    20 dict begin    % temporary dict
  34.    /datalength exch def
  35.    (Hex) eq /hex exch def
  36.    /cidfont exch def
  37.    /startdata currentfile fileposition def
  38.    
  39.     % Read the character data into an array of strings.
  40.     % There's no particular reason to prefer long strings over short,
  41.     % so we just create a separate string for each character.
  42.  
  43.    /charstrings CIDCount array def
  44.    /fontindices CIDCount FDBytes 1 eq { string } { array } ifelse def
  45.    0 1 CIDCount 1 sub
  46.     { /cid exch def
  47.       currentfile FDBytes GDBytes add cid mul startdata add setfileposition
  48.       fontindices cid FDBytes .readint put
  49.       charstrings cid
  50.       /pos GDBytes .readint def
  51.       FDBytes .readint pop  % skip FD of next entry
  52.       GDBytes .readint pos sub
  53.       dup 0 eq
  54.        { pop null }
  55.        { currentfile pos setfileposition string readstring pop }
  56.       ifelse put
  57.     }
  58.    for
  59.  
  60.     % Process each font in the FDArray.
  61.     % For Type 3 fonts, just do a definefont with an empty Encoding.
  62.     % For Type 1 fonts, read the Subrs (don't bother to check for
  63.     % duplicates), and set CharStrings to the character data array.
  64.     % We don't support embedded Type 0 fonts, but it isn't clear
  65.     % whether they're allowed anyway.
  66.  
  67.    cidfont /FDepVector [ FDArray
  68.     { dup /FontType get 1 eq
  69.        { dup /CharStrings charstrings put
  70.      /Private get
  71.      dup /SubrCount known
  72.       { begin /Subrs [  % Private
  73.         0 1 SubrCount 1 sub
  74.          { SDBytes mul SubrMapOffset add startdata add
  75.            currentfile exch setfileposition
  76.            /pos SDBytes .readint def
  77.            SDBytes .readint pos sub
  78.            currentfile pos setfileposition string readstring pop
  79.          }
  80.         ] readonly def end  % Private
  81.       }
  82.      if pop
  83.        }
  84.       if
  85.       dup /Encoding [] put
  86.       dup /FontName get exch definefont
  87.     }
  88.    forall ] readonly def
  89.  
  90.     % Install the rest of the data in the font.
  91.  
  92.    cidfont /CharStrings charstrings readonly put
  93.    cidfont /FontIndices fontindices readonly put
  94.    FontName cidfont /CIDFont defineresource pop
  95.  
  96.     % Wrap up.
  97.  
  98.    end          % temporary dict
  99.    end          % CID font dict
  100.    end          % resource dict
  101.  } bind def
  102.  
  103. /.readint       % <nbytes> .readint <int>
  104.  { 0 exch { 8 bitshift currentfile read pop add } repeat
  105.  } bind def
  106.  
  107. % ---------------- Resource category definition ---------------- %
  108.  
  109. end readonly def
  110.  
  111. /defineresource where
  112.  { pop
  113.    /CIDFont /Generic /Category findresource dup length dict .copydict
  114.    /Category defineresource pop
  115.    /CIDInit GS_CIDInit_ProcSet /ProcSet defineresource pop
  116.  }
  117. if
  118.  
  119. .setglobal
  120.