1 % === BEGIN ps-print prologue 1
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)
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 % ISOLatin1Encoding stolen from ps_init.ps in GhostScript 2.6.1.4:
24 /ISOLatin1Encoding where
{pop}{
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.
29 StandardEncoding
0 45 getinterval aload
pop
31 StandardEncoding
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.
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
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
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
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
70 /reencodeFontISO
{ %def
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.
75 begin
% Make the new font the current dictionary.
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
81 % Override the encoding with the ISOLatin1 encoding.
82 currentdict
/FontType get
0 ne
{/Encoding ISOLatin1Encoding def
}if
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.
93 % | | | | Ascent (usually > 0)
95 % (0 0) -> +--+----+-------->
97 % | | v Descent (usually < 0)
98 % (x1 y1) --> +----+ - -
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
109 /FontHeight Ascent Descent
sub def
% use `sub' because descent < 0
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
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.
130 /DefFont
{findfont
exch scalefont reencodeFontISO
}def
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
150 /FG
/setrgbcolor load def
163 % | Ascent (usually > 0)
165 % | Descent (usually < 0)
169 /dobackground
{ % width --
170 currentpoint
% -- width x y
176 0 Descent Ascent
sub rlineto
% D
183 /eolbg
{ % dobackground until right margin
184 PrintWidth
% -- x-eol
185 currentpoint
pop % -- cur-x
186 sub % -- width until eol
190 /LineHS LineHeight LineSpacing add def
191 /ParagraphHS LineHeight ParagraphSpacing add def
192 /PSL
{/h
exch def bg
{eolbg
}if 0 currentpoint
exch pop h
sub moveto
}def
193 /PLN
{PrintLineNumber
{doLineNumber
}if}def
195 /SL
{LineHS PSL isLineStep
pop}def
% Soft Linefeed
197 /PHL
{ParagraphHS PSL PLN
}def
% Paragraph Hard Linefeed
198 /LHL
{LineHS PSL PLN
}def
% Hard Linefeed
201 /dcp
{currentpoint
exch 40 string cvs print
(, )print
=}def
202 /dp
{print
2 copy exch 40 string cvs print
(, )print
=}def
205 ( )stringwidth
% Get the width of a space in the current font.
206 pop % Discard the Y component.
207 mul % Multiply the width of a space
208 % by the number of spaces to plot
209 bg
{dup dobackground
}if
214 /EffectUnderline
false def
215 /EffectStrikeout
false def
216 /EffectOverline
false def
217 /EffectShadow
false def
219 /EffectOutline
false def
221 % effect: 1 - underline 2 - strikeout 4 - overline
222 % 8 - shadow 16 - box 32 - outline
225 /EffectUnderline Effect
1 and
0 ne def
226 /EffectStrikeout Effect
2 and
0 ne def
227 /EffectOverline Effect
4 and
0 ne def
228 /EffectShadow Effect
8 and
0 ne def
229 /EffectBox Effect
16 and
0 ne def
230 /EffectOutline Effect
32 and
0 ne def
233 % stack: string |- --
235 /xx currentpoint
dup Descent add
/yy
exch def
236 Ascent add
/YY
exch def def
237 dup stringwidth
pop xx add
/XX
exch def
239 /yy yy Yshadow add def
240 /XX XX Xshadow add def
245 {SpaceBackground doBox
}
249 EffectBox
{false 0 doBox
}if % box
250 EffectShadow
{dup doShadow
}if % shadow
252 {true doOutline
} % outline
255 EffectUnderline
{UnderlinePosition Hline
}if % underline
256 EffectStrikeout
{StrikeoutPosition Hline
}if % strikeout
257 EffectOverline
{OverlinePosition Hline
}if % overline
260 % stack: position |- --
262 currentpoint
exch pop add
dup
268 LineThickness setlinewidth stroke
272 % stack: fill-or-not delta |- --
275 xx XBox
sub dd
sub yy YBox
sub dd
sub
276 XX XBox add dd add YY YBox add dd add
280 % stack: fill-or-not lower-x lower-y upper-x upper-y |- --
293 % top of stack: fill-or-not
295 {LineThickness setlinewidth stroke
}ifelse
299 % stack: string |- --
302 Xshadow Yshadow rmoveto
309 % stack: string fill-or-not |- --
312 /-ox
- currentpoint
/-oy
- exch def def
314 LineThickness setlinewidth
317 -fillp
- {gsave FillBgColor grestore
}if
319 -oy
- add
/-oy
- exch def
320 -ox
- add
/-ox
- exch def
328 /FillBgColor
{bgcolor aload
pop setrgbcolor fill
}bind def
330 % stack: -- |- boolean
333 {PLScounter
0 gt
% or zebra
334 {/PLScounter PLScounter
1 sub def PLScounter
0 eq
}
337 {/PrintLineStep PrintLineStep
1 sub def
}
338 {/PrintLineStep ZebraHeight def
339 /PLScounter PrintLineStart def
}ifelse}
340 {LineNumber PrintLineStart
sub PrintLineStep
mod 0 eq
}ifelse % or line step
347 isLineStep
% or line step
348 LineNumber Lines ge or
% or last line
351 LineNumberColor SetColor
355 {LineNumber
6 string cvs
( )strcat
}ifelse
356 dup stringwidth
pop neg
0 rmoveto
360 /LineNumber LineNumber
1 add def
364 % stack: color-specifier |- --
365 /SetColor
{dup type
/realtype eq
{setgray
}{aload
pop setrgbcolor
}ifelse}def
371 /double
-zebra ZebraHeight ZebraHeight add def
372 /yiter double
-zebra LineHS
mul neg def
373 /xiter PrintWidth InterColumn add def
374 /zebra
-line LinesPrinted def
375 NumberOfColumns
{LinesPerColumn doColumnZebra xiter
0 rmoveto
}repeat
379 % stack: lines-per-column |- --
383 ZebraFollow
1 and
0 ne
{
384 /H ZebraHeight zebra
-line ZebraHeight
mod sub def
386 zebra
-line double
-zebra
mod ZebraHeight lt
387 {H doZebra
% "black" stripe followed by a "white" stripe
388 /lpc lpc ZebraHeight
sub def
390 {H
}ifelse % "white" stripe
391 LineHS
mul neg
0 exch rmoveto
392 /zebra
-line zebra
-line LinesPerColumn add def
395 lpc
dup double
-zebra
idiv{ZebraHeight doZebra
0 yiter rmoveto
}repeat
396 double
-zebra
mod dup 0 le
{pop}
399 {/zspacing LineSpacing def
400 ZebraFollow
2 and
0 ne
{pop ZebraHeight
}if}ifelse
405 % stack: zebra-height (in lines) |- --
407 /zh
exch 0.05 sub LineHS
mul zspacing
sub def
409 0 LineHeight
0.65 mul rmoveto
412 PrintWidth neg
0 rlineto
420 /BackgroundColor where
{
421 pop gsave BackgroundColor SetColor
424 0 LineHeight
0.65 mul rmoveto
426 0 PrintHeight neg rlineto
427 PrintWidth neg
0 rlineto
428 0 PrintHeight rlineto
431 PrintWidth InterColumn add
0 rmoveto
437 % tx ty rotation xscale yscale xpos ypos BeginBackImage
439 /-save
-image
- save def
447 /EndBackImage
{-save
-image
- restore
}def
449 % string fontsize fontname rotation gray xpos ypos ShowBackText
455 findfont
exch dup/-offset
- exch -0.25 mul def scalefont setfont
457 /-saveLineThickness
- LineThickness def
460 /LineThickness
-saveLineThickness
- def
465 BMark
/PageSize
[PageWidth LandscapePageHeight LandscapeMode
{exch}if]EMark setpagedevice
469 % ---- Remember space width of the normal text font `f0'.
470 /SpaceWidth
/f0 findfont setfont
( )stringwidth
pop def
471 % ---- save the state of the document (useful for ghostscript!)
473 % ---- [andrewi] set PageSize based on chosen dimensions
475 WarnPaperSize
{SetPageSize
}{mark{SetPageSize
}stopped cleartomark}ifelse
477 /ColumnWidth PrintWidth InterColumn add def
478 % ---- define where printing will start
479 /f0 F
% this installs Ascent
480 /PrintStartY PrintHeight Ascent
sub def
482 /N
-Up
-Counter N
-Up
-End
1 sub def
483 /PLScounter PrintLineStart def
487 % ---- restore the state of the document (useful for ghostscript!)
492 % ---- when 1st column, save the state of the page
493 ColumnIndex
1 eq
{/pageState save def
}if
494 % ---- save the state of the column
495 /columnState save def
498 /PrintHeaderWidth PrintOnlyOneHeader
{PrintPageWidth
}{PrintWidth
}ifelse def
501 /LinesPrinted
exch def
502 % ---- when 1st column, print all background effects
504 0 PrintStartY moveto
% move to where printing will start
507 printGlobalBackground
510 PrintOnlyOneHeader
{ColumnIndex
1 eq
}{true}ifelse
512 PrintHeaderFrame
{HeaderFrame
}if
516 PrintFooterFrame
{FooterFrame
}if
519 0 PrintStartY moveto
% move to where printing will start
523 {/H PageNumber
1 sub NumberOfColumns
mul ColumnIndex
1 sub add
524 LinesPerColumn
mul ZebraHeight
mod def
525 /PLScounter H PrintLineStart ge
{0}{PrintLineStart H
sub}ifelse def
526 /PrintLineStep ZebraHeight H
sub def
}if}if
530 /EndPage
{bg
{eolbg
}if}def
533 ColumnIndex NumberOfColumns eq
{
534 % ---- restore the state of the page
540 {% ---- Next page on same row
541 /N
-Up
-Counter N
-Up
-Counter
1 sub def
542 N
-Up
-XColumn N
-Up
-YColumn
}
543 {% ---- Next page on next line
544 /N
-Up
-Counter N
-Up
-End
1 sub def
545 N
-Up
-XLine N
-Up
-YLine
}ifelse
549 % ---- restore the state of the current column
551 % ---- and translate to the next column
552 ColumnWidth
0 translate
553 /ColumnIndex ColumnIndex
1 add def
558 LeftMargin BottomMargin
561 FooterLines FooterLineHeight
mul add
566 % stack: number-of-pages-per-sheet |- --
569 /pages
-per
-sheet
exch def
571 % ---- translate to bottom-right corner of Portrait page
573 LandscapePageHeight
0 translate
576 % ---- [jack] Kludge: my ghostscript window is 21x27.7 instead of 21x29.7
577 /JackGhostscript where
{pop 1 27.7 29.7 div scale
}if
578 UpsideDown
{PageWidth LandscapePageHeight translate
180 rotate
}if
583 PageWidth
0 translate
586 N
-Up
-Margin
dup translate
590 /WW LandscapePageHeight def
592 /HH LandscapePageHeight def
597 /ww WW WW
mul N
-Up
-Lines HH
mul div def
598 /cc HH N
-Up
-Columns N
-Up
-Missing add div def
599 ww cc gt
{/xx WW def
/WW cc ww div WW
mul def
/xx xx WW
sub def
}if
601 /hh HH N
-Up
-Columns N
-Up
-Missing add div def
602 /cc HH N
-Up
-Lines div def
603 hh cc gt
{/xx WW def
/WW cc hh div WW
mul def
/xx xx WW
sub def
}if
605 WW N
-Up
-Margin
sub N
-Up
-Margin
sub
608 {N
-Up
-Columns N
-Up
-Missing add div WW
}ifelse
610 LandscapeMode
{/yy
0 def
}{/yy xx def
/xx
0 def
}ifelse
611 xx N
-Up
-Repeat
1 sub LandscapePageHeight
mul yy add translate
612 % ---- go to start position in page matrix
613 N
-Up
-XStart N
-Up
-Missing
0.5 mul
615 {LandscapePageHeight
mul N
-Up
-YStart add
}
616 {PageWidth
mul add N
-Up
-YStart
}ifelse
619 % ---- translate to lower left corner of TEXT
623 N
-Up
1 gt N
-Up
-Border and pages
-per
-sheet
0 gt and
{
627 TextStart
exch neg
exch neg moveto
632 0 LandscapePageHeight rlineto
633 PageWidth neg
0 rlineto
636 /pages
-per
-sheet pages
-per
-sheet
1 sub def
637 pages
-per
-sheet
0 le
{exit}if
638 N
-Up
-XColumn N
-Up
-YColumn rmoveto
640 pages
-per
-sheet
0 le
{exit}if
641 N
-Up
-XLine N
-Up
-XColumn
sub N
-Up
-YLine rmoveto
652 /SetHeaderLines
{ % nb-lines --
653 /HeaderLines
exch def
656 HeaderLines
1 sub HeaderLineHeight
mul add
657 HeaderTitleLineHeight add
659 /HeaderHeight
exch def
662 /SetFooterLines
{ % nb-lines --
663 /FooterLines
exch def
666 FooterLines FooterLineHeight
mul add
668 /FooterHeight
exch def
675 % |-+-------| <-- (x y)
683 % |-+-------| <-- (0 0)
688 /HeaderFrameStart
{0 PrintHeight HeaderOffset add
}def
689 /FooterFrameStart
{0 FooterHeight FooterOffset add neg
}def
693 PrintHeaderWidth
0 rlineto
695 PrintHeaderWidth neg
0 rlineto
699 /HeaderFramePath
{HeaderHeight doFramePath
}def
700 /FooterFramePath
{FooterHeight doFramePath
}def
702 % /path-fun /start-fun vector-property doFrame
705 /startFrame
exch load def
706 /pathFrame
exch load def
708 vecFrame
2 get setlinewidth
% frame border width
709 % ---- do the shadow of the next rectangle
713 vecFrame
4 get SetColor fill
% frame shadow color
714 % ---- do the next rectangle ...
717 gsave vecFrame
1 get SetColor fill grestore
% frame background
718 gsave vecFrame
3 get SetColor stroke grestore
% frame border color
722 /HeaderFrame
{/HeaderFramePath
/HeaderFrameStart HeaderFrameProperties doFrame
}def
723 /FooterFrame
{/FooterFramePath
/FooterFrameStart FooterFrameProperties doFrame
}def
727 exch HeaderPad add
exch % horizontal pad
729 HeaderPad add
% vertical pad
731 HeaderLineHeight HeaderLines
1 sub mul add
736 exch FooterPad add
exch % horizontal pad
738 FooterPad add
% vertical pad
740 FooterLineHeight FooterLines
1 sub mul add
744 dup length
3 -1 roll dup length
dup 4 -1 roll add string
dup
745 0 5 -1 roll putinterval
746 dup 4 2 roll exch putinterval
750 PageNumber
32 string cvs
751 ShowNofN
{(/)strcat PageCount
32 string cvs strcat
}if
754 % lines is-right HeaderOrFooterTextLines
755 /HeaderOrFooterTextLines
{
758 { % ---- process the lines
765 PrintHeaderWidth
exch sub HFPad HFPad add
sub 0 rmoveto
770 0 HFLineHeight neg rmoveto
774 % right-lines left-lines /start lineheight pad fore-color HeaderOrFooterText
778 /HFLineHeight
exch def
779 /HFStart
exch load def
781 % -- rightLines leftLines -- at stack
783 % ---- hack: `PN 1 and' == `PN 2 modulo'
784 % ---- if even page number and duplex, then exchange left and right
785 PageNumber
1 and
0 eq SwitchHeader and
{exch}if
787 % ---- process the left lines
788 false HeaderOrFooterTextLines
790 % ---- process the right lines
791 true HeaderOrFooterTextLines
795 HeaderLinesRight HeaderLinesLeft
796 /HeaderStart HeaderLineHeight HeaderPad
797 HeaderFrameProperties
0 get
802 FooterLinesRight FooterLinesLeft
803 /FooterStart FooterLineHeight FooterPad
804 FooterFrameProperties
0 get
813 /sw
( )stringwidth
pop def
814 /aw
(01234567890abcdefghijklmnopqrstuvwxyz
)dup length
exch
815 stringwidth
pop exch div def
816 /t1
12/Helvetica
-Oblique DefFont
819 (languagelevel
= )show
820 languagelevel
32 string cvs show
822 0 FontHeight neg rmoveto
828 ( point
, the line height is
)show
829 lh
32 string cvs show
830 (, the space width is
)show
831 sw
32 string cvs show
834 0 FontHeight neg rmoveto
836 (and a crude estimate of average character width is
)show
837 aw
32 string cvs show
840 0 FontHeight neg rmoveto
844 /cm
{72 mul 2.54 div
}def
847 % key = font name value = font dictionary
848 FontDirectory
{pop 10 exch ReportFontInfo
}forall
851 % 3 cm 20 cm moveto 10/Courier ReportFontInfo showpage
852 % 3 cm 20 cm moveto ReportAllFontInfo showpage
854 % === END ps-print prologue 1