*** empty log message ***
[emacs.git] / etc / ps-prin1.ps
blob3ab3d6176f605fab68c8638149ae481525f2e026
1 % === BEGIN ps-print prologue 1
2 % version: 6.1
4 % Copyright (C) 2000, 2001, 2002, 2003, 2004, 2007  Free Software Foundation, Inc.
6 % This file is part of GNU Emacs.
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.
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.
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., 51 Franklin Street, Fifth Floor,
21 % Boston, MA 02110-1301, USA.
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.
34 % ISOLatin1Encoding stolen from ps_init.ps in GhostScript 2.6.1.4:
35 /ISOLatin1Encoding where{pop}{
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
40 StandardEncoding 0 45 getinterval aload pop
41     /minus
42 StandardEncoding 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)
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
51 % 0240 (160)
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
60 % 0300 (192)
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
69 % 0340 (224)
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
78 256 packedarray def
79 }ifelse
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.
86   begin                 % Make the new font the current dictionary.
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
92     % Override the encoding with the ISOLatin1 encoding.
93     currentdict/FontType get 0 ne{/Encoding ISOLatin1Encoding def}if
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.
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) --> +----+ - -
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
120     /FontHeight Ascent Descent sub def  % use `sub' because descent < 0
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
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
140 % Font definition
141 /DefFont{findfont exch scalefont reencodeFontISO}def
143 % Font selection
145   findfont
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
158   setfont
159 }def
161 /FG/setrgbcolor load def
163 /bg false def
164 /BG{
165   dup/bg exch def
166   {[4 1 roll]}
167   {[1.0 1.0 1.0]}
168   ifelse
169   /bgcolor exch def
170 }def
172 %  B    width    C
173 %   +-----------+
174 %               | Ascent  (usually > 0)
175 % A +           +
176 %               | Descent (usually < 0)
177 %   +-----------+
178 %  E    width    D
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
190     FillBgColor
191   grestore
192 }def
194 /eolbg{                                 % dobackground until right margin
195   PrintWidth                            % -- x-eol
196   currentpoint pop                      % -- cur-x
197   sub                                   % -- width until eol
198   dobackground
199 }def
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
204 /PLN{PrintLineNumber{doLineNumber}if}def
206 /SL{LineHS PSL isLineStep pop}def       % Soft Linefeed
208 /PHL{ParagraphHS PSL PLN}def            % Paragraph Hard Linefeed
209 /LHL{LineHS PSL PLN}def                 % Hard Linefeed
211 % Some debug
212 /dcp{currentpoint exch 40 string cvs print(, )print =}def
213 /dp{print 2 copy  exch 40 string cvs print(, )print =}def
216   ( )stringwidth        % Get the width of a space in the current font.
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
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
232 % effect: 1  - underline  2   - strikeout  4  - overline
233 %         8  - shadow     16  - box        32 - outline
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
244 % stack:  string  |-  --
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
249   EffectShadow{
250     /yy yy Yshadow add def
251     /XX XX Xshadow add def
252   }if
253   bg{
254     true
255     EffectBox
256       {SpaceBackground doBox}
257       {xx yy XX YY doRect}
258     ifelse
259   }if                                           % background
260   EffectBox      {false 0 doBox}if              % box
261   EffectShadow   {dup doShadow}if               % shadow
262   EffectOutline
263     {true doOutline}                            % outline
264     {show}                                      % normal text
265   ifelse
266   EffectUnderline{UnderlinePosition Hline}if    % underline
267   EffectStrikeout{StrikeoutPosition Hline}if    % strikeout
268   EffectOverline {OverlinePosition  Hline}if    % overline
269 }bind def
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
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
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
305   {FillBgColor}
306   {LineThickness setlinewidth stroke}ifelse
307   grestore
308 }bind def
310 % stack:  string  |-  --
311 /doShadow{
312   gsave
313   Xshadow Yshadow rmoveto
314   false doOutline
315   grestore
316 }bind def
318 /st 1 string def
320 % stack:  string fill-or-not  |-  --
321 /doOutline{
322   /-fillp- exch def
323   /-ox- currentpoint/-oy- exch def def
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
330    -oy- add/-oy- exch def
331    -ox- add/-ox- exch def
332    -ox- -oy- moveto
333   }forall
334   grestore
335   -ox- -oy- moveto
336 }bind def
338 % stack:  --
339 /FillBgColor{bgcolor aload pop setrgbcolor fill}bind def
341 % stack:  -- |- boolean
342 /isLineStep{
343   SyncLineZebra
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
352 }def
354 % stack:  --
355 /doLineNumber{
356   /LineNumber where
357   {pop
358    isLineStep                   % or line step
359    LineNumber Lines ge or       % or last line
360    {currentfont
361     gsave
362     LineNumberColor SetColor
363     /L0 findfont setfont
364     LineNumber Lines ge
365     {(end      )}
366     {LineNumber 6 string cvs(      )strcat}ifelse
367     dup stringwidth pop neg 0 rmoveto
368     show
369     grestore
370     setfont}if
371     /LineNumber LineNumber 1 add def
372   }if
373 }def
375 % stack: color-specifier |- --
376 /SetColor{dup type/realtype eq{setgray}{aload pop setrgbcolor}ifelse}def
378 % stack: --
379 /printZebra{
380   gsave
381   ZebraColor SetColor
382   /double-zebra ZebraHeight ZebraHeight add def
383   /yiter double-zebra LineHS mul neg def
384   /xiter PrintWidth InterColumn add def
385   /zebra-line LinesPrinted def
386   NumberOfColumns{LinesPerColumn doColumnZebra xiter 0 rmoveto}repeat
387   grestore
388 }def
390 % stack:  lines-per-column |- --
391 /doColumnZebra{
392   /lpc exch def
393   gsave
394   ZebraFollow 1 and 0 ne{
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
402     LineHS mul neg 0 exch rmoveto
403     /zebra-line zebra-line LinesPerColumn add def
404   }if
405   /zspacing 0 def
406   lpc dup double-zebra idiv{ZebraHeight doZebra 0 yiter rmoveto}repeat
407   double-zebra mod dup 0 le{pop}
408   {dup ZebraHeight gt
409    {pop ZebraHeight}
410    {/zspacing LineSpacing def
411     ZebraFollow 2 and 0 ne{pop ZebraHeight}if}ifelse
412    doZebra}ifelse
413   grestore
414 }def
416 % stack:  zebra-height (in lines) |- --
417 /doZebra{
418   /zh exch 0.05 sub LineHS mul zspacing sub def
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
429 % stack: --
430 /printBackground{
431   /BackgroundColor where{
432     /LHg LineHeight 0.65 mul def
433     /PHg PrintHeight LHg add def
434     pop gsave BackgroundColor SetColor
435     NumberOfColumns{
436      gsave
437      0 LHg rmoveto
438      PrintWidth 0 rlineto
439      0 PHg neg rlineto
440      PrintWidth neg 0 rlineto
441      0 PHg rlineto
442      fill
443      grestore
444      PrintWidth InterColumn add 0 rmoveto
445     }repeat
446     grestore
447   }if
448 }def
450 % tx ty rotation xscale yscale xpos ypos BeginBackImage
451 /BeginBackImage{
452   /-save-image- save def
453   /showpage{}def
454   translate
455   scale
456   rotate
457   translate
458 }def
460 /EndBackImage{-save-image- restore}def
462 % string fontsize fontname rotation gray xpos ypos ShowBackText
463 /ShowBackText{
464   gsave
465   translate
466   setgray
467   rotate
468   findfont exch dup/-offset- exch -0.25 mul def scalefont setfont
469   0 -offset- moveto
470   /-saveLineThickness- LineThickness def
471   /LineThickness 1 def
472   false doOutline
473   /LineThickness -saveLineThickness- def
474   grestore
475 }def
477 /SetPageSize{
478   BMark/PageSize[PageWidth LandscapePageHeight LandscapeMode{exch}if]EMark setpagedevice
479 }def
481 /BeginDoc{
482   % ---- Remember space width of the normal text font `f0'.
483   /SpaceWidth/f0 findfont setfont( )stringwidth pop def
484   % ---- save the state of the document (useful for ghostscript!)
485   /docState save def
486   % ---- [andrewi] set PageSize based on chosen dimensions
487   UseSetpagedevice{
488    WarnPaperSize{SetPageSize}{mark{SetPageSize}stopped cleartomark}ifelse
489   }if
490   /ColumnWidth PrintWidth InterColumn add def
491   % ---- define where  printing will start
492   /f0 F                                 % this installs Ascent
493   /PrintStartY PrintHeight Ascent sub def
494   /ColumnIndex 1 def
495   /N-Up-Counter N-Up-End 1 sub def
496   /PLScounter PrintLineStart def
497 }def
499 /EndDoc{
500   % ---- restore the state of the document (useful for ghostscript!)
501   docState restore
502 }def
504 /BeginDSCPage{
505   % ---- when 1st column, save the state of the page
506   ColumnIndex 1 eq{/pageState save def}if
507   % ---- save the state of the column
508   /columnState save def
509 }def
511 /PrintHeaderWidth PrintOnlyOneHeader{PrintPageWidth}{PrintWidth}ifelse def
513 /BeginPage{
514   /LinesPrinted exch def
515   % ---- when 1st column, print all background effects
516   ColumnIndex 1 eq{
517     0 PrintStartY moveto                % move to where printing will start
518     printBackground
519     Zebra{printZebra}if
520     printGlobalBackground
521     printLocalBackground
522   }if
523   PrintOnlyOneHeader{ColumnIndex 1 eq}{true}ifelse
524   dup PrintHeader and{
525     PrintHeaderFrame{HeaderFrame}if
526     HeaderText
527   }if
528   PrintFooter and{
529     PrintFooterFrame{FooterFrame}if
530     FooterText
531   }if
532   0 PrintStartY moveto                  % move to where printing will start
533   /LineNumber where
534   {pop
535    SyncLineZebra
536    {/H PageNumber 1 sub NumberOfColumns mul ColumnIndex 1 sub add
537        LinesPerColumn mul ZebraHeight mod def
538     /PLScounter H PrintLineStart ge{0}{PrintLineStart H sub}ifelse def
539     /PrintLineStep ZebraHeight H sub def}if}if
540   PLN
541 }def
543 /EndPage{bg{eolbg}if}def
545 /EndDSCPage{
546   ColumnIndex NumberOfColumns eq{
547     % ---- restore the state of the page
548     pageState restore
549     /ColumnIndex 1 def
550     % ---- N-up printing
551     N-Up 1 gt{
552       N-Up-Counter 0 gt
553       {% ---- Next page on same row
554         /N-Up-Counter N-Up-Counter 1 sub def
555         N-Up-XColumn N-Up-YColumn}
556       {% ---- Next page on next line
557         /N-Up-Counter N-Up-End 1 sub def
558         N-Up-XLine N-Up-YLine}ifelse
559       translate
560     }if
561   }{ % else
562     % ---- restore the state of the current column
563     columnState restore
564     % ---- and translate to the next column
565     ColumnWidth 0 translate
566     /ColumnIndex ColumnIndex 1 add def
567   }ifelse
568 }def
570 /TextStart{
571   LeftMargin BottomMargin
572   PrintFooter{
573     FooterPad add
574     FooterLines FooterLineHeight mul add
575     FooterPad add
576     FooterOffset add}if
577 }def
579 % stack: number-of-pages-per-sheet |- --
580 /BeginSheet{
581   /sheetState save def
582   /pages-per-sheet exch def
584   % ---- translate to bottom-right corner of Portrait page
585   LandscapeMode{
586     LandscapePageHeight 0 translate
587     90 rotate
588   }if
589   % ---- [jack] Kludge: my ghostscript window is 21x27.7 instead of 21x29.7
590   /JackGhostscript where{pop 1 27.7 29.7 div scale}if
591   UpsideDown{PageWidth LandscapePageHeight translate 180 rotate}if
592   % ---- N-Up printing
593   N-Up 1 gt{
594     % ---- landscape
595     N-Up-Landscape{
596       PageWidth 0 translate
597       90 rotate
598     }if
599     N-Up-Margin dup translate
600     % ---- scale
601     LandscapeMode{
602       /HH PageWidth def
603       /WW LandscapePageHeight def
604     }{
605       /HH LandscapePageHeight def
606       /WW PageWidth def
607     }ifelse
608     /xx 0 def
609     N-Up-Landscape{
610       /ww WW WW mul N-Up-Lines HH mul div def
611       /cc HH N-Up-Columns N-Up-Missing add div def
612       ww cc gt{/xx WW def/WW cc ww div WW mul def/xx xx WW sub def}if
613     }{
614       /hh HH N-Up-Columns N-Up-Missing add div def
615       /cc HH N-Up-Lines div def
616       hh cc gt{/xx WW def/WW cc hh div WW mul def/xx xx WW sub def}if
617     }ifelse
618     WW N-Up-Margin sub N-Up-Margin sub
619     N-Up-Landscape
620     {N-Up-Lines div HH}
621     {N-Up-Columns N-Up-Missing add div WW}ifelse
622     div dup scale
623     LandscapeMode{/yy 0 def}{/yy xx def/xx 0 def}ifelse
624     xx N-Up-Repeat 1 sub LandscapePageHeight mul yy add translate
625     % ---- go to start position in page matrix
626     N-Up-XStart N-Up-Missing 0.5 mul
627     LandscapeMode
628     {LandscapePageHeight mul N-Up-YStart add}
629     {PageWidth mul add N-Up-YStart}ifelse
630     translate
631   }if
632   % ---- translate to lower left corner of TEXT
633   TextStart translate
635   % ---- N-up printing
636   N-Up 1 gt N-Up-Border and pages-per-sheet 0 gt and{
637     % ---- page border
638     gsave
639     0 setgray
640     TextStart exch neg exch neg moveto
641     N-Up-Repeat
642     {N-Up-End
643      {gsave
644       PageWidth 0 rlineto
645       0 LandscapePageHeight rlineto
646       PageWidth neg 0 rlineto
647       closepath stroke
648       grestore
649       /pages-per-sheet pages-per-sheet 1 sub def
650       pages-per-sheet 0 le{exit}if
651       N-Up-XColumn N-Up-YColumn rmoveto
652      }repeat
653      pages-per-sheet 0 le{exit}if
654      N-Up-XLine N-Up-XColumn sub N-Up-YLine rmoveto
655     }repeat
656     grestore
657   }if
658 }def
660 /EndSheet{
661   showpage
662   sheetState restore
663 }def
665 /SetHeaderLines{                        % nb-lines --
666   /HeaderLines exch def
667   % ---- bottom up
668   HeaderPad
669   HeaderLines 1 sub HeaderLineHeight mul add
670   HeaderTitleLineHeight add
671   HeaderPad add
672   /HeaderHeight exch def
673 }def
675 /SetFooterLines{                        % nb-lines --
676   /FooterLines exch def
677   % ---- bottom up
678   FooterPad
679   FooterLines FooterLineHeight mul add
680   FooterPad add
681   /FooterHeight exch def
682 }def
684 % |---------|
685 % |  tm     |
686 % |---------|
687 % |  header |
688 % |-+-------| <-- (x y)
689 % |  ho     |
690 % |---------|
691 % |  text   |
692 % |---------|
693 % |  fo     |
694 % |---------|
695 % |  footer |
696 % |-+-------| <-- (0 0)
697 % |  bm     |
698 % |---------|
700 % -- |- x y
701 /HeaderFrameStart{0  PrintHeight HeaderOffset add}def
702 /FooterFrameStart{0  FooterHeight FooterOffset add neg}def
704 /doFramePath{
705   /h exch def
706   PrintHeaderWidth      0       rlineto
707   0                     h       rlineto
708   PrintHeaderWidth neg  0       rlineto
709   0                     h neg   rlineto
710 }def
712 /HeaderFramePath{HeaderHeight doFramePath}def
713 /FooterFramePath{FooterHeight doFramePath}def
715 % /path-fun /start-fun vector-property doFrame
716 /doFrame{
717   /vecFrame exch def
718   /startFrame exch load def
719   /pathFrame exch load def
720   gsave
721     vecFrame 2 get setlinewidth                         % frame border width
722     % ---- do the shadow of the next rectangle
723     startFrame moveto
724     1 -1 rmoveto
725     pathFrame
726     vecFrame 4 get SetColor fill                        % frame shadow color
727     % ---- do the next rectangle ...
728     startFrame moveto
729     pathFrame
730     gsave vecFrame 1 get SetColor fill grestore         % frame background
731     gsave vecFrame 3 get SetColor stroke grestore       % frame border color
732   grestore
733 }def
735 /HeaderFrame{/HeaderFramePath /HeaderFrameStart HeaderFrameProperties doFrame}def
736 /FooterFrame{/FooterFramePath /FooterFrameStart FooterFrameProperties doFrame}def
738 /HeaderStart{
739   HeaderFrameStart
740   exch HeaderPad add exch       % horizontal pad
741   % ---- bottom up
742   HeaderPad add                 % vertical   pad
743   HeaderDescent sub
744   HeaderLineHeight HeaderLines 1 sub mul add
745 }def
747 /FooterStart{
748   FooterFrameStart
749   exch FooterPad add exch       % horizontal pad
750   % ---- bottom up
751   FooterPad add                 % vertical   pad
752   FooterDescent sub
753   FooterLineHeight FooterLines 1 sub mul add
754 }def
756 /HeaderClip{HeaderFrameStart moveto HeaderFramePath clip}def
757 /FooterClip{FooterFrameStart moveto FooterFramePath clip}def
759 /strcat{
760   dup length 3 -1 roll dup length dup 4 -1 roll add string dup
761   0 5 -1 roll putinterval
762   dup 4 2 roll exch putinterval
763 }def
765 /pagenumberstring{
766   PageNumber 32 string cvs
767   ShowNofN{(/)strcat PageCount 32 string cvs strcat}if
768 }def
770 % lines is-right HeaderOrFooterTextLines
771 /HeaderOrFooterTextLines{
772   /is_right exch def
773   HFStart moveto
774   { % ---- process the lines
775    aload pop
776    exch F
777    gsave
778     dup xcheck{exec}if
779     is_right{
780      dup stringwidth pop
781      PrintHeaderWidth exch sub HFPad HFPad add sub 0 rmoveto
782     }if
783     HFColor SetColor
784     show
785    grestore
786    0 HFLineHeight neg rmoveto
787   }forall
788 }def
790 % right-lines left-lines /start lineheight pad fore-color HeaderOrFooterText
791 /HeaderOrFooterText{
792   /HFColor exch def
793   /HFPad exch def
794   /HFLineHeight exch def
795   /HFStart exch load def
797   % -- rightLines leftLines -- at stack
799   % ---- hack: `PN 1 and'  ==  `PN 2 modulo'
800   % ---- if even page number and duplex, then exchange left and right
801   PageNumber 1 and 0 eq SwitchHeader and{exch}if
803   % ---- process the left lines
804   false HeaderOrFooterTextLines
806   % ---- process the right lines
807   true HeaderOrFooterTextLines
808 }def
810 /HeaderText{
811   gsave HeaderClip
812   HeaderLinesRight HeaderLinesLeft
813   /HeaderStart HeaderLineHeight HeaderPad
814   HeaderFrameProperties 0 get
815   HeaderOrFooterText
816   grestore
817 }def
819 /FooterText{
820   gsave FooterClip
821   FooterLinesRight FooterLinesLeft
822   /FooterStart FooterLineHeight FooterPad
823   FooterFrameProperties 0 get
824   HeaderOrFooterText
825   grestore
826 }def
828 /ReportFontInfo{
829   2 copy
830   /t0 3 1 roll DefFont
831   /t0 F
832   /lh FontHeight def
833   /sw( )stringwidth pop def
834   /aw(01234567890abcdefghijklmnopqrstuvwxyz)dup length exch
835   stringwidth pop exch div def
836   /t1 12/Helvetica-Oblique DefFont
837   /t1 F
838   gsave
839     (languagelevel = )show
840     languagelevel 32 string cvs show
841   grestore
842   0 FontHeight neg rmoveto
843   gsave
844     (For )show
845     128 string cvs show
846     ( )show
847     32 string cvs show
848     ( point, the line height is )show
849     lh 32 string cvs show
850     (, the space width is )show
851     sw 32 string cvs show
852     (,)show
853   grestore
854   0 FontHeight neg rmoveto
855   gsave
856     (and a crude estimate of average character width is )show
857     aw 32 string cvs show
858     (.)show
859   grestore
860   0 FontHeight neg rmoveto
861 }def
863 % cm to point
864 /cm{72 mul 2.54 div}def
866 /ReportAllFontInfo{
867   % key = font name   value = font dictionary
868   FontDirectory{pop 10 exch ReportFontInfo}forall
869 }def
871 % 3 cm 20 cm moveto  10/Courier ReportFontInfo  showpage
872 % 3 cm 20 cm moveto  ReportAllFontInfo          showpage
874 % === END ps-print prologue 1