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