home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2002 February / INTERNET88.ISO / pc / software / windows / bits / pdf995 / data1.cab / Program_Executable_Files / res / pcharstr.ps < prev    next >
Encoding:
Text File  |  2001-12-08  |  3.9 KB  |  130 lines

  1. %    Copyright (C) 1990, 1992, 1997, 1999 Aladdin Enterprises.  All rights reserved.
  2. % This file is part of GNU Ghostscript.
  3. % GNU Ghostscript is distributed in the hope that it will be useful, but
  4. % WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
  5. % to anyone for the consequences of using it or for whether it serves any
  6. % particular purpose or works at all, unless he says so in writing.  Refer
  7. % to the GNU General Public License for full details.
  8. % Everyone is granted permission to copy, modify and redistribute GNU
  9. % Ghostscript, but only under the conditions described in the GNU General
  10. % Public License.  A copy of this license is supposed to have been given
  11. % to you along with GNU Ghostscript so you can know your rights and
  12. % responsibilities.  It should be in a file named COPYING.  Among other
  13. % things, the copyright notice and this notice must be preserved on all
  14. % copies.
  15.  
  16. % $RCSfile: pcharstr.ps,v $ $Revision: 1.2.2.1 $
  17. % pcharstr.ps
  18. % Print the CharStrings and Subrs (if present) from a Type 1 font,
  19. % in either a PostScript-like or a C-compatible form,
  20. % depending on whether CSFormat is defined as /PS or /C.
  21.  
  22. % Load the Type 1 utilities.
  23. (type1ops.ps) runlibfile
  24.  
  25. % Define the printing procedures for PostScript-like output.
  26. /pcs_ps_dict mark
  27.   /, {( ) print}
  28.   /charname {==only}
  29.   /csbegin {}
  30.   /beginchars {(%---------------- CharStrings\n) print}
  31.   /charbegin {==only}
  32.   /char1 {( ) print ==only}
  33.   /endchars {}
  34.   /beginsubrs {(%---------------- Subrs\n) print}
  35.   /subrbegin {=only}
  36.   /endsubrs {}
  37.   /beginboxes {(%---------------- Encoding & metrics\n) print}
  38.   /notdefbox {}
  39.   /boxbegin {=only ( ) print}
  40.   /boxend {(\n) print}
  41.   /endboxes {(%----------------\n) print}
  42. .dicttomark readonly def
  43.  
  44. % Define the printing procedures for C-like output.
  45. /pcs_c_dict mark
  46.   /, {(, ) print}
  47.   /charname {(") print =only (") print}
  48.   /csbegin {counttomark =only ,}
  49.   /beginchars {(\nconstdata int CSCharData[] = {\n) print}
  50.   /charbegin {pop}
  51.   /char1 {=only ,}
  52.   /endchars {
  53.     (-1\n};\nconstdata char *CSCharNames[] = {\n) print
  54.     CharStrings {pop charname ,} forall (0\n};\n) print
  55.   }
  56.   /beginsubrs {(\nconstdata int CSSubrs[] = {\n) print}
  57.   /subrbegin {pop}
  58.   /endsubrs {(-1\n};\n) print}
  59.   /beginboxes {(\nconstdata type1_box CSboxes[] = {\n) print}
  60.   /notdefbox {(  {""},\n) print}
  61.   /boxbegin {pop (  {) print}
  62.   /boxend {(},) =}
  63.   /endboxes {(  {0}\n};\n) print}
  64. .dicttomark readonly def
  65.  
  66. /printcs
  67.  { dup type /stringtype eq
  68.     { printcs1 (\n) print }
  69.     { ( ) print == }
  70.    ifelse
  71.  } bind def
  72. /printcs1
  73.  { save exch
  74.    lenIV 0 ge {
  75.      4330 exch dup length string .type1decrypt exch pop
  76.      dup length lenIV sub lenIV exch getinterval
  77.    } if
  78.    0 () /SubFileDecode filter
  79.    mark exch charstack_read csbegin
  80.    counttomark 1 sub -1 0 { index char1 } for
  81.    cleartomark restore
  82.  } bind def
  83.  
  84. /printfont
  85.  { pcs_ps_dict
  86.    /CSFormat where { pop CSFormat /C eq { pop pcs_c_dict } if } if
  87.    begin
  88.    currentfont begin Private begin 10 dict begin
  89.  
  90.     % Print the CharStrings and Subrs
  91.  
  92.    beginchars
  93.    CharStrings { exch charbegin printcs } forall
  94.    endchars
  95.    /Subrs where
  96.     { pop    % the dictionary
  97.       beginsubrs
  98.       0 1 Subrs length 1 sub
  99.        { dup subrbegin
  100.          Subrs exch get printcs
  101.        } for
  102.       endsubrs
  103.     } if
  104.  
  105.     % Print the bounding boxes
  106.  
  107.    gsave nulldevice FontMatrix matrix invertmatrix concat
  108.    beginboxes
  109.    0 1 Encoding length 1 sub
  110.     { dup Encoding exch get dup /.notdef eq
  111.        { pop pop notdefbox
  112.        }
  113.        { 1 index boxbegin charname ,
  114.          ( ) dup 0 4 -1 roll put
  115.          newpath 0 0 moveto false charpath
  116.      pathbbox ({) print 4 -1 roll =only ,
  117.      3 -1 roll =only , exch =only , =only (}) print
  118.          boxend
  119.        }
  120.       ifelse
  121.     } for
  122.    endboxes
  123.    grestore
  124.  
  125.    end end end end
  126.  } bind def
  127.