home *** CD-ROM | disk | FTP | other *** search
/ Acorn User 10 / AU_CD10.iso / Updates / GhostScript / !GhostScr / 6_01 / lib / pcharstr.ps < prev    next >
Text File  |  2000-03-09  |  4KB  |  129 lines

  1. %    Copyright (C) 1990, 1992, 1997, 1999 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. % $Id: pcharstr.ps,v 1.1 2000/03/09 08:40:40 lpd Exp $
  16. % pcharstr.ps
  17. % Print the CharStrings and Subrs (if present) from a Type 1 font,
  18. % in either a PostScript-like or a C-compatible form,
  19. % depending on whether CSFormat is defined as /PS or /C.
  20.  
  21. % Load the Type 1 utilities.
  22. (type1ops.ps) runlibfile
  23.  
  24. % Define the printing procedures for PostScript-like output.
  25. /pcs_ps_dict mark
  26.   /, {( ) print}
  27.   /charname {==only}
  28.   /csbegin {}
  29.   /beginchars {(%---------------- CharStrings\n) print}
  30.   /charbegin {==only}
  31.   /char1 {( ) print ==only}
  32.   /endchars {}
  33.   /beginsubrs {(%---------------- Subrs\n) print}
  34.   /subrbegin {=only}
  35.   /endsubrs {}
  36.   /beginboxes {(%---------------- Encoding & metrics\n) print}
  37.   /notdefbox {}
  38.   /boxbegin {=only ( ) print}
  39.   /boxend {(\n) print}
  40.   /endboxes {(%----------------\n) print}
  41. .dicttomark readonly def
  42.  
  43. % Define the printing procedures for C-like output.
  44. /pcs_c_dict mark
  45.   /, {(, ) print}
  46.   /charname {(") print =only (") print}
  47.   /csbegin {counttomark =only ,}
  48.   /beginchars {(\nconstdata int CSCharData[] = {\n) print}
  49.   /charbegin {pop}
  50.   /char1 {=only ,}
  51.   /endchars {
  52.     (-1\n};\nconstdata char *CSCharNames[] = {\n) print
  53.     CharStrings {pop charname ,} forall (0\n};\n) print
  54.   }
  55.   /beginsubrs {(\nconstdata int CSSubrs[] = {\n) print}
  56.   /subrbegin {pop}
  57.   /endsubrs {(-1\n};\n) print}
  58.   /beginboxes {(\nconstdata type1_box CSboxes[] = {\n) print}
  59.   /notdefbox {(  {""},\n) print}
  60.   /boxbegin {pop (  {) print}
  61.   /boxend {(},) =}
  62.   /endboxes {(  {0}\n};\n) print}
  63. .dicttomark readonly def
  64.  
  65. /printcs
  66.  { dup type /stringtype eq
  67.     { printcs1 (\n) print }
  68.     { ( ) print == }
  69.    ifelse
  70.  } bind def
  71. /printcs1
  72.  { save exch
  73.    lenIV 0 ge {
  74.      4330 exch dup length string .type1decrypt exch pop
  75.      dup length lenIV sub lenIV exch getinterval
  76.    } if
  77.    0 () /SubFileDecode filter
  78.    mark exch charstack_read csbegin
  79.    counttomark 1 sub -1 0 { index char1 } for
  80.    cleartomark restore
  81.  } bind def
  82.  
  83. /printfont
  84.  { pcs_ps_dict
  85.    /CSFormat where { pop CSFormat /C eq { pop pcs_c_dict } if } if
  86.    begin
  87.    currentfont begin Private begin 10 dict begin
  88.  
  89.     % Print the CharStrings and Subrs
  90.  
  91.    beginchars
  92.    CharStrings { exch charbegin printcs } forall
  93.    endchars
  94.    /Subrs where
  95.     { pop    % the dictionary
  96.       beginsubrs
  97.       0 1 Subrs length 1 sub
  98.        { dup subrbegin
  99.          Subrs exch get printcs
  100.        } for
  101.       endsubrs
  102.     } if
  103.  
  104.     % Print the bounding boxes
  105.  
  106.    gsave nulldevice FontMatrix matrix invertmatrix concat
  107.    beginboxes
  108.    0 1 Encoding length 1 sub
  109.     { dup Encoding exch get dup /.notdef eq
  110.        { pop pop notdefbox
  111.        }
  112.        { 1 index boxbegin charname ,
  113.          ( ) dup 0 4 -1 roll put
  114.          newpath 0 0 moveto false charpath
  115.      pathbbox ({) print 4 -1 roll =only ,
  116.      3 -1 roll =only , exch =only , =only (}) print
  117.          boxend
  118.        }
  119.       ifelse
  120.     } for
  121.    endboxes
  122.    grestore
  123.  
  124.    end end end end
  125.  } bind def
  126.