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