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_type1.ps < prev    next >
Text File  |  1996-10-12  |  5KB  |  128 lines

  1. %    Copyright (C) 1994, 1995, 1996 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. % Type 1 font support code.
  16.  
  17. % The standard representation for PostScript compatible fonts is described
  18. % in the book "Adobe Type 1 Font Format", published by Adobe Systems Inc.
  19.  
  20. % Define an augmented version of .buildfont1 that inserts UnderlinePosition
  21. % and UnderlineThickness entries in FontInfo if they aren't there already.
  22. % (This works around the incorrect assumption, made by many word processors,
  23. % that these entries are present in the built-in fonts.)
  24. /.buildfont1
  25.  { dup /FontInfo known not
  26.     { .growfontdict dup /FontInfo 2 dict put }
  27.    if
  28.    dup dup /FontInfo get dup dup
  29.    /UnderlinePosition known exch /UnderlineThickness known and
  30.     { pop pop       % entries already present
  31.     }
  32.     { dup length 2 add dict .copydict
  33.       dup /UnderlinePosition known not
  34.        { dup /UnderlinePosition 3 index /FontBBox get
  35.          1 get 2 div put        % 1/2 the font descent
  36.        }
  37.       if
  38.       dup /UnderlineThickness known not
  39.        { dup /UnderlineThickness 3 index /FontBBox get
  40.          dup 3 get exch 1 get sub 20 div put    % 1/20 the font height
  41.        }
  42.       if
  43.       1 index /FontInfo get wcheck not { readonly } if
  44.       /FontInfo exch put
  45.     }
  46.    ifelse //.buildfont1
  47.  } bind def
  48. % If the diskfont feature isn't included, define a dummy .loadfontdict.
  49. /.loadfontdict where
  50.  { pop }
  51.  { /.loadfontdict 0 dict readonly def }
  52. ifelse
  53. /.loadfontfile      % <file> .loadfontfile -
  54.  { mark exch //systemdict begin
  55.    DISKFONTS { .loadfontdict begin } if
  56.    % We really would just like systemdict on the stack,
  57.    % but fonts produced by Fontographer require a writable dictionary....
  58.    userdict begin
  59.     % We can't just use `run', because we want to check for .PFB files.
  60.    currentpacking
  61.     { false setpacking .loadfont1 true setpacking }
  62.     { .loadfont1 }
  63.    ifelse
  64.     { stop } if
  65.    end
  66.    DISKFONTS { end } if
  67.    end cleartomark
  68.  } bind def
  69. /.loadfont1     % <file> .loadfont1 <errorflag>
  70.  {  % We would like to use `false /PFBDecode filter',
  71.     % but this occasionally produces a whitespace character as
  72.     % the first of an eexec section, so we can't do it.
  73.     % Also, since the real input file never reaches EOF if we are using
  74.     % a PFBDecode filter (the filter stops just after reading the last
  75.     % character), we must explicitly close the real file in this case.
  76.     % Since the file might leave garbage on the operand stack,
  77.     % we have to create a procedure to close the file reliably.
  78.     { dup read not { -1 } if
  79.       2 copy unread 16#80 eq
  80.        { [ exch dup true /PFBDecode filter cvx exch cvlit
  81.          //systemdict /closefile get ]
  82.        }
  83.       if cvx exec
  84.     } stopped
  85.    $error /newerror get and dup { .clearerror } if
  86.  } bind def
  87.  
  88.  
  89. % The CharStrings are a dictionary in which the key is the character name,
  90. % and the value is a compressed and encrypted representation of a path.
  91. % For detailed information, see the book "Adobe Type 1 Font Format",
  92. % published by Adobe Systems Inc.
  93.  
  94. % Here are the BuildChar and BuildGlyph implementation for Type 1 fonts.
  95. % The names %Type1BuildChar and %Type1BuildGlyph are known to the interpreter.
  96. % The real work is done in an operator:
  97. %   <font> <code|name> <name> <charstring> .type1execchar -
  98.  
  99. (%Type1BuildChar) cvn   % <font> <code> %Type1BuildChar -
  100.  { 1 index /Encoding get 1 index get .type1build
  101.  } bind def
  102. (%Type1BuildGlyph) cvn  % <font> <name> %Type1BuildGlyph -
  103.  { dup .type1build
  104.  } bind def
  105. /.type1build        % <font> <code|name> <name> .type1build -
  106.  { 2 index begin
  107.     dup CharStrings exch .knownget not
  108.      { 2 copy eq { exch pop /.notdef exch } if
  109.        QUIET not
  110.     { (Substituting .notdef for ) print = flush }
  111.     { pop }
  112.        ifelse
  113.        /.notdef CharStrings /.notdef get
  114.      } if
  115.    end .type1execchar
  116.  } bind def
  117. % CCRun is an undocumented procedure provided for Type 4 fonts.
  118. 1183615869 internaldict begin
  119. /CCRun          % <font> <code|name> <charstring> CCRun -
  120.  { 1 index dup type /integertype eq
  121.     { 3 index /Encoding get exch get }
  122.    if exch .type1execchar
  123.  } bind def
  124. end
  125.