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