summaryrefslogtreecommitdiff
path: root/Master/xemtex/gslib/pcharstr.ps
blob: 06d6a29ca52ea704fe13fe30486e61c9ac7f80d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
%    Copyright (C) 1990, 1992, 1997, 1999 Aladdin Enterprises.  All rights reserved.
% 
% This program is free software; you can redistribute it and/or modify it
% under the terms of the GNU General Public License as published by the
% Free Software Foundation; either version 2 of the License, or (at your
% option) any later version.
%
% This program is distributed in the hope that it will be useful, but
% WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
% Public License for more details.
%
% You should have received a copy of the GNU General Public License along
% with this program; if not, write to the Free Software Foundation, Inc.,
% 59 Temple Place, Suite 330, Boston, MA, 02111-1307.

% $Id: pcharstr.ps,v 1.2.6.1.2.1 2003/04/12 14:02:39 giles Exp $
% pcharstr.ps
% Print the CharStrings and Subrs (if present) from a Type 1 font,
% in either a PostScript-like or a C-compatible form,
% depending on whether CSFormat is defined as /PS or /C.

% Load the Type 1 utilities.
(type1ops.ps) runlibfile

% Define the printing procedures for PostScript-like output.
/pcs_ps_dict mark
  /, {( ) print}
  /charname {==only}
  /csbegin {}
  /beginchars {(%---------------- CharStrings\n) print}
  /charbegin {==only}
  /char1 {( ) print ==only}
  /endchars {}
  /beginsubrs {(%---------------- Subrs\n) print}
  /subrbegin {=only}
  /endsubrs {}
  /beginboxes {(%---------------- Encoding & metrics\n) print}
  /notdefbox {}
  /boxbegin {=only ( ) print}
  /boxend {(\n) print}
  /endboxes {(%----------------\n) print}
.dicttomark readonly def

% Define the printing procedures for C-like output.
/pcs_c_dict mark
  /, {(, ) print}
  /charname {(") print =only (") print}
  /csbegin {counttomark =only ,}
  /beginchars {(\nconstdata int CSCharData[] = {\n) print}
  /charbegin {pop}
  /char1 {=only ,}
  /endchars {
    (-1\n};\nconstdata char *CSCharNames[] = {\n) print
    CharStrings {pop charname ,} forall (0\n};\n) print
  }
  /beginsubrs {(\nconstdata int CSSubrs[] = {\n) print}
  /subrbegin {pop}
  /endsubrs {(-1\n};\n) print}
  /beginboxes {(\nconstdata type1_box CSboxes[] = {\n) print}
  /notdefbox {(  {""},\n) print}
  /boxbegin {pop (  {) print}
  /boxend {(},) =}
  /endboxes {(  {0}\n};\n) print}
.dicttomark readonly def

/printcs
 { dup type /stringtype eq
    { printcs1 (\n) print }
    { ( ) print == }
   ifelse
 } bind def
/printcs1
 { save exch
   lenIV 0 ge {
     4330 exch dup length string .type1decrypt exch pop
     dup length lenIV sub lenIV exch getinterval
   } if
   0 () /SubFileDecode filter
   mark exch charstack_read csbegin
   counttomark 1 sub -1 0 { index char1 } for
   cleartomark restore
 } bind def

/printfont
 { pcs_ps_dict
   /CSFormat where { pop CSFormat /C eq { pop pcs_c_dict } if } if
   begin
   currentfont begin Private begin 10 dict begin

	% Print the CharStrings and Subrs

   beginchars
   CharStrings { exch charbegin printcs } forall
   endchars
   /Subrs where
    { pop	% the dictionary
      beginsubrs
      0 1 Subrs length 1 sub
       { dup subrbegin
         Subrs exch get printcs
       } for
      endsubrs
    } if

	% Print the bounding boxes

   gsave nulldevice FontMatrix matrix invertmatrix concat
   beginboxes
   0 1 Encoding length 1 sub
    { dup Encoding exch get dup /.notdef eq
       { pop pop notdefbox
       }
       { 1 index boxbegin charname ,
         ( ) dup 0 4 -1 roll put
         newpath 0 0 moveto false charpath
	 pathbbox ({) print 4 -1 roll =only ,
	 3 -1 roll =only , exch =only , =only (}) print
         boxend
       }
      ifelse
    } for
   endboxes
   grestore

   end end end end
 } bind def