doc: ps/pdf: set page numbers in normal-sized italic
[nasm/autotest.git] / doc / head.ps
blob48b7af21a38b75e3c3654d82c2226a1988264323
2 % PostScript header for NASM documentation
5 % Avoid barfing on old PS implementations
6 /pdfmark where
7 {pop} {userdict /pdfmark /cleartomark load put} ifelse
8 /setpagedevice where
9 {pop} {userdict /setpagedevice /pop load put} ifelse
11 % Useful definition
12 /space 32 def
15 % This asks the PostScript interpreter for the proper size paper
17 /setpagesize {
18   1 dict dup /PageSize [pagewidth pageheight] put setpagedevice
19 } def
22 % Code to handle links
24 /min { 2 copy gt { exch } if pop } def
25 /max { 2 copy lt { exch } if pop } def
27 /lkbegun 0 def
28 /lktype null def
29 /lkury 0 def
30 /lkurx 0 def
31 /lklly 0 def
32 /lkllx 0 def
33 /lkxmarg 1 def  % Extra space for link in x dir
34 /lkymarg 1 def  % Extra space for link in y dir
35 /lktarget () def
37 % target type --
38 /linkbegin {
39   userdict begin
40     /lkbegun 1 def
41     /lktype exch def
42     /lktarget exch def
43     colorlinks { 0 0 0.4 setrgbcolor } if
44   end
45 } def
47 % target --
48 /linkbegindest {
49   /Dest linkbegin
50 } def
52 % uristring --
53 /linkbeginuri {
54   /URI linkbegin
55 } def
57 % pageno --
58 /linkbeginpage {
59   /Page linkbegin
60 } def
62 % string spacepadding --
63 /linkshow {
64   userdict begin
65     /lspad exch def /lss exch def
66     lkbegun 0 ne {
67       gsave lss true charpath flattenpath pathbbox grestore
68       lkbegun 1 eq {
69         /lkury exch def
70         lss spacecount lspad mul add /lkurx exch def
71         /lklly exch def
72         /lkllx exch def
73         /lkbegun 2 def
74       } {
75         lkury max /lkury exch def
76         lss spacecount lspad mul add lkurx max /lkurx exch def
77         lklly min /lklly exch def
78         lkllx min /lkllx exch def
79       } ifelse
80     } if
81     lspad 0 space lss widthshow
82   end
83 } def
85 % --
86 /linkend {
87   userdict begin
88     [ lktype /URI eq {
89         /Action 2 dict dup /Subtype /URI put dup /URI lktarget put
90       } {
91         /Dest lktarget
92       } ifelse
93       /Border [0 0 0]
94       /Rect [ lkllx lkxmarg sub
95               lklly lkymarg sub
96               lkurx lkxmarg add
97               lkury lkymarg add ]
98       /Subtype /Link
99       /ANN pdfmark
100     /lkbegun 0 def
101     colorlinks { 0 setgray } if
102   end
103 } def
105 % targetname --
106 /linkdest {
107   [ /Dest 3 -1 roll
108     /View [ /XYZ currentpoint null ]
109     /DEST pdfmark
110 } def
112 % A "fontset" is an array of fonts; a "stream" is an array of strings
113 % and numbers or procedures:
114 % [ 0 (Foo) ( ) (mani) ( ) 1 (padme) 0 ( ) (hum.) ]
115 % A number choses a font from the current fontset.
116 % A procedure is invoked as-is when printing the stream.
118 % When printing justified, an equal amount of space is added in
119 % between each string.
121 % string -- spacecount
122 % Count space characters in a string
123 /spacecount {
124   0 exch {
125     space eq { 1 add } if
126   } forall
127 } def
129 % stream fontset -- spacecount width
130 % Get the width of a stream in the given fontset, and the
131 % number of space characters in the stream
132 /streamwidth {
133   gsave
134     6 dict begin
135       /f exch def
136       /w 0 def
137       /s 0 def
138       f 0 get setfont
139       /integertype {
140         f exch get setfont
141       } def
142       /stringtype {
143         dup stringwidth pop w add /w exch def
144         spacecount s add /s exch def
145       } def
146       /arraytype { pop } def
147       % The input stream is on the top of the stack now
148       {
149         dup type exec
150       } forall
151       s w
152     end
153   grestore
154 } def
156 % stream fontset spacer --
157 % Show the stream in the given fontset, but add a certain amount
158 % of space to each space character
159 /showstreamspc {
160   5 dict begin
161     /spc exch def
162     /f exch def
163     f 0 get setfont
164     /integertype {
165       f exch get setfont
166     } def
167     /stringtype {
168       spc linkshow
169     } def
170     /arraytype {
171       exec
172     } def
173     % Now stream is on the top of the stack
174     {
175       dup type exec
176     } forall
177   end
178 } def
180 % stream fontset --
181 % Show the stream in the given fontset, with no extra spacing
182 /showstream {
183   0 showstreamspc
184 } def
186 % stream fontset totalspace --
187 % Show the stream justified to fit into a certain number of pixels
188 /showstreamjust {
189   userdict begin
190     /ts exch def /fs exch def /st exch def
191       st fs
192         st fs streamwidth ts exch sub exch
193         dup 0 gt { div } { pop } ifelse
194       showstreamspc
195     end
196 } def
198 /bullmarg lmarg bulladj add def
199 /lwidth pagewidth lmarg sub rmarg sub def
200 /bwidth lwidth bulladj sub def
203 % The various paragraph types
204 % The number at the end indicates start (1) of para, end (2) of para
206 /chapline {
207         currentpoint exch pop 10 sub lmarg exch moveto
208         0 setlinecap 3 setlinewidth
209         lwidth 0 rlineto stroke
210 } def
212 /chap0 { lmarg exch moveto cfont lwidth showstreamjust } def
213 /chap1 { lmarg exch moveto cfont lwidth showstreamjust } def
214 /chap2 { lmarg exch moveto cfont showstream chapline } def
215 /chap3 { lmarg exch moveto cfont showstream chapline } def
217 /appn0 {chap0} def
218 /appn1 {chap1} def
219 /appn2 {chap2} def
220 /appn3 {chap3} def
222 % lbl ypos fontset -- ypos
223 /headlbl {
224   3 -1 roll [exch (  )] exch % ypos strm fontset
225   2 copy % ypos strm fontset strm fontset
226   streamwidth % ypos strm fontset spccount width
227   lmarg exch sub % ypos strm fontset spccount xpos
228   4 index % ypos strm fontset spccount xpos ypos
229   moveto % ypos strm fontset spccount
230   pop % ypos strm fontset spccount
231   showstream % ypos
232 } def
234 /head0 { lmarg exch moveto hfont lwidth showstreamjust } def
235 /head1 { hfont headlbl lmarg exch moveto hfont lwidth showstreamjust } def
236 /head2 { lmarg exch moveto hfont showstream } def
237 /head3 { hfont headlbl lmarg exch moveto hfont showstream } def
239 /subh0 { lmarg exch moveto sfont lwidth showstreamjust } def
240 /subh1 { sfont headlbl lmarg exch moveto sfont lwidth showstreamjust } def
241 /subh2 { lmarg exch moveto sfont showstream } def
242 /subh3 { sfont headlbl lmarg exch moveto sfont showstream } def
244 /norm0 { lmarg exch moveto bfont lwidth showstreamjust } def
245 /norm1 { lmarg exch moveto bfont lwidth showstreamjust } def
246 /norm2 { lmarg exch moveto bfont showstream } def
247 /norm3 { lmarg exch moveto bfont showstream } def
249 /code0 { lmarg exch moveto bfont showstream } def
250 /code1 { lmarg exch moveto bfont showstream } def
251 /code2 { lmarg exch moveto bfont showstream } def
252 /code3 { lmarg exch moveto bfont showstream } def
254 /bull0 { bullmarg exch moveto bfont bwidth showstreamjust } def
255 /bull1 { dup lmarg exch moveto bullet bfont showstream
256          bullmarg exch moveto bfont bwidth showstreamjust } def
257 /bull2 { bullmarg exch moveto bfont showstream } def
258 /bull3 { dup lmarg exch moveto bullet bfont showstream
259          bullmarg exch moveto bfont showstream } def
261 /tocw0 lwidth tocpnz sub def
262 /tocw1 tocw0 tocind sub def
263 /tocw2 tocw1 tocind sub def
265 /tocx0 lmarg def
266 /tocx1 tocx0 tocind add def
267 /tocx2 tocx1 tocind add def
269 /tocpn {
270   bfont0 setfont
271   3 dict begin
272     /s exch def
273     /x s stringwidth pop pagewidth rmarg sub exch sub def
274     currentpoint /y exch def
275     lmarg sub tocdots div ceiling tocdots mul lmarg add
276     tocdots x {
277       y moveto (.) 0 linkshow
278     } for
279     x y moveto s 0 linkshow
280   end
281   linkend
282 } def
284 /toc00 { tocx0 exch moveto 0 rmoveto bfont showstream } def
285 /toc01 { tocx0 exch moveto
286          linkbegindest bfont0 setfont 0 linkshow bfont showstream } def
287 /toc02 { tocx0 exch moveto 3 1 roll
288          0 rmoveto bfont showstream tocpn } def
289 /toc03 { tocx0 exch moveto 4 1 roll
290          linkbegindest bfont0 setfont 0 linkshow bfont showstream tocpn } def
292 /toc10 { tocx1 exch moveto 0 rmoveto bfont showstream } def
293 /toc11 { tocx1 exch moveto
294          linkbegindest bfont0 setfont 0 linkshow bfont showstream } def
295 /toc12 { tocx1 exch moveto 3 1 roll
296          0 rmoveto bfont showstream tocpn } def
297 /toc13 { tocx1 exch moveto 4 1 roll
298          linkbegindest bfont0 setfont 0 linkshow bfont showstream tocpn } def
300 /toc20 { tocx2 exch moveto 0 rmoveto bfont showstream } def
301 /toc21 { tocx2 exch moveto
302          linkbegindest bfont0 setfont 0 linkshow bfont showstream } def
303 /toc22 { tocx2 exch moveto 3 1 roll
304          0 rmoveto bfont showstream tocpn } def
305 /toc23 { tocx2 exch moveto 4 1 roll
306          linkbegindest bfont0 setfont 0 linkshow bfont showstream tocpn } def
308 % Spacing between index columns
309 /indexcolumn pagewidth lmarg sub rmarg sub idxgutter add idxcolumns div def
310 % Width of an individual index column
311 /indexcolwid indexcolumn idxgutter sub def
313 /idx03 {
314   2 dict begin
315     indexcolumn mul lmarg add
316     /x exch def /y exch def x y moveto
317     exch bfont showstream
318     dup bfont streamwidth
319     x indexcolwid add exch sub exch pop y moveto
320     bfont showstream
321   end
322 } def
323 /idx00 {idx03} def
324 /idx01 {idx03} def
325 /idx02 {idx03} def
327 /idx13 {
328   2 dict begin
329     indexcolumn mul lmarg add idxindent add
330     /x exch def /y exch def x y moveto
331     exch bfont showstream
332     dup bfont streamwidth
333     x indexcolwid idxindent sub add exch sub exch pop y moveto
334     bfont showstream
335   end
336 } def
337 /idx10 {idx13} def
338 /idx11 {idx13} def
339 /idx12 {idx13} def
342 % Page numbers
344 /pagey botmarg pymarg sub def
345 /pagel lmarg plmarg sub def
346 /pager pagewidth rmarg sub prmarg add def
348 /pageeven { pagel pagey moveto bfont1 setfont show } def
349 /pageodd  { bfont1 setfont dup stringwidth pop pager exch sub
350             pagey moveto show } def
353 % Functions invoked during parsing
355 /xa { linkdest } def
356 /pa { 0 pageheight moveto linkdest } def
357 /xl { linkbegindest } def
358 /wl { linkbeginuri } def
359 /pl { linkbeginpage } def
360 /el { linkend } def
363 % PDF viewer options
365 [/PageMode /UseOutlines /DOCVIEW pdfmark        % Display bookmarks
368 % Functions to include EPS
370 /BeginEPSF {
371   /Before_EPSF_State save def
372   /dict_count countdictstack def
373   /op_count count 1 sub def
374   userdict begin
375   /showpage {} def
376   0 setgray 0 setlinecap
377   1 setlinewidth 0 setlinejoin
378   10 setmiterlimit [ ] 0 setdash newpath
379   /languagelevel where
380   {
381     pop languagelevel
382     1 ne {
383       false setstrokeadjust false setoverprint
384     } if
385   } if
386 } bind def
387 /EndEPSF {
388   count op_count sub {pop} repeat
389   countdictstack dict_count sub {end} repeat
390   Before_EPSF_State restore
391 } bind def