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