|
|
1.1 root 1: %
2: % Prologue for building troff width tables. The gsave/grestore pairs are
3: % for hardcopy.
4: %
5:
6: /slowdown 25 def
7: /flagduplicates false def
8:
9: /ascenderheight -1 def
10: /descenderdepth 0 def
11: /octalescapes 256 def
12: /startcomments 256 def
13: /currentfontdict null def
14: /scratchstring 512 string def
15:
16: /Print {
17: scratchstring cvs print flush
18: slowdown {1 pop} repeat
19: } def
20:
21: /ReEncode { % vector fontname ReEncode -
22: dup
23: findfont dup length dict begin
24: {1 index /FID ne {def}{pop pop} ifelse} forall
25: /Encoding 3 -1 roll def
26: currentdict
27: end
28: definefont pop
29: } bind def
30:
31: /SelectFont { % fontname SelectFont -
32: findfont
33: dup /PaintType get 0 eq {
34: /scaling 1 def
35: unitwidth resolution 72.0 div mul
36: }{
37: /scaling resolution 72 div def
38: unitwidth
39: } ifelse
40: scalefont
41: /currentfontdict exch def
42: } def
43:
44: /ChangeMetrics {DpostPrologue begin addmetrics end} def
45:
46: /NamedInPrologue {
47: dup
48: DpostPrologue exch known {
49: DpostPrologue exch get type /nametype eq {
50: (named in prologue\n) Print
51: } if
52: }{pop} ifelse
53: } def
54:
55: /SetAscender {
56: /str exch def
57:
58: gsave
59: currentfontdict setfont
60: newpath
61: 0 0 moveto
62: str false charpath flattenpath pathbbox
63: /descenderdepth 4 -1 roll .5 mul def
64: exch pop exch pop
65:
66: newpath
67: 0 0 moveto
68: str 0 1 getinterval false charpath flattenpath pathbbox
69: 4 1 roll pop pop pop
70: dup 3 1 roll sub .25 mul add
71: /ascenderheight exch def
72: grestore
73: } def
74:
75: /GetAscender {
76: ascenderheight descenderdepth ge {
77: gsave
78: currentfontdict setfont
79: newpath
80: 0 0 moveto
81: ( ) dup 0 4 -1 roll put
82: false charpath flattenpath pathbbox
83: exch pop 3 -1 roll pop
84: ascenderheight gt {2}{0} ifelse
85: exch descenderdepth lt {1}{0} ifelse
86: or
87: grestore
88: }{0} ifelse
89: } def
90:
91: /GetWidth {
92: gsave
93: currentfontdict setfont
94: ( ) dup 0 4 -1 roll put
95: stringwidth pop scaling mul round cvi
96: grestore
97: } def
98:
99: /GetCode {
100: 256 3 1 roll % last unprintable match
101: 0 3 -1 roll {
102: 2 index eq {
103: dup 127 and 32 ge {exit} if
104: 3 -1 roll pop
105: dup 3 1 roll
106: } if
107: 1 add
108: } forall
109: exch pop
110: dup 255 gt {pop}{exch pop} ifelse
111: } def
112:
113: /BuildFontCharset {
114: 0 2 charset length 2 sub {
115: /i exch def
116: /chcode -1 def
117: /chname null def
118: /key charset i get def
119: /val charset i 1 add get def
120:
121: val type /integertype eq {
122: /chcode val def
123: /chname currentfontdict /Encoding get chcode get def
124: } if
125:
126: val type /nametype eq {
127: /chname val def
128: /chcode currentfontdict /Encoding get chname GetCode def
129: } if
130:
131: val type /stringtype eq {/chcode 0 def} if
132:
133: chcode 0 lt chcode 255 gt or {
134: chcode 0 lt {(syntaxerror: )}{(undefinedname: )} ifelse
135: Print key Print (\t) Print val Print (\n) Print
136: quit
137: } if
138:
139: val type /stringtype eq {
140: key Print
141: (\t) Print val Print
142: (\n) Print
143: }{
144: chcode octalescapes ge key (---) eq and {
145: (\\0) Print chcode 8 ( ) cvrs Print
146: }{key Print} ifelse
147: (\t) Print chcode GetWidth Print
148: (\t) Print chcode GetAscender Print
149: (\t) Print chcode Print
150: chcode startcomments ge {
151: (\t# ) Print chname Print
152: } if
153: (\n) Print
154: chcode octalescapes ge (---) key ne and {
155: key (\\0) anchorsearch not {
156: pop
157: (\\0) Print chcode 8 ( ) cvrs Print
158: (\t"\n) Print
159: }{pop pop} ifelse
160: } if
161: } ifelse
162: } for
163: } def
164:
165: /BuildDescCharset {
166: /DescDict 512 dict def
167: /Characters 0 def
168:
169: 0 1 charset length 1 sub {
170: /i exch def
171: /key charset i get def
172:
173: key length 2 eq {
174: DescDict key cvn known {
175: flagduplicates { % for debugging
176: (<<<duplicated character: ) Print
177: key Print
178: (>>>\n) Print
179: } if
180: }{
181: DescDict key cvn 1 put
182: key Print
183: /Characters Characters 1 add def
184: Characters 20 mod 0 eq {(\n)}{( )} ifelse Print
185: } ifelse
186: } if
187: } for
188: } def
189:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.