head.ps 10.0 KB

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