blob: 4cfc0ea40c644b1938a7071c84b4268301c1c5a4 (
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
|
% $Id$
%
% PostScript header for NASM documentation
%
% Avoid barfing on old PS implementations
/pdfmark where
{pop} {userdict /pdfmark /cleartomark load put} ifelse
/setpagedevice where
{pop} {userdict /setpagedevice /pop load put} ifelse
% Useful definition
/space 32 def
%
% This asks the PostScript interpreter for the proper size paper
%
/setpagesize {
1 dict dup /PageSize [pagewidth pageheight] put setpagedevice
} def
%
% Code to handle links
%
/min { 2 copy gt { exch } if pop } def
/max { 2 copy lt { exch } if pop } def
/lkbegun 0 def
/lktype null def
/lkury 0 def
/lkurx 0 def
/lklly 0 def
/lkllx 0 def
/lkxmarg 1 def % Extra space for link in x dir
/lkymarg 1 def % Extra space for link in y dir
/lktarget () def
% target type --
/linkbegin {
userdict begin
/lkbegun 1 def
/lktype exch def
/lktarget exch def
colorlinks { 0 0 0.4 setrgbcolor } if
end
} def
% target --
/linkbegindest {
/Dest linkbegin
} def
% uristring --
/linkbeginuri {
/URI linkbegin
} def
% pageno --
/linkbeginpage {
/Page linkbegin
} def
% string spacepadding --
/linkshow {
userdict begin
/lspad exch def /lss exch def
lkbegun 0 ne {
gsave lss true charpath flattenpath pathbbox grestore
lkbegun 1 eq {
/lkury exch def
lss spacecount lspad mul add /lkurx exch def
/lklly exch def
/lkllx exch def
/lkbegun 2 def
} {
lkury max /lkury exch def
lss spacecount lspad mul add lkurx max /lkurx exch def
lklly min /lklly exch def
lkllx min /lkllx exch def
} ifelse
} if
lspad 0 space lss widthshow
end
} def
% --
/linkend {
userdict begin
[ lktype /URI eq {
/Action 2 dict dup /Subtype /URI put dup /URI lktarget put
} {
/Dest lktarget
} ifelse
/Border [0 0 0]
/Rect [ lkllx lkxmarg sub
lklly lkymarg sub
lkurx lkxmarg add
lkury lkymarg add ]
/Subtype /Link
/ANN pdfmark
/lkbegun 0 def
colorlinks { 0 setgray } if
end
} def
% targetname --
/linkdest {
[ /Dest 3 -1 roll
/View [ /XYZ currentpoint null ]
/DEST pdfmark
} def
% A "fontset" is an array of fonts; a "stream" is an array of strings
% and numbers or procedures:
% [ 0 (Foo) ( ) (mani) ( ) 1 (padme) 0 ( ) (hum.) ]
% A number choses a font from the current fontset.
% A procedure is invoked as-is when printing the stream.
%
% When printing justified, an equal amount of space is added in
% between each string.
% string -- spacecount
% Count space characters in a string
/spacecount {
0 exch {
space eq { 1 add } if
} forall
} def
% stream fontset -- spacecount width
% Get the width of a stream in the given fontset, and the
% number of space characters in the stream
/streamwidth {
gsave
6 dict begin
/f exch def
/w 0 def
/s 0 def
f 0 get setfont
/integertype {
f exch get setfont
} def
/stringtype {
dup stringwidth pop w add /w exch def
spacecount s add /s exch def
} def
/arraytype { pop } def
% The input stream is on the top of the stack now
{
dup type exec
} forall
s w
end
grestore
} def
% stream fontset spacer --
% Show the stream in the given fontset, but add a certain amount
% of space to each space character
/showstreamspc {
5 dict begin
/spc exch def
/f exch def
f 0 get setfont
/integertype {
f exch get setfont
} def
/stringtype {
spc linkshow
} def
/arraytype {
exec
} def
% Now stream is on the top of the stack
{
dup type exec
} forall
end
} def
% stream fontset --
% Show the stream in the given fontset, with no extra spacing
/showstream {
0 showstreamspc
} def
% stream fontset totalspace --
% Show the stream justified to fit into a certain number of pixels
/showstreamjust {
userdict begin
/ts exch def /fs exch def /st exch def
st fs
st fs streamwidth ts exch sub exch
dup 0 gt { div } { pop } ifelse
showstreamspc
end
} def
/bullmarg lmarg bulladj add def
/lwidth pagewidth lmarg sub rmarg sub def
/bwidth lwidth bulladj sub def
%
% The various paragraph types
% The number at the end indicates start (1) of para, end (2) of para
%
/chapline {
currentpoint exch pop 10 sub lmarg exch moveto
0 setlinecap 3 setlinewidth
lwidth 0 rlineto stroke
} def
/chap0 { lmarg exch moveto cfont lwidth showstreamjust } def
/chap1 { lmarg exch moveto cfont lwidth showstreamjust } def
/chap2 { lmarg exch moveto cfont showstream chapline } def
/chap3 { lmarg exch moveto cfont showstream chapline } def
/appn0 {chap0} def
/appn1 {chap1} def
/appn2 {chap2} def
/appn3 {chap3} def
% lbl ypos fontset -- ypos
/headlbl {
3 -1 roll [exch ( )] exch % ypos strm fontset
2 copy % ypos strm fontset strm fontset
streamwidth % ypos strm fontset spccount width
lmarg exch sub % ypos strm fontset spccount xpos
4 index % ypos strm fontset spccount xpos ypos
moveto % ypos strm fontset spccount
pop % ypos strm fontset spccount
showstream % ypos
} def
/head0 { lmarg exch moveto hfont lwidth showstreamjust } def
/head1 { hfont headlbl lmarg exch moveto hfont lwidth showstreamjust } def
/head2 { lmarg exch moveto hfont showstream } def
/head3 { hfont headlbl lmarg exch moveto hfont showstream } def
/subh0 { lmarg exch moveto sfont lwidth showstreamjust } def
/subh1 { sfont headlbl lmarg exch moveto sfont lwidth showstreamjust } def
/subh2 { lmarg exch moveto sfont showstream } def
/subh3 { sfont headlbl lmarg exch moveto sfont showstream } def
/norm0 { lmarg exch moveto bfont lwidth showstreamjust } def
/norm1 { lmarg exch moveto bfont lwidth showstreamjust } def
/norm2 { lmarg exch moveto bfont showstream } def
/norm3 { lmarg exch moveto bfont showstream } def
/code0 { lmarg exch moveto bfont showstream } def
/code1 { lmarg exch moveto bfont showstream } def
/code2 { lmarg exch moveto bfont showstream } def
/code3 { lmarg exch moveto bfont showstream } def
/bullet [(\225)] def
/bull0 { bullmarg exch moveto bfont bwidth showstreamjust } def
/bull1 { dup lmarg exch moveto bullet bfont showstream
bullmarg exch moveto bfont bwidth showstreamjust } def
/bull2 { bullmarg exch moveto bfont showstream } def
/bull3 { dup lmarg exch moveto bullet bfont showstream
bullmarg exch moveto bfont showstream } def
/tocw0 lwidth tocpnz sub def
/tocw1 tocw0 tocind sub def
/tocw2 tocw1 tocind sub def
/tocx0 lmarg def
/tocx1 tocx0 tocind add def
/tocx2 tocx1 tocind add def
/tocpn {
bfont0 setfont
3 dict begin
/s exch def
/x s stringwidth pop pagewidth rmarg sub exch sub def
currentpoint /y exch def
lmarg sub tocdots div ceiling tocdots mul lmarg add
tocdots x {
y moveto (.) 0 linkshow
} for
x y moveto s 0 linkshow
end
linkend
} def
/toc00 { tocx0 exch moveto 0 rmoveto bfont showstream } def
/toc01 { tocx0 exch moveto
linkbegindest bfont0 setfont 0 linkshow bfont showstream } def
/toc02 { tocx0 exch moveto 3 1 roll
0 rmoveto bfont showstream tocpn } def
/toc03 { tocx0 exch moveto 4 1 roll
linkbegindest bfont0 setfont 0 linkshow bfont showstream tocpn } def
/toc10 { tocx1 exch moveto 0 rmoveto bfont showstream } def
/toc11 { tocx1 exch moveto
linkbegindest bfont0 setfont 0 linkshow bfont showstream } def
/toc12 { tocx1 exch moveto 3 1 roll
0 rmoveto bfont showstream tocpn } def
/toc13 { tocx1 exch moveto 4 1 roll
linkbegindest bfont0 setfont 0 linkshow bfont showstream tocpn } def
/toc20 { tocx2 exch moveto 0 rmoveto bfont showstream } def
/toc21 { tocx2 exch moveto
linkbegindest bfont0 setfont 0 linkshow bfont showstream } def
/toc22 { tocx2 exch moveto 3 1 roll
0 rmoveto bfont showstream tocpn } def
/toc23 { tocx2 exch moveto 4 1 roll
linkbegindest bfont0 setfont 0 linkshow bfont showstream tocpn } def
% Spacing between index columns
/indexcolumn pagewidth lmarg sub rmarg sub idxgutter add idxcolumns div def
% Width of an individual index column
/indexcolwid indexcolumn idxgutter sub def
/idx03 {
2 dict begin
indexcolumn mul lmarg add
/x exch def /y exch def x y moveto
exch bfont showstream
dup bfont streamwidth
x indexcolwid add exch sub exch pop y moveto
bfont showstream
end
} def
/idx00 {idx03} def
/idx01 {idx03} def
/idx02 {idx03} def
/idx13 {
2 dict begin
indexcolumn mul lmarg add idxindent add
/x exch def /y exch def x y moveto
exch bfont showstream
dup bfont streamwidth
x indexcolwid idxindent sub add exch sub exch pop y moveto
bfont showstream
end
} def
/idx10 {idx13} def
/idx11 {idx13} def
/idx12 {idx13} def
%
% Page numbers
%
/pagey botmarg pymarg sub def
/pagel lmarg plmarg sub def
/pager pagewidth rmarg sub prmarg add def
/pageeven { pagel pagey moveto sfont0 setfont show } def
/pageodd { sfont0 setfont dup stringwidth pop pager exch sub
pagey moveto show } def
%
% Functions invoked during parsing
%
/xa { linkdest } def
/pa { 0 pageheight moveto linkdest } def
/xl { linkbegindest } def
/wl { linkbeginuri } def
/pl { linkbeginpage } def
/el { linkend } def
%
% PDF viewer options
%
[/PageMode /UseOutlines /DOCVIEW pdfmark % Display bookmarks
|