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