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