doc: Update changes
[nasm.git] / doc / head.ps
blob7fbb3a90622c63d96a3be362e5f21732edd7d31c
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 /indt0 { bullmarg exch moveto bfont bwidth showstreamjust } def
262 /indt1 { bullmarg exch moveto bfont bwidth showstreamjust } def
263 /indt2 { bullmarg exch moveto bfont showstream } def
264 /indt3 { bullmarg exch moveto bfont showstream } def
266 /bquo0 { bullmarg exch moveto qfont bwidth showstreamjust } def
267 /bquo1 { bullmarg exch moveto qfont bwidth showstreamjust } def
268 /bquo2 { bullmarg exch moveto qfont showstream } def
269 /bquo3 { bullmarg exch moveto qfont showstream } def
271 /tocw0 lwidth tocpnz sub def
272 /tocw1 tocw0 tocind sub def
273 /tocw2 tocw1 tocind sub def
275 /tocx0 lmarg def
276 /tocx1 tocx0 tocind add def
277 /tocx2 tocx1 tocind add def
279 /tocpn {
280   bfont0 setfont
281   3 dict begin
282     /s exch def
283     /x s stringwidth pop pagewidth rmarg sub exch sub def
284     currentpoint /y exch def
285     lmarg sub tocdots div ceiling tocdots mul lmarg add
286     tocdots x {
287       y moveto (.) 0 linkshow
288     } for
289     x y moveto s 0 linkshow
290   end
291   linkend
292 } def
294 /toc00 { tocx0 exch moveto 0 rmoveto bfont showstream } def
295 /toc01 { tocx0 exch moveto
296          linkbegindest bfont0 setfont 0 linkshow bfont showstream } def
297 /toc02 { tocx0 exch moveto 3 1 roll
298          0 rmoveto bfont showstream tocpn } def
299 /toc03 { tocx0 exch moveto 4 1 roll
300          linkbegindest bfont0 setfont 0 linkshow bfont showstream tocpn } def
302 /toc10 { tocx1 exch moveto 0 rmoveto bfont showstream } def
303 /toc11 { tocx1 exch moveto
304          linkbegindest bfont0 setfont 0 linkshow bfont showstream } def
305 /toc12 { tocx1 exch moveto 3 1 roll
306          0 rmoveto bfont showstream tocpn } def
307 /toc13 { tocx1 exch moveto 4 1 roll
308          linkbegindest bfont0 setfont 0 linkshow bfont showstream tocpn } def
310 /toc20 { tocx2 exch moveto 0 rmoveto bfont showstream } def
311 /toc21 { tocx2 exch moveto
312          linkbegindest bfont0 setfont 0 linkshow bfont showstream } def
313 /toc22 { tocx2 exch moveto 3 1 roll
314          0 rmoveto bfont showstream tocpn } def
315 /toc23 { tocx2 exch moveto 4 1 roll
316          linkbegindest bfont0 setfont 0 linkshow bfont showstream tocpn } def
318 % Spacing between index columns
319 /indexcolumn pagewidth lmarg sub rmarg sub idxgutter add idxcolumns div def
320 % Width of an individual index column
321 /indexcolwid indexcolumn idxgutter sub def
323 /idx03 {
324   2 dict begin
325     indexcolumn mul lmarg add
326     /x exch def /y exch def x y moveto
327     exch bfont showstream
328     dup bfont streamwidth
329     x indexcolwid add exch sub exch pop y moveto
330     bfont showstream
331   end
332 } def
333 /idx00 {idx03} def
334 /idx01 {idx03} def
335 /idx02 {idx03} def
337 /idx13 {
338   2 dict begin
339     indexcolumn mul lmarg add idxindent add
340     /x exch def /y exch def x y moveto
341     exch bfont showstream
342     dup bfont streamwidth
343     x indexcolwid idxindent sub add exch sub exch pop y moveto
344     bfont showstream
345   end
346 } def
347 /idx10 {idx13} def
348 /idx11 {idx13} def
349 /idx12 {idx13} def
352 % Page numbers
354 /pagey botmarg pymarg sub def
355 /pagel lmarg plmarg sub def
356 /pager pagewidth rmarg sub prmarg add def
358 /pageeven { pagel pagey moveto bfont1 setfont show } def
359 /pageodd  { bfont1 setfont dup stringwidth pop pager exch sub
360             pagey moveto show } def
363 % Functions invoked during parsing
365 /xa { linkdest } def
366 /pa { 0 pageheight moveto linkdest } def
367 /xl { linkbegindest } def
368 /wl { linkbeginuri } def
369 /pl { linkbeginpage } def
370 /el { linkend } def
373 % PDF viewer options
375 [/PageMode /UseOutlines /DOCVIEW pdfmark        % Display bookmarks
378 % Functions to include EPS
380 /BeginEPSF {
381   /Before_EPSF_State save def
382   /dict_count countdictstack def
383   /op_count count 1 sub def
384   userdict begin
385   /showpage {} def
386   0 setgray 0 setlinecap
387   1 setlinewidth 0 setlinejoin
388   10 setmiterlimit [ ] 0 setdash newpath
389   /languagelevel where
390   {
391     pop languagelevel
392     1 ne {
393       false setstrokeadjust false setoverprint
394     } if
395   } if
396 } bind def
397 /EndEPSF {
398   count op_count sub {pop} repeat
399   countdictstack dict_count sub {end} repeat
400   Before_EPSF_State restore
401 } bind def