ps-prin1.ps 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873
  1. % === BEGIN ps-print prologue 1
  2. % version: 6.1
  3. % Copyright (C) 2000-2012 Free Software Foundation, Inc.
  4. % This file is part of GNU Emacs.
  5. % GNU Emacs is free software: you can redistribute it and/or modify
  6. % it under the terms of the GNU General Public License as published by
  7. % the Free Software Foundation, either version 3 of the License, or
  8. % (at your option) any later version.
  9. % GNU Emacs is distributed in the hope that it will be useful,
  10. % but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. % GNU General Public License for more details.
  13. % You should have received a copy of the GNU General Public License
  14. % along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  15. % As a special exception, the copyright holders of this module give
  16. % you permission to include the module in a Postscript file generated
  17. % by Emacs or other free software together with the result of
  18. % converting text to be printed, regardless of the license terms of
  19. % that text, and to use under terms of your choice the page images
  20. % resulting from formatting said combination. If you modify this
  21. % module, you may extend this exception to your version of the module
  22. % but you are not obligated to do so. If you do not wish to do so,
  23. % delete this exception statement from your version.
  24. % ISOLatin1Encoding stolen from ps_init.ps in GhostScript 2.6.1.4:
  25. /ISOLatin1Encoding where{pop}{
  26. % -- The ISO Latin-1 encoding vector isn't known, so define it.
  27. % -- The first half is the same as the standard encoding,
  28. % -- except for minus instead of hyphen at code 055.
  29. /ISOLatin1Encoding
  30. StandardEncoding 0 45 getinterval aload pop
  31. /minus
  32. StandardEncoding 46 82 getinterval aload pop
  33. %*** NOTE: the following are missing in the Adobe documentation,
  34. %*** but appear in the displayed table:
  35. %*** macron at 0225, dieresis at 0230, cedilla at 0233, space at 0240.
  36. % 0200 (128)
  37. /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  38. /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  39. /dotlessi/grave/acute/circumflex/tilde/macron/breve/dotaccent
  40. /dieresis/.notdef/ring/cedilla/.notdef/hungarumlaut/ogonek/caron
  41. % 0240 (160)
  42. /space/exclamdown/cent/sterling
  43. /currency/yen/brokenbar/section
  44. /dieresis/copyright/ordfeminine/guillemotleft
  45. /logicalnot/hyphen/registered/macron
  46. /degree/plusminus/twosuperior/threesuperior
  47. /acute/mu/paragraph/periodcentered
  48. /cedilla/onesuperior/ordmasculine/guillemotright
  49. /onequarter/onehalf/threequarters/questiondown
  50. % 0300 (192)
  51. /Agrave/Aacute/Acircumflex/Atilde
  52. /Adieresis/Aring/AE/Ccedilla
  53. /Egrave/Eacute/Ecircumflex/Edieresis
  54. /Igrave/Iacute/Icircumflex/Idieresis
  55. /Eth/Ntilde/Ograve/Oacute
  56. /Ocircumflex/Otilde/Odieresis/multiply
  57. /Oslash/Ugrave/Uacute/Ucircumflex
  58. /Udieresis/Yacute/Thorn/germandbls
  59. % 0340 (224)
  60. /agrave/aacute/acircumflex/atilde
  61. /adieresis/aring/ae/ccedilla
  62. /egrave/eacute/ecircumflex/edieresis
  63. /igrave/iacute/icircumflex/idieresis
  64. /eth/ntilde/ograve/oacute
  65. /ocircumflex/otilde/odieresis/divide
  66. /oslash/ugrave/uacute/ucircumflex
  67. /udieresis/yacute/thorn/ydieresis
  68. 256 packedarray def
  69. }ifelse
  70. /reencodeFontISO{ %def
  71. dup
  72. length 12 add dict % Make a new font (a new dict the same size
  73. % as the old one) with room for our new symbols.
  74. begin % Make the new font the current dictionary.
  75. % Copy each of the symbols from the old dictionary
  76. % to the new one except for the font ID.
  77. {1 index/FID ne{def}{pop pop}ifelse}forall
  78. % Override the encoding with the ISOLatin1 encoding.
  79. currentdict/FontType get 0 ne{/Encoding ISOLatin1Encoding def}if
  80. % Use the font's bounding box to determine the ascent, descent,
  81. % and overall height; don't forget that these values have to be
  82. % transformed using the font's matrix.
  83. % ^ (x2 y2)
  84. % | |
  85. % | v
  86. % | +----+ - -
  87. % | | | ^
  88. % | | | | Ascent (usually > 0)
  89. % | | | |
  90. % (0 0) -> +--+----+-------->
  91. % | | |
  92. % | | v Descent (usually < 0)
  93. % (x1 y1) --> +----+ - -
  94. currentdict/FontType get 0 ne
  95. {/FontBBox load aload pop % -- x1 y1 x2 y2
  96. FontMatrix transform/Ascent exch def pop
  97. FontMatrix transform/Descent exch def pop}
  98. {/PrimaryFont FDepVector 0 get def
  99. PrimaryFont/FontBBox get aload pop
  100. PrimaryFont/FontMatrix get transform/Ascent exch def pop
  101. PrimaryFont/FontMatrix get transform/Descent exch def pop}ifelse
  102. /FontHeight Ascent Descent sub def % use `sub' because descent < 0
  103. % Define these in case they're not in the FontInfo
  104. % (also, here they're easier to get to).
  105. /UnderlinePosition Descent 0.70 mul def
  106. /OverlinePosition Descent UnderlinePosition sub Ascent add def
  107. /StrikeoutPosition Ascent 0.30 mul def
  108. /LineThickness FontHeight 0.05 mul def
  109. /Xshadow FontHeight 0.08 mul def
  110. /Yshadow FontHeight -0.09 mul def
  111. /SpaceBackground Descent neg UnderlinePosition add def
  112. /XBox Descent neg def
  113. /YBox LineThickness 0.7 mul def
  114. currentdict % Leave the new font on the stack
  115. end % Stop using the font as the current dictionary.
  116. definefont % Put the font into the font dictionary
  117. pop % Discard the returned font.
  118. }bind def
  119. % Font definition
  120. /DefFont{findfont exch scalefont reencodeFontISO}def
  121. % Font selection
  122. /F{
  123. findfont
  124. dup/Ascent get/Ascent exch def
  125. dup/Descent get/Descent exch def
  126. dup/FontHeight get/FontHeight exch def
  127. dup/UnderlinePosition get/UnderlinePosition exch def
  128. dup/OverlinePosition get/OverlinePosition exch def
  129. dup/StrikeoutPosition get/StrikeoutPosition exch def
  130. dup/LineThickness get/LineThickness exch def
  131. dup/Xshadow get/Xshadow exch def
  132. dup/Yshadow get/Yshadow exch def
  133. dup/SpaceBackground get/SpaceBackground exch def
  134. dup/XBox get/XBox exch def
  135. dup/YBox get/YBox exch def
  136. setfont
  137. }def
  138. /FG/setrgbcolor load def
  139. /bg false def
  140. /BG{
  141. dup/bg exch def
  142. {[4 1 roll]}
  143. {[1.0 1.0 1.0]}
  144. ifelse
  145. /bgcolor exch def
  146. }def
  147. % B width C
  148. % +-----------+
  149. % | Ascent (usually > 0)
  150. % A + +
  151. % | Descent (usually < 0)
  152. % +-----------+
  153. % E width D
  154. /dobackground{ % width --
  155. currentpoint % -- width x y
  156. gsave
  157. newpath
  158. moveto % A (x y)
  159. 0 Ascent rmoveto % B
  160. dup 0 rlineto % C
  161. 0 Descent Ascent sub rlineto % D
  162. neg 0 rlineto % E
  163. closepath
  164. FillBgColor
  165. grestore
  166. }def
  167. /eolbg{ % dobackground until right margin
  168. PrintWidth % -- x-eol
  169. currentpoint pop % -- cur-x
  170. sub % -- width until eol
  171. dobackground
  172. }def
  173. /LineHS LineHeight LineSpacing add def
  174. /ParagraphHS LineHeight ParagraphSpacing add def
  175. /PSL{/h exch def bg{eolbg}if 0 currentpoint exch pop h sub moveto}def
  176. /PLN{PrintLineNumber{doLineNumber}if}def
  177. /SL{LineHS PSL isLineStep pop}def % Soft Linefeed
  178. /PHL{ParagraphHS PSL PLN}def % Paragraph Hard Linefeed
  179. /LHL{LineHS PSL PLN}def % Hard Linefeed
  180. % Some debug
  181. /dcp{currentpoint exch 40 string cvs print(, )print =}def
  182. /dp{print 2 copy exch 40 string cvs print(, )print =}def
  183. /W{
  184. ( )stringwidth % Get the width of a space in the current font.
  185. pop % Discard the Y component.
  186. mul % Multiply the width of a space
  187. % by the number of spaces to plot
  188. bg{dup dobackground}if
  189. 0 rmoveto
  190. }def
  191. /Effect 0 def
  192. /EffectUnderline false def
  193. /EffectStrikeout false def
  194. /EffectOverline false def
  195. /EffectShadow false def
  196. /EffectBox false def
  197. /EffectOutline false def
  198. % effect: 1 - underline 2 - strikeout 4 - overline
  199. % 8 - shadow 16 - box 32 - outline
  200. /EF{
  201. /Effect exch def
  202. /EffectUnderline Effect 1 and 0 ne def
  203. /EffectStrikeout Effect 2 and 0 ne def
  204. /EffectOverline Effect 4 and 0 ne def
  205. /EffectShadow Effect 8 and 0 ne def
  206. /EffectBox Effect 16 and 0 ne def
  207. /EffectOutline Effect 32 and 0 ne def
  208. }def
  209. % stack: string |- --
  210. /S{
  211. /xx currentpoint dup Descent add/yy exch def
  212. Ascent add/YY exch def def
  213. dup stringwidth pop xx add/XX exch def
  214. EffectShadow{
  215. /yy yy Yshadow add def
  216. /XX XX Xshadow add def
  217. }if
  218. bg{
  219. true
  220. EffectBox
  221. {SpaceBackground doBox}
  222. {xx yy XX YY doRect}
  223. ifelse
  224. }if % background
  225. EffectBox {false 0 doBox}if % box
  226. EffectShadow {dup doShadow}if % shadow
  227. EffectOutline
  228. {true doOutline} % outline
  229. {show} % normal text
  230. ifelse
  231. EffectUnderline{UnderlinePosition Hline}if % underline
  232. EffectStrikeout{StrikeoutPosition Hline}if % strikeout
  233. EffectOverline {OverlinePosition Hline}if % overline
  234. }bind def
  235. % stack: position |- --
  236. /Hline{
  237. currentpoint exch pop add dup
  238. gsave
  239. newpath
  240. xx exch moveto
  241. XX exch lineto
  242. closepath
  243. LineThickness setlinewidth stroke
  244. grestore
  245. }bind def
  246. % stack: fill-or-not delta |- --
  247. /doBox{
  248. /dd exch def
  249. xx XBox sub dd sub yy YBox sub dd sub
  250. XX XBox add dd add YY YBox add dd add
  251. doRect
  252. }bind def
  253. % stack: fill-or-not lower-x lower-y upper-x upper-y |- --
  254. /doRect{
  255. /rYY exch def
  256. /rXX exch def
  257. /ryy exch def
  258. /rxx exch def
  259. gsave
  260. newpath
  261. rXX rYY moveto
  262. rxx rYY lineto
  263. rxx ryy lineto
  264. rXX ryy lineto
  265. closepath
  266. % top of stack: fill-or-not
  267. {FillBgColor}
  268. {LineThickness setlinewidth stroke}ifelse
  269. grestore
  270. }bind def
  271. % stack: string |- --
  272. /doShadow{
  273. gsave
  274. Xshadow Yshadow rmoveto
  275. false doOutline
  276. grestore
  277. }bind def
  278. /st 1 string def
  279. % stack: string fill-or-not |- --
  280. /doOutline{
  281. /-fillp- exch def
  282. /-ox- currentpoint/-oy- exch def def
  283. gsave
  284. LineThickness setlinewidth
  285. {st 0 3 -1 roll put
  286. st dup true charpath
  287. -fillp- {gsave FillBgColor grestore}if
  288. stroke stringwidth
  289. -oy- add/-oy- exch def
  290. -ox- add/-ox- exch def
  291. -ox- -oy- moveto
  292. }forall
  293. grestore
  294. -ox- -oy- moveto
  295. }bind def
  296. % stack: --
  297. /FillBgColor{bgcolor aload pop setrgbcolor fill}bind def
  298. % stack: -- |- boolean
  299. /isLineStep{
  300. SyncLineZebra
  301. {PLScounter 0 gt % or zebra
  302. {/PLScounter PLScounter 1 sub def PLScounter 0 eq}
  303. {false}ifelse
  304. PrintLineStep 1 gt
  305. {/PrintLineStep PrintLineStep 1 sub def}
  306. {/PrintLineStep ZebraHeight def
  307. /PLScounter PrintLineStart def}ifelse}
  308. {LineNumber PrintLineStart sub PrintLineStep mod 0 eq}ifelse % or line step
  309. }def
  310. % stack: --
  311. /doLineNumber{
  312. /LineNumber where
  313. {pop
  314. isLineStep % or line step
  315. LineNumber Lines ge or % or last line
  316. {currentfont
  317. gsave
  318. LineNumberColor SetColor
  319. /L0 findfont setfont
  320. LineNumber Lines ge
  321. {(end )}
  322. {LineNumber 6 string cvs( )strcat}ifelse
  323. dup stringwidth pop neg 0 rmoveto
  324. show
  325. grestore
  326. setfont}if
  327. /LineNumber LineNumber 1 add def
  328. }if
  329. }def
  330. % stack: color-specifier |- --
  331. /SetColor{dup type/realtype eq{setgray}{aload pop setrgbcolor}ifelse}def
  332. % stack: --
  333. /printZebra{
  334. gsave
  335. ZebraColor SetColor
  336. /double-zebra ZebraHeight ZebraHeight add def
  337. /yiter double-zebra LineHS mul neg def
  338. /xiter PrintWidth InterColumn add def
  339. /zebra-line LinesPrinted def
  340. NumberOfColumns{LinesPerColumn doColumnZebra xiter 0 rmoveto}repeat
  341. grestore
  342. }def
  343. % stack: lines-per-column |- --
  344. /doColumnZebra{
  345. /lpc exch def
  346. gsave
  347. ZebraFollow 1 and 0 ne{
  348. /H ZebraHeight zebra-line ZebraHeight mod sub def
  349. /lpc lpc H sub def
  350. zebra-line double-zebra mod ZebraHeight lt
  351. {H doZebra % "black" stripe followed by a "white" stripe
  352. /lpc lpc ZebraHeight sub def
  353. H ZebraHeight add}
  354. {H}ifelse % "white" stripe
  355. LineHS mul neg 0 exch rmoveto
  356. /zebra-line zebra-line LinesPerColumn add def
  357. }if
  358. /zspacing 0 def
  359. lpc dup double-zebra idiv{ZebraHeight doZebra 0 yiter rmoveto}repeat
  360. double-zebra mod dup 0 le{pop}
  361. {dup ZebraHeight gt
  362. {pop ZebraHeight}
  363. {/zspacing LineSpacing def
  364. ZebraFollow 2 and 0 ne{pop ZebraHeight}if}ifelse
  365. doZebra}ifelse
  366. grestore
  367. }def
  368. % stack: zebra-height (in lines) |- --
  369. /doZebra{
  370. /zh exch 0.05 sub LineHS mul zspacing sub def
  371. gsave
  372. 0 LineHeight 0.65 mul rmoveto
  373. PrintWidth 0 rlineto
  374. 0 zh neg rlineto
  375. PrintWidth neg 0 rlineto
  376. 0 zh rlineto
  377. fill
  378. grestore
  379. }def
  380. % stack: --
  381. /printBackground{
  382. /BackgroundColor where{
  383. /LHg LineHeight 0.65 mul def
  384. /PHg PrintHeight LHg add def
  385. pop gsave BackgroundColor SetColor
  386. NumberOfColumns{
  387. gsave
  388. 0 LHg rmoveto
  389. PrintWidth 0 rlineto
  390. 0 PHg neg rlineto
  391. PrintWidth neg 0 rlineto
  392. 0 PHg rlineto
  393. fill
  394. grestore
  395. PrintWidth InterColumn add 0 rmoveto
  396. }repeat
  397. grestore
  398. }if
  399. }def
  400. % tx ty rotation xscale yscale xpos ypos BeginBackImage
  401. /BeginBackImage{
  402. /-save-image- save def
  403. /showpage{}def
  404. translate
  405. scale
  406. rotate
  407. translate
  408. }def
  409. /EndBackImage{-save-image- restore}def
  410. % string fontsize fontname rotation gray xpos ypos ShowBackText
  411. /ShowBackText{
  412. gsave
  413. translate
  414. setgray
  415. rotate
  416. findfont exch dup/-offset- exch -0.25 mul def scalefont setfont
  417. 0 -offset- moveto
  418. /-saveLineThickness- LineThickness def
  419. /LineThickness 1 def
  420. false doOutline
  421. /LineThickness -saveLineThickness- def
  422. grestore
  423. }def
  424. /SetPageSize{
  425. BMark/PageSize[PageWidth LandscapePageHeight LandscapeMode{exch}if]EMark setpagedevice
  426. }def
  427. /BeginDoc{
  428. % ---- Remember space width of the normal text font `f0'.
  429. /SpaceWidth/f0 findfont setfont( )stringwidth pop def
  430. % ---- save the state of the document (useful for ghostscript!)
  431. /docState save def
  432. % ---- [andrewi] set PageSize based on chosen dimensions
  433. UseSetpagedevice{
  434. WarnPaperSize{SetPageSize}{mark{SetPageSize}stopped cleartomark}ifelse
  435. }if
  436. /ColumnWidth PrintWidth InterColumn add def
  437. % ---- define where printing will start
  438. /f0 F % this installs Ascent
  439. /PrintStartY PrintHeight Ascent sub def
  440. /ColumnIndex 1 def
  441. /N-Up-Counter N-Up-End 1 sub def
  442. /PLScounter PrintLineStart def
  443. }def
  444. /EndDoc{
  445. % ---- restore the state of the document (useful for ghostscript!)
  446. docState restore
  447. }def
  448. /BeginDSCPage{
  449. % ---- when 1st column, save the state of the page
  450. ColumnIndex 1 eq{/pageState save def}if
  451. % ---- save the state of the column
  452. /columnState save def
  453. }def
  454. /PrintHeaderWidth PrintOnlyOneHeader{PrintPageWidth}{PrintWidth}ifelse def
  455. /BeginPage{
  456. /LinesPrinted exch def
  457. % ---- when 1st column, print all background effects
  458. ColumnIndex 1 eq{
  459. 0 PrintStartY moveto % move to where printing will start
  460. printBackground
  461. Zebra{printZebra}if
  462. printGlobalBackground
  463. printLocalBackground
  464. }if
  465. PrintOnlyOneHeader{ColumnIndex 1 eq}{true}ifelse
  466. dup PrintHeader and{
  467. PrintHeaderFrame{HeaderFrame}if
  468. HeaderText
  469. }if
  470. PrintFooter and{
  471. PrintFooterFrame{FooterFrame}if
  472. FooterText
  473. }if
  474. 0 PrintStartY moveto % move to where printing will start
  475. /LineNumber where
  476. {pop
  477. SyncLineZebra
  478. {/H PageNumber 1 sub NumberOfColumns mul ColumnIndex 1 sub add
  479. LinesPerColumn mul ZebraHeight mod def
  480. /PLScounter H PrintLineStart ge{0}{PrintLineStart H sub}ifelse def
  481. /PrintLineStep ZebraHeight H sub def}if}if
  482. PLN
  483. }def
  484. /EndPage{bg{eolbg}if}def
  485. /EndDSCPage{
  486. ColumnIndex NumberOfColumns eq{
  487. % ---- restore the state of the page
  488. pageState restore
  489. /ColumnIndex 1 def
  490. % ---- N-up printing
  491. N-Up 1 gt{
  492. N-Up-Counter 0 gt
  493. {% ---- Next page on same row
  494. /N-Up-Counter N-Up-Counter 1 sub def
  495. N-Up-XColumn N-Up-YColumn}
  496. {% ---- Next page on next line
  497. /N-Up-Counter N-Up-End 1 sub def
  498. N-Up-XLine N-Up-YLine}ifelse
  499. translate
  500. }if
  501. }{ % else
  502. % ---- restore the state of the current column
  503. columnState restore
  504. % ---- and translate to the next column
  505. ColumnWidth 0 translate
  506. /ColumnIndex ColumnIndex 1 add def
  507. }ifelse
  508. }def
  509. /TextStart{
  510. LeftMargin BottomMargin
  511. PrintFooter{
  512. FooterPad add
  513. FooterLines FooterLineHeight mul add
  514. FooterPad add
  515. FooterOffset add}if
  516. }def
  517. % stack: number-of-pages-per-sheet |- --
  518. /BeginSheet{
  519. /sheetState save def
  520. /pages-per-sheet exch def
  521. % ---- translate to bottom-right corner of Portrait page
  522. LandscapeMode{
  523. LandscapePageHeight 0 translate
  524. 90 rotate
  525. }if
  526. % ---- [jack] Kludge: my ghostscript window is 21x27.7 instead of 21x29.7
  527. /JackGhostscript where{pop 1 27.7 29.7 div scale}if
  528. UpsideDown{PageWidth LandscapePageHeight translate 180 rotate}if
  529. % ---- N-Up printing
  530. N-Up 1 gt{
  531. % ---- landscape
  532. N-Up-Landscape{
  533. PageWidth 0 translate
  534. 90 rotate
  535. }if
  536. N-Up-Margin dup translate
  537. % ---- scale
  538. LandscapeMode{
  539. /HH PageWidth def
  540. /WW LandscapePageHeight def
  541. }{
  542. /HH LandscapePageHeight def
  543. /WW PageWidth def
  544. }ifelse
  545. /xx 0 def
  546. N-Up-Landscape{
  547. /ww WW WW mul N-Up-Lines HH mul div def
  548. /cc HH N-Up-Columns N-Up-Missing add div def
  549. ww cc gt{/xx WW def/WW cc ww div WW mul def/xx xx WW sub def}if
  550. }{
  551. /hh HH N-Up-Columns N-Up-Missing add div def
  552. /cc HH N-Up-Lines div def
  553. hh cc gt{/xx WW def/WW cc hh div WW mul def/xx xx WW sub def}if
  554. }ifelse
  555. WW N-Up-Margin sub N-Up-Margin sub
  556. N-Up-Landscape
  557. {N-Up-Lines div HH}
  558. {N-Up-Columns N-Up-Missing add div WW}ifelse
  559. div dup scale
  560. LandscapeMode{/yy 0 def}{/yy xx def/xx 0 def}ifelse
  561. xx N-Up-Repeat 1 sub LandscapePageHeight mul yy add translate
  562. % ---- go to start position in page matrix
  563. N-Up-XStart N-Up-Missing 0.5 mul
  564. LandscapeMode
  565. {LandscapePageHeight mul N-Up-YStart add}
  566. {PageWidth mul add N-Up-YStart}ifelse
  567. translate
  568. }if
  569. % ---- translate to lower left corner of TEXT
  570. TextStart translate
  571. % ---- N-up printing
  572. N-Up 1 gt N-Up-Border and pages-per-sheet 0 gt and{
  573. % ---- page border
  574. gsave
  575. 0 setgray
  576. TextStart exch neg exch neg moveto
  577. N-Up-Repeat
  578. {N-Up-End
  579. {gsave
  580. PageWidth 0 rlineto
  581. 0 LandscapePageHeight rlineto
  582. PageWidth neg 0 rlineto
  583. closepath stroke
  584. grestore
  585. /pages-per-sheet pages-per-sheet 1 sub def
  586. pages-per-sheet 0 le{exit}if
  587. N-Up-XColumn N-Up-YColumn rmoveto
  588. }repeat
  589. pages-per-sheet 0 le{exit}if
  590. N-Up-XLine N-Up-XColumn sub N-Up-YLine rmoveto
  591. }repeat
  592. grestore
  593. }if
  594. }def
  595. /EndSheet{
  596. showpage
  597. sheetState restore
  598. }def
  599. /SetHeaderLines{ % nb-lines --
  600. /HeaderLines exch def
  601. % ---- bottom up
  602. HeaderPad
  603. HeaderLines 1 sub HeaderLineHeight mul add
  604. HeaderTitleLineHeight add
  605. HeaderPad add
  606. /HeaderHeight exch def
  607. }def
  608. /SetFooterLines{ % nb-lines --
  609. /FooterLines exch def
  610. % ---- bottom up
  611. FooterPad
  612. FooterLines FooterLineHeight mul add
  613. FooterPad add
  614. /FooterHeight exch def
  615. }def
  616. % |---------|
  617. % | tm |
  618. % |---------|
  619. % | header |
  620. % |-+-------| <-- (x y)
  621. % | ho |
  622. % |---------|
  623. % | text |
  624. % |---------|
  625. % | fo |
  626. % |---------|
  627. % | footer |
  628. % |-+-------| <-- (0 0)
  629. % | bm |
  630. % |---------|
  631. % -- |- x y
  632. /HeaderFrameStart{0 PrintHeight HeaderOffset add}def
  633. /FooterFrameStart{0 FooterHeight FooterOffset add neg}def
  634. /doFramePath{
  635. /h exch def
  636. PrintHeaderWidth 0 rlineto
  637. 0 h rlineto
  638. PrintHeaderWidth neg 0 rlineto
  639. 0 h neg rlineto
  640. }def
  641. /HeaderFramePath{HeaderHeight doFramePath}def
  642. /FooterFramePath{FooterHeight doFramePath}def
  643. % /path-fun /start-fun vector-property doFrame
  644. /doFrame{
  645. /vecFrame exch def
  646. /startFrame exch load def
  647. /pathFrame exch load def
  648. gsave
  649. vecFrame 2 get setlinewidth % frame border width
  650. % ---- do the shadow of the next rectangle
  651. startFrame moveto
  652. 1 -1 rmoveto
  653. pathFrame
  654. vecFrame 4 get SetColor fill % frame shadow color
  655. % ---- do the next rectangle ...
  656. startFrame moveto
  657. pathFrame
  658. gsave vecFrame 1 get SetColor fill grestore % frame background
  659. gsave vecFrame 3 get SetColor stroke grestore % frame border color
  660. grestore
  661. }def
  662. /HeaderFrame{/HeaderFramePath /HeaderFrameStart HeaderFrameProperties doFrame}def
  663. /FooterFrame{/FooterFramePath /FooterFrameStart FooterFrameProperties doFrame}def
  664. /HeaderStart{
  665. HeaderFrameStart
  666. exch HeaderPad add exch % horizontal pad
  667. % ---- bottom up
  668. HeaderPad add % vertical pad
  669. HeaderDescent sub
  670. HeaderLineHeight HeaderLines 1 sub mul add
  671. }def
  672. /FooterStart{
  673. FooterFrameStart
  674. exch FooterPad add exch % horizontal pad
  675. % ---- bottom up
  676. FooterPad add % vertical pad
  677. FooterDescent sub
  678. FooterLineHeight FooterLines 1 sub mul add
  679. }def
  680. /HeaderClip{HeaderFrameStart moveto HeaderFramePath clip}def
  681. /FooterClip{FooterFrameStart moveto FooterFramePath clip}def
  682. /strcat{
  683. dup length 3 -1 roll dup length dup 4 -1 roll add string dup
  684. 0 5 -1 roll putinterval
  685. dup 4 2 roll exch putinterval
  686. }def
  687. /pagenumberstring{
  688. PageNumber 32 string cvs
  689. ShowNofN{(/)strcat PageCount 32 string cvs strcat}if
  690. }def
  691. % lines is-right HeaderOrFooterTextLines
  692. /HeaderOrFooterTextLines{
  693. /is_right exch def
  694. HFStart moveto
  695. { % ---- process the lines
  696. aload pop
  697. exch F
  698. gsave
  699. dup xcheck{exec}if
  700. is_right{
  701. dup stringwidth pop
  702. PrintHeaderWidth exch sub HFPad HFPad add sub 0 rmoveto
  703. }if
  704. HFColor SetColor
  705. show
  706. grestore
  707. 0 HFLineHeight neg rmoveto
  708. }forall
  709. }def
  710. % right-lines left-lines /start lineheight pad fore-color HeaderOrFooterText
  711. /HeaderOrFooterText{
  712. /HFColor exch def
  713. /HFPad exch def
  714. /HFLineHeight exch def
  715. /HFStart exch load def
  716. % -- rightLines leftLines -- at stack
  717. % ---- hack: `PN 1 and' == `PN 2 modulo'
  718. % ---- if even page number and duplex, then exchange left and right
  719. PageNumber 1 and 0 eq SwitchHeader and{exch}if
  720. % ---- process the left lines
  721. false HeaderOrFooterTextLines
  722. % ---- process the right lines
  723. true HeaderOrFooterTextLines
  724. }def
  725. /HeaderText{
  726. gsave HeaderClip
  727. HeaderLinesRight HeaderLinesLeft
  728. /HeaderStart HeaderLineHeight HeaderPad
  729. HeaderFrameProperties 0 get
  730. HeaderOrFooterText
  731. grestore
  732. }def
  733. /FooterText{
  734. gsave FooterClip
  735. FooterLinesRight FooterLinesLeft
  736. /FooterStart FooterLineHeight FooterPad
  737. FooterFrameProperties 0 get
  738. HeaderOrFooterText
  739. grestore
  740. }def
  741. /ReportFontInfo{
  742. 2 copy
  743. /t0 3 1 roll DefFont
  744. /t0 F
  745. /lh FontHeight def
  746. /sw( )stringwidth pop def
  747. /aw(01234567890abcdefghijklmnopqrstuvwxyz)dup length exch
  748. stringwidth pop exch div def
  749. /t1 12/Helvetica-Oblique DefFont
  750. /t1 F
  751. gsave
  752. (languagelevel = )show
  753. languagelevel 32 string cvs show
  754. grestore
  755. 0 FontHeight neg rmoveto
  756. gsave
  757. (For )show
  758. 128 string cvs show
  759. ( )show
  760. 32 string cvs show
  761. ( point, the line height is )show
  762. lh 32 string cvs show
  763. (, the space width is )show
  764. sw 32 string cvs show
  765. (,)show
  766. grestore
  767. 0 FontHeight neg rmoveto
  768. gsave
  769. (and a crude estimate of average character width is )show
  770. aw 32 string cvs show
  771. (.)show
  772. grestore
  773. 0 FontHeight neg rmoveto
  774. }def
  775. % cm to point
  776. /cm{72 mul 2.54 div}def
  777. /ReportAllFontInfo{
  778. % key = font name value = font dictionary
  779. FontDirectory{pop 10 exch ReportFontInfo}forall
  780. }def
  781. % 3 cm 20 cm moveto 10/Courier ReportFontInfo showpage
  782. % 3 cm 20 cm moveto ReportAllFontInfo showpage
  783. % === END ps-print prologue 1