(fortran-imenu-generic-expression): New variable.
[emacs.git] / lisp / ps-print.el
blobf358e69d0d17f23d491ce54afd22aecd02ed2a1f
1 ;;; ps-print.el --- Print text from the buffer as PostScript
3 ;; Copyright (C) 1993, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
5 ;; Author: Jim Thompson (was <thompson@wg2.waii.com>)
6 ;; Author: Jacques Duthen <duthen@cegelec-red.fr>
7 ;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.br>
8 ;; Keywords: print, PostScript
9 ;; Time-stamp: <97/08/27 13:00:37 vinicius>
10 ;; Version: 3.05.1
12 (defconst ps-print-version "3.05.1"
13 "ps-print.el, v 3.05.1 <97/08/24 vinicius>
15 Vinicius's last change version -- this file may have been edited as part of
16 Emacs without changes to the version number. When reporting bugs,
17 please also report the version of Emacs, if any, that ps-print was
18 distributed with.
20 Please send all bug fixes and enhancements to
21 Jacques Duthen <duthen@cegelec-red.fr>.
24 ;; This file is part of GNU Emacs.
26 ;; GNU Emacs is free software; you can redistribute it and/or modify
27 ;; it under the terms of the GNU General Public License as published by
28 ;; the Free Software Foundation; either version 2, or (at your option)
29 ;; any later version.
31 ;; GNU Emacs is distributed in the hope that it will be useful,
32 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
33 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34 ;; GNU General Public License for more details.
36 ;; You should have received a copy of the GNU General Public License
37 ;; along with GNU Emacs; see the file COPYING. If not, write to the
38 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
39 ;; Boston, MA 02111-1307, USA.
41 ;;; Commentary:
43 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
45 ;; About ps-print
46 ;; --------------
48 ;; This package provides printing of Emacs buffers on PostScript
49 ;; printers; the buffer's bold and italic text attributes are
50 ;; preserved in the printer output. Ps-print is intended for use with
51 ;; Emacs 19 or Lucid Emacs, together with a fontifying package such as
52 ;; font-lock or hilit.
54 ;; ps-print uses the same face attributes defined through font-lock or hilit
55 ;; to print a PostScript file, but some faces are better seeing on the screen
56 ;; than on paper, specially when you have a black/white PostScript printer.
58 ;; ps-print allows a remap of face to another one that it is better to print,
59 ;; for example, the face font-lock-comment-face (if you are using font-lock)
60 ;; could have bold or italic attribute when printing, besides foreground color.
61 ;; This remap improves printing look (see How Ps-Print Maps Faces).
64 ;; Using ps-print
65 ;; --------------
67 ;; The Commands
69 ;; Ps-print provides eight commands for generating PostScript images
70 ;; of Emacs buffers:
72 ;; ps-print-buffer
73 ;; ps-print-buffer-with-faces
74 ;; ps-print-region
75 ;; ps-print-region-with-faces
76 ;; ps-spool-buffer
77 ;; ps-spool-buffer-with-faces
78 ;; ps-spool-region
79 ;; ps-spool-region-with-faces
81 ;; These commands all perform essentially the same function: they
82 ;; generate PostScript images suitable for printing on a PostScript
83 ;; printer or displaying with GhostScript. These commands are
84 ;; collectively referred to as "ps-print- commands".
86 ;; The word "print" or "spool" in the command name determines when the
87 ;; PostScript image is sent to the printer:
89 ;; print - The PostScript image is immediately sent to the
90 ;; printer;
92 ;; spool - The PostScript image is saved temporarily in an
93 ;; Emacs buffer. Many images may be spooled locally
94 ;; before printing them. To send the spooled images
95 ;; to the printer, use the command `ps-despool'.
97 ;; The spooling mechanism was designed for printing lots of small
98 ;; files (mail messages or netnews articles) to save paper that would
99 ;; otherwise be wasted on banner pages, and to make it easier to find
100 ;; your output at the printer (it's easier to pick up one 50-page
101 ;; printout than to find 50 single-page printouts).
103 ;; Ps-print has a hook in the `kill-emacs-hooks' so that you won't
104 ;; accidentally quit from Emacs while you have unprinted PostScript
105 ;; waiting in the spool buffer. If you do attempt to exit with
106 ;; spooled PostScript, you'll be asked if you want to print it, and if
107 ;; you decline, you'll be asked to confirm the exit; this is modeled
108 ;; on the confirmation that Emacs uses for modified buffers.
110 ;; The word "buffer" or "region" in the command name determines how
111 ;; much of the buffer is printed:
113 ;; buffer - Print the entire buffer.
115 ;; region - Print just the current region.
117 ;; The -with-faces suffix on the command name means that the command
118 ;; will include font, color, and underline information in the
119 ;; PostScript image, so the printed image can look as pretty as the
120 ;; buffer. The ps-print- commands without the -with-faces suffix
121 ;; don't include font, color, or underline information; images printed
122 ;; with these commands aren't as pretty, but are faster to generate.
124 ;; Two ps-print- command examples:
126 ;; ps-print-buffer - print the entire buffer,
127 ;; without font, color, or
128 ;; underline information, and
129 ;; send it immediately to the
130 ;; printer.
132 ;; ps-spool-region-with-faces - print just the current region;
133 ;; include font, color, and
134 ;; underline information, and
135 ;; spool the image in Emacs to
136 ;; send to the printer later.
139 ;; Invoking Ps-Print
140 ;; -----------------
142 ;; To print your buffer, type
144 ;; M-x ps-print-buffer
146 ;; or substitute one of the other seven ps-print- commands. The
147 ;; command will generate the PostScript image and print or spool it as
148 ;; specified. By giving the command a prefix argument
150 ;; C-u M-x ps-print-buffer
152 ;; it will save the PostScript image to a file instead of sending it
153 ;; to the printer; you will be prompted for the name of the file to
154 ;; save the image to. The prefix argument is ignored by the commands
155 ;; that spool their images, but you may save the spooled images to a
156 ;; file by giving a prefix argument to `ps-despool':
158 ;; C-u M-x ps-despool
160 ;; When invoked this way, `ps-despool' will prompt you for the name of
161 ;; the file to save to.
163 ;; Any of the `ps-print-' commands can be bound to keys; I recommend
164 ;; binding `ps-spool-buffer-with-faces', `ps-spool-region-with-faces',
165 ;; and `ps-despool'. Here are the bindings I use on my Sun 4 keyboard:
167 ;; (global-set-key 'f22 'ps-spool-buffer-with-faces) ;f22 is prsc
168 ;; (global-set-key '(shift f22) 'ps-spool-region-with-faces)
169 ;; (global-set-key '(control f22) 'ps-despool)
172 ;; The Printer Interface
173 ;; ---------------------
175 ;; The variables `ps-lpr-command' and `ps-lpr-switches' determine what
176 ;; command is used to send the PostScript images to the printer, and
177 ;; what arguments to give the command. These are analogous to
178 ;; `lpr-command' and `lpr-switches'.
180 ;; Make sure that they contain appropriate values for your system;
181 ;; see the usage notes below and the documentation of these variables.
183 ;; NOTE: `ps-lpr-command' and `ps-lpr-switches' take their initial values
184 ;; from the variables `lpr-command' and `lpr-switches'. If you have
185 ;; `lpr-command' set to invoke a pretty-printer such as `enscript',
186 ;; then ps-print won't work properly. `ps-lpr-command' must name
187 ;; a program that does not format the files it prints.
190 ;; The Page Layout
191 ;; ---------------
193 ;; All dimensions are floats in PostScript points.
194 ;; 1 inch == 2.54 cm == 72 points
195 ;; 1 cm == (/ 1 2.54) inch == (/ 72 2.54) points
197 ;; The variable `ps-paper-type' determines the size of paper ps-print
198 ;; formats for; it should contain one of the symbols:
199 ;; `a4' `a3' `letter' `legal' `letter-small' `tabloid'
200 ;; `ledger' `statement' `executive' `a4small' `b4' `b5'
202 ;; The variable `ps-landscape-mode' determines the orientation
203 ;; of the printing on the page:
204 ;; nil means `portrait' mode, non-nil means `landscape' mode.
205 ;; There is no oblique mode yet, though this is easy to do in ps.
207 ;; In landscape mode, the text is NOT scaled: you may print 70 lines
208 ;; in portrait mode and only 50 lignes in landscape mode.
209 ;; The margins represent margins in the printed paper:
210 ;; the top margin is the margin between the top of the page
211 ;; and the printed header, whatever the orientation is.
213 ;; The variable `ps-number-of-columns' determines the number of columns
214 ;; both in landscape and portrait mode.
215 ;; You can use:
216 ;; - (the standard) one column portrait mode
217 ;; - (my favorite) two columns landscape mode (which spares trees)
218 ;; but also
219 ;; - one column landscape mode for files with very long lines.
220 ;; - multi-column portrait or landscape mode
223 ;; Horizontal layout
224 ;; -----------------
226 ;; The horizontal layout is determined by the variables
227 ;; `ps-left-margin' `ps-inter-column' `ps-right-margin'
228 ;; as follows:
230 ;; ------------------------------------------
231 ;; | | | | | | | |
232 ;; | lm | text | ic | text | ic | text | rm |
233 ;; | | | | | | | |
234 ;; ------------------------------------------
236 ;; If `ps-number-of-columns' is 1, `ps-inter-column' is not relevant.
237 ;; Usually, lm = rm > 0 and ic = lm
238 ;; If (ic < 0), the text of adjacent columns can overlap.
241 ;; Vertical layout
242 ;; ---------------
244 ;; The vertical layout is determined by the variables
245 ;; `ps-bottom-margin' `ps-top-margin' `ps-header-offset'
246 ;; as follows:
248 ;; |--------| |--------|
249 ;; | tm | | tm |
250 ;; |--------| |--------|
251 ;; | header | | |
252 ;; |--------| | |
253 ;; | ho | | |
254 ;; |--------| or | text |
255 ;; | | | |
256 ;; | text | | |
257 ;; | | | |
258 ;; |--------| |--------|
259 ;; | bm | | bm |
260 ;; |--------| |--------|
262 ;; If `ps-print-header' is nil, `ps-header-offset' is not relevant.
263 ;; The margins represent margins in the printed paper:
264 ;; the top margin is the margin between the top of the page
265 ;; and the printed header, whatever the orientation is.
268 ;; Headers
269 ;; -------
271 ;; Ps-print can print headers at the top of each column; the default
272 ;; headers contain the following four items: on the left, the name of
273 ;; the buffer and, if the buffer is visiting a file, the file's
274 ;; directory; on the right, the page number and date of printing.
275 ;; The default headers look something like this:
277 ;; ps-print.el 1/21
278 ;; /home/jct/emacs-lisp/ps/new 94/12/31
280 ;; When printing on duplex printers, left and right are reversed so
281 ;; that the page numbers are toward the outside (cf. `ps-spool-duplex').
283 ;; Headers are configurable:
284 ;; To turn them off completely, set `ps-print-header' to nil.
285 ;; To turn off the header's gaudy framing box,
286 ;; set `ps-print-header-frame' to nil.
288 ;; The font family and size of text in the header are determined
289 ;; by the variables `ps-header-font-family', `ps-header-font-size' and
290 ;; `ps-header-title-font-size' (see below).
292 ;; The variable `ps-header-line-pad' determines the portion of a header
293 ;; title line height to insert between the header frame and the text
294 ;; it contains, both in the vertical and horizontal directions:
295 ;; .5 means half a line.
297 ;; Page numbers are printed in `n/m' format, indicating page n of m pages;
298 ;; to omit the total page count and just print the page number,
299 ;; set `ps-show-n-of-n' to nil.
301 ;; The amount of information in the header can be changed by changing
302 ;; the number of lines. To show less, set `ps-header-lines' to 1, and
303 ;; the header will show only the buffer name and page number. To show
304 ;; more, set `ps-header-lines' to 3, and the header will show the time of
305 ;; printing below the date.
307 ;; To change the content of the headers, change the variables
308 ;; `ps-left-header' and `ps-right-header'.
309 ;; These variables are lists, specifying top-to-bottom the text
310 ;; to display on the left or right side of the header.
311 ;; Each element of the list should be a string or a symbol.
312 ;; Strings are inserted directly into the PostScript arrays,
313 ;; and should contain the PostScript string delimiters '(' and ')'.
315 ;; Symbols in the header format lists can either represent functions
316 ;; or variables. Functions are called, and should return a string to
317 ;; show in the header. Variables should contain strings to display in
318 ;; the header. In either case, function or variable, the PostScript
319 ;; string delimiters are added by ps-print, and should not be part of
320 ;; the returned value.
322 ;; Here's an example: say we want the left header to display the text
324 ;; Moe
325 ;; Larry
326 ;; Curly
328 ;; where we have a function to return "Moe"
330 ;; (defun moe-func ()
331 ;; "Moe")
333 ;; a variable specifying "Larry"
335 ;; (setq larry-var "Larry")
337 ;; and a literal for "Curly". Here's how `ps-left-header' should be
338 ;; set:
340 ;; (setq ps-left-header (list 'moe-func 'larry-var "(Curly)"))
342 ;; Note that Curly has the PostScript string delimiters inside his
343 ;; quotes -- those aren't misplaced lisp delimiters!
345 ;; Without them, PostScript would attempt to call the undefined
346 ;; function Curly, which would result in a PostScript error.
348 ;; Since most printers don't report PostScript errors except by
349 ;; aborting the print job, this kind of error can be hard to track down.
351 ;; Consider yourself warned!
354 ;; Duplex Printers
355 ;; ---------------
357 ;; If you have a duplex-capable printer (one that prints both sides of
358 ;; the paper), set `ps-spool-duplex' to t.
359 ;; Ps-print will insert blank pages to make sure each buffer starts
360 ;; on the correct side of the paper.
361 ;; Don't forget to set `ps-lpr-switches' to select duplex printing
362 ;; for your printer.
365 ;; Line Number
366 ;; -----------
368 ;; The variable `ps-line-number' specifies whether to number each line;
369 ;; non-nil means do so. The default is nil (don't number each line).
372 ;; Zebra Stripes
373 ;; -------------
375 ;; Zebra stripes are a kind of background that appear "underneath" the text
376 ;; and can make the text easier to read. They look like this:
378 ;; XXXXXXXXXXXXXXXXXXXXXXXX
379 ;; XXXXXXXXXXXXXXXXXXXXXXXX
380 ;; XXXXXXXXXXXXXXXXXXXXXXXX
384 ;; XXXXXXXXXXXXXXXXXXXXXXXX
385 ;; XXXXXXXXXXXXXXXXXXXXXXXX
386 ;; XXXXXXXXXXXXXXXXXXXXXXXX
388 ;; The blocks of X's represent rectangles filled with a light gray color.
389 ;; Each rectangle extends all the way across the page.
391 ;; The height, in lines, of each rectangle is controlled by
392 ;; the variable `ps-zebra-stripe-height', which is 3 by default.
393 ;; The distance between stripes equals the height of a stripe.
395 ;; The variable `ps-zebra-stripes' controls whether to print zebra stripes.
396 ;; Non-nil means yes, nil means no. The default is nil.
398 ;; See also section How Ps-Print Has A Text And/Or Image On Background.
401 ;; Font managing
402 ;; -------------
404 ;; Ps-print now knows rather precisely some fonts:
405 ;; the variable `ps-font-info-database' contains information
406 ;; for a list of font families (currently mainly `Courier' `Helvetica'
407 ;; `Times' `Palatino' `Helvetica-Narrow' `NewCenturySchlbk').
408 ;; Each font family contains the font names for standard, bold, italic
409 ;; and bold-italic characters, a reference size (usually 10) and the
410 ;; corresponding line height, width of a space and average character width.
412 ;; The variable `ps-font-family' determines which font family
413 ;; is to be used for ordinary text.
414 ;; If its value does not correspond to a known font family,
415 ;; an error message is printed into the `*Messages*' buffer,
416 ;; which lists the currently available font families.
418 ;; The variable `ps-font-size' determines the size (in points)
419 ;; of the font for ordinary text, when generating Postscript.
420 ;; Its value is a float.
422 ;; Similarly, the variable `ps-header-font-family' determines
423 ;; which font family is to be used for text in the header.
424 ;; The variable `ps-header-font-size' determines the font size,
425 ;; in points, for text in the header.
426 ;; The variable `ps-header-title-font-size' determines the font size,
427 ;; in points, for the top line of text in the header.
430 ;; Adding a new font family
431 ;; ------------------------
433 ;; To use a new font family, you MUST first teach ps-print
434 ;; this font, i.e., add its information to `ps-font-info-database',
435 ;; otherwise ps-print cannot correctly place line and page breaks.
437 ;; For example, assuming `Helvetica' is unknown,
438 ;; you first need to do the following ONLY ONCE:
440 ;; - create a new buffer
441 ;; - generate the PostScript image to a file (C-u M-x ps-print-buffer)
442 ;; - open this file and find the line:
443 ;; `% 3 cm 20 cm moveto 10 /Courier ReportFontInfo showpage'
444 ;; - delete the leading `%' (which is the PostScript comment character)
445 ;; - replace in this line `Courier' by the new font (say `Helvetica')
446 ;; to get the line:
447 ;; `3 cm 20 cm moveto 10 /Helvetica ReportFontInfo showpage'
448 ;; - send this file to the printer (or to ghostscript).
449 ;; You should read the following on the output page:
451 ;; For Helvetica 10 point, the line height is 11.56, the space width is 2.78
452 ;; and a crude estimate of average character width is 5.09243
454 ;; - Add these values to the `ps-font-info-database':
455 ;; (setq ps-font-info-database
456 ;; (append
457 ;; '((Helvetica ; the family name
458 ;; "Helvetica" "Helvetica-Bold" "Helvetica-Oblique" "Helvetica-BoldOblique"
459 ;; 10.0 11.56 2.78 5.09243))
460 ;; ps-font-info-database))
461 ;; - Now you can use this font family with any size:
462 ;; (setq ps-font-family 'Helvetica)
463 ;; - if you want to use this family in another emacs session, you must
464 ;; put into your `~/.emacs':
465 ;; (require 'ps-print)
466 ;; (setq ps-font-info-database (append ...)))
467 ;; if you don't want to load ps-print, you have to copy the whole value:
468 ;; (setq ps-font-info-database '(<your stuff> <the standard stuff>))
469 ;; or, if you can wait until the `ps-print-hook' is implemented, do:
470 ;; (add-hook 'ps-print-hook '(setq ps-font-info-database (append ...)))
471 ;; This does not work yet, since there is no `ps-print-hook' yet.
473 ;; You can create new `mixed' font families like:
474 ;; (my-mixed-family
475 ;; "Courier-Bold" "Helvetica"
476 ;; "Zapf-Chancery-MediumItalic" "NewCenturySchlbk-BoldItalic"
477 ;; 10.0 10.55 6.0 6.0)
478 ;; Now you can use your new font family with any size:
479 ;; (setq ps-font-family 'my-mixed-family)
481 ;; You can get information on all the fonts resident in YOUR printer
482 ;; by uncommenting the line:
483 ;; % 3 cm 20 cm moveto ReportAllFontInfo showpage
485 ;; The PostScript file should be sent to YOUR PostScript printer.
486 ;; If you send it to ghostscript or to another PostScript printer,
487 ;; you may get slightly different results.
488 ;; Anyway, as ghostscript fonts are autoload, you won't get
489 ;; much font info.
492 ;; How Ps-Print Deals With Faces
493 ;; -----------------------------
495 ;; The ps-print-*-with-faces commands attempt to determine which faces
496 ;; should be printed in bold or italic, but their guesses aren't
497 ;; always right. For example, you might want to map colors into faces
498 ;; so that blue faces print in bold, and red faces in italic.
500 ;; It is possible to force ps-print to consider specific faces bold or
501 ;; italic, no matter what font they are displayed in, by setting the
502 ;; variables `ps-bold-faces' and `ps-italic-faces'. These variables
503 ;; contain lists of faces that ps-print should consider bold or
504 ;; italic; to set them, put code like the following into your .emacs
505 ;; file:
507 ;; (setq ps-bold-faces '(my-blue-face))
508 ;; (setq ps-italic-faces '(my-red-face))
510 ;; Faces like bold-italic that are both bold and italic should go in
511 ;; *both* lists.
513 ;; Ps-print keeps internal lists of which fonts are bold and which are
514 ;; italic; these lists are built the first time you invoke ps-print.
515 ;; For the sake of efficiency, the lists are built only once; the same
516 ;; lists are referred in later invocations of ps-print.
518 ;; Because these lists are built only once, it's possible for them to
519 ;; get out of sync, if a face changes, or if new faces are added. To
520 ;; get the lists back in sync, you can set the variable
521 ;; `ps-build-face-reference' to t, and the lists will be rebuilt the
522 ;; next time ps-print is invoked.
525 ;; How Ps-Print Deals With Color
526 ;; -----------------------------
528 ;; Ps-print detects faces with foreground and background colors
529 ;; defined and embeds color information in the PostScript image.
530 ;; The default foreground and background colors are defined by the
531 ;; variables `ps-default-fg' and `ps-default-bg'.
532 ;; On black-and-white printers, colors are displayed in grayscale.
533 ;; To turn off color output, set `ps-print-color-p' to nil.
536 ;; How Ps-Print Maps Faces
537 ;; -----------------------
539 ;; As ps-print uses PostScript to print buffers, it is possible to have
540 ;; other attributes associated with faces. So the new attributes used
541 ;; by ps-print are:
543 ;; strikeout - like underline, but the line is in middle of text.
544 ;; overline - like underline, but the line is over the text.
545 ;; shadow - text will have a shadow.
546 ;; box - text will be surrounded by a box.
547 ;; outline - print characters as hollow outlines.
549 ;; See the documentation for `ps-extend-face'.
551 ;; Let's, for example, remap font-lock-keyword-face to another foreground color
552 ;; and bold attribute:
554 ;; (ps-extend-face '(font-lock-keyword-face "RoyalBlue" nil bold) 'MERGE)
556 ;; If you want to use a new face, define it first with `defface',
557 ;; and then call `ps-extend-face' to specify how to print it.
560 ;; How Ps-Print Has A Text And/Or Image On Background
561 ;; --------------------------------------------------
563 ;; Ps-print can print texts and/or EPS PostScript images on background; it is
564 ;; possible to define the following text attributes: font name, font size,
565 ;; initial position, angle, gray scale and pages to print.
567 ;; It has the following EPS PostScript images attributes: file name containing
568 ;; the image, initial position, X and Y scales, angle and pages to print.
570 ;; See documentation for `ps-print-background-text' and
571 ;; `ps-print-background-image'.
573 ;; For example, if we wish to print text "preliminary" on all pages and text
574 ;; "special" on page 5 and from page 11 to page 17, we could specify:
576 ;; (setq ps-print-background-text
577 ;; '(("preliminary")
578 ;; ("special"
579 ;; "LeftMargin" "BottomMargin PrintHeight add" ; X and Y position
580 ;; ; (upper left corner)
581 ;; nil nil nil
582 ;; "PrintHeight neg PrintWidth atan" ; angle
583 ;; 5 (11 . 17)) ; page list
584 ;; ))
586 ;; Similarly, we could print image "~/images/EPS-image1.ps" on all pages and
587 ;; image "~/images/EPS-image2.ps" on page 5 and from page 11 to page 17, we
588 ;; specify:
590 ;; (setq ps-print-background-image
591 ;; '(("~/images/EPS-image1.ps"
592 ;; "LeftMargin" "BottomMargin") ; X and Y position (lower left corner)
593 ;; ("~/images/EPS-image2.ps"
594 ;; "LeftMargin" "BottomMargin PrintHeight 2 div add" ; X and Y position
595 ;; ; (upper left corner)
596 ;; nil nil nil
597 ;; 5 (11 . 17)) ; page list
598 ;; ))
600 ;; If it is not possible to read (or does not exist) an image file, that file
601 ;; is ignored.
603 ;; The printing order is:
605 ;; 1. Print zebra stripes
606 ;; 2. Print background texts that it should be on all pages
607 ;; 3. Print background images that it should be on all pages
608 ;; 4. Print background texts only for current page (if any)
609 ;; 5. Print background images only for current page (if any)
610 ;; 6. Print header
611 ;; 7. Print buffer text (with faces, if specified) and line number
614 ;; Utilities
615 ;; ---------
617 ;; Some tools are provided to help you customize your font setup.
619 ;; `ps-setup' returns (some part of) the current setup.
621 ;; To avoid wrapping too many lines, you may want to adjust the
622 ;; left and right margins and the font size. On UN*X systems, do:
623 ;; pr -t file | awk '{printf "%3d %s\n", length($0), $0}' | sort -r | head
624 ;; to determine the longest lines of your file.
625 ;; Then, the command `ps-line-lengths' will give you the correspondence
626 ;; between a line length (number of characters) and the maximum font
627 ;; size which doesn't wrap such a line with the current ps-print setup.
629 ;; The commands `ps-nb-pages-buffer' and `ps-nb-pages-region' display
630 ;; the correspondence between a number of pages and the maximum font
631 ;; size which allow the number of lines of the current buffer or of
632 ;; its current region to fit in this number of pages.
634 ;; NOTE: line folding is not taken into account in this process and could
635 ;; change the results.
638 ;; New since version 1.5
639 ;; ---------------------
641 ;; Color output capability.
642 ;; Automatic detection of font attributes (bold, italic).
643 ;; Configurable headers with page numbers.
644 ;; Slightly faster.
645 ;; Support for different paper sizes.
646 ;; Better conformance to PostScript Document Structure Conventions.
649 ;; New since version 2.8
650 ;; ---------------------
652 ;; [vinicius] 970809 Vinicius Jose Latorre <vinicius@cpqd.br>
654 ;; Handle control characters.
655 ;; Face remapping.
656 ;; New face attributes.
657 ;; Line number.
658 ;; Zebra stripes.
659 ;; Text and/or image on background.
661 ;; [jack] 960517 Jacques Duthen <duthen@cegelec-red.fr>
663 ;; Font family and float size for text and header.
664 ;; Landscape mode.
665 ;; Multiple columns.
666 ;; Tools for page setup.
669 ;; Known bugs and limitations of ps-print:
670 ;; --------------------------------------
672 ;; Although color printing will work in XEmacs 19.12, it doesn't work
673 ;; well; in particular, bold or italic fonts don't print in the right
674 ;; background color.
676 ;; Invisible properties aren't correctly ignored in XEmacs 19.12.
678 ;; Automatic font-attribute detection doesn't work well, especially
679 ;; with hilit19 and older versions of get-create-face. Users having
680 ;; problems with auto-font detection should use the lists
681 ;; `ps-italic-faces' and `ps-bold-faces' and/or turn off automatic
682 ;; detection by setting `ps-auto-font-detect' to nil.
684 ;; Automatic font-attribute detection doesn't work with XEmacs 19.12
685 ;; in tty mode; use the lists `ps-italic-faces' and `ps-bold-faces'
686 ;; instead.
688 ;; Still too slow; could use some hand-optimization.
690 ;; Default background color isn't working.
692 ;; Faces are always treated as opaque.
694 ;; Epoch and Emacs 18 not supported. At all.
696 ;; Fixed-pitch fonts work better for line folding, but are not required.
698 ;; `ps-nb-pages-buffer' and `ps-nb-pages-region' don't take care
699 ;; of folding lines.
702 ;; Things to change:
703 ;; ----------------
705 ;; Add `ps-print-hook' (I don't know how to do that (yet!)).
706 ;; Add 4-up capability (really needed?).
707 ;; Add `ps-non-bold-faces' and `ps-non-italic-faces' (should be easy).
708 ;; Put one header per page over the columns (easy but needed?).
709 ;; Improve the memory management for big files (hard?).
710 ;; `ps-nb-pages-buffer' and `ps-nb-pages-region' should take care
711 ;; of folding lines.
714 ;; Acknowledgements
715 ;; ----------------
716 ;; Thanks to Jim Thompson <?@?> for the 2.8 version I started from.
717 ;; [jack]
719 ;; Thanks to Kevin Rodgers <kevinr@ihs.com> for adding support for
720 ;; color and the invisible property.
722 ;; Thanks to Avishai Yacobi, avishaiy@mcil.comm.mot.com, for writing
723 ;; the initial port to Emacs 19. His code is no longer part of
724 ;; ps-print, but his work is still appreciated.
726 ;; Thanks to Remi Houdaille and Michel Train, michel@metasoft.fdn.org,
727 ;; for adding underline support. Their code also is no longer part of
728 ;; ps-print, but their efforts are not forgotten.
730 ;; Thanks also to all of you who mailed code to add features to
731 ;; ps-print; although I didn't use your code, I still appreciate your
732 ;; sharing it with me.
734 ;; Thanks to all who mailed comments, encouragement, and criticism.
735 ;; Thanks also to all who responded to my survey; I had too many
736 ;; responses to reply to them all, but I greatly appreciate your
737 ;; interest.
739 ;; Jim
740 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
742 ;;; Code:
744 (eval-when-compile
745 (require 'cl))
747 (unless (featurep 'lisp-float-type)
748 (error "`ps-print' requires floating point support"))
750 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
751 ;; User Variables:
753 ;;; Interface to the command system
755 (defgroup ps-print nil
756 "Postscript generator for Emacs 19"
757 :prefix "ps-"
758 :group 'wp)
760 (defgroup ps-print-horizontal nil
761 "Horizontal page layout"
762 :prefix "ps-"
763 :tag "Horizontal"
764 :group 'ps-print)
766 (defgroup ps-print-vertical nil
767 "Vertical page layout"
768 :prefix "ps-"
769 :tag "Vertical"
770 :group 'ps-print)
772 (defgroup ps-print-header nil
773 "Headers layout"
774 :prefix "ps-"
775 :tag "Header"
776 :group 'ps-print)
778 (defgroup ps-print-font nil
779 "Fonts customization"
780 :prefix "ps-"
781 :tag "Font"
782 :group 'ps-print)
784 (defgroup ps-print-color nil
785 "Color customization"
786 :prefix "ps-"
787 :tag "Color"
788 :group 'ps-print)
790 (defgroup ps-print-face nil
791 "Faces customization"
792 :prefix "ps-"
793 :tag "PS Faces"
794 :group 'ps-print
795 :group 'faces)
798 (defcustom ps-lpr-command lpr-command
799 "*The shell command for printing a PostScript file."
800 :type 'string
801 :group 'ps-print)
803 (defcustom ps-lpr-switches lpr-switches
804 "*A list of extra switches to pass to `ps-lpr-command'."
805 :type '(repeat string)
806 :group 'ps-print)
808 ;;; Page layout
810 ;; All page dimensions are in PostScript points.
811 ;; 1 inch == 2.54 cm == 72 points
812 ;; 1 cm == (/ 1 2.54) inch == (/ 72 2.54) points
814 ;; Letter 8.5 inch x 11.0 inch
815 ;; Legal 8.5 inch x 14.0 inch
816 ;; A4 8.26 inch x 11.69 inch = 21.0 cm x 29.7 cm
818 ;; LetterSmall 7.68 inch x 10.16 inch
819 ;; Tabloid 11.0 inch x 17.0 inch
820 ;; Ledger 17.0 inch x 11.0 inch
821 ;; Statement 5.5 inch x 8.5 inch
822 ;; Executive 7.5 inch x 10.0 inch
823 ;; A3 11.69 inch x 16.5 inch = 29.7 cm x 42.0 cm
824 ;; A4Small 7.47 inch x 10.85 inch
825 ;; B4 10.125 inch x 14.33 inch
826 ;; B5 7.16 inch x 10.125 inch
828 (defcustom ps-page-dimensions-database
829 (list (list 'a4 (/ (* 72 21.0) 2.54) (/ (* 72 29.7) 2.54))
830 (list 'a3 (/ (* 72 29.7) 2.54) (/ (* 72 42.0) 2.54))
831 (list 'letter (* 72 8.5) (* 72 11.0))
832 (list 'legal (* 72 8.5) (* 72 14.0))
833 (list 'letter-small (* 72 7.68) (* 72 10.16))
834 (list 'tabloid (* 72 11.0) (* 72 17.0))
835 (list 'ledger (* 72 17.0) (* 72 11.0))
836 (list 'statement (* 72 5.5) (* 72 8.5))
837 (list 'executive (* 72 7.5) (* 72 10.0))
838 (list 'a4small (* 72 7.47) (* 72 10.85))
839 (list 'b4 (* 72 10.125) (* 72 14.33))
840 (list 'b5 (* 72 7.16) (* 72 10.125)))
841 "*List associating a symbolic paper type to its width and height.
842 see `ps-paper-type'."
843 :type '(repeat (list :tag "Paper Type"
844 (symbol :tag "Name")
845 (number :tag "Width")
846 (number :tag "Height")))
847 :group 'ps-print)
849 (defcustom ps-paper-type 'letter
850 "*Specifies the size of paper to format for.
851 Should be one of the paper types defined in `ps-page-dimensions-database', for
852 example `letter', `legal' or `a4'."
853 :type '(symbol :validate (lambda (wid)
854 (if (assq (widget-value wid)
855 ps-page-dimensions-database)
857 (widget-put wid :error "Unknown paper size")
858 wid)))
859 :group 'ps-print)
861 (defcustom ps-landscape-mode nil
862 "*Non-nil means print in landscape mode."
863 :type 'boolean
864 :group 'ps-print)
866 (defcustom ps-number-of-columns (if ps-landscape-mode 2 1)
867 "*Specifies the number of columns"
868 :type 'number
869 :group 'ps-print)
871 (defcustom ps-zebra-stripes nil
872 "*Non-nil means print zebra stripes.
873 See also documentation for `ps-zebra-stripe-height'."
874 :type 'boolean
875 :group 'ps-print)
877 (defcustom ps-zebra-stripe-height 3
878 "*Number of zebra stripe lines.
879 See also documentation for `ps-zebra-stripes'."
880 :type 'number
881 :group 'ps-print)
883 (defcustom ps-line-number nil
884 "*Non-nil means print line number."
885 :type 'boolean
886 :group 'ps-print)
888 (defcustom ps-print-background-image nil
889 "*EPS image list to be printed on background.
891 The elements are:
893 (FILENAME X Y XSCALE YSCALE ROTATION PAGES...)
895 FILENAME is a file name which contains an EPS image or some PostScript
896 programming like EPS.
897 FILENAME is ignored, if it doesn't exist or is read protected.
899 X and Y are relative positions on paper to put the image.
900 If X and Y are nil, the image is centralized on paper.
902 XSCALE and YSCALE are scale factor to be applied to image before printing.
903 If XSCALE and YSCALE are nil, the original size is used.
905 ROTATION is the image rotation angle; if nil, the default is 0.
907 PAGES designates the page to print background image.
908 PAGES may be a number or a cons cell (FROM . TO) designating FROM page
909 to TO page.
910 If PAGES is nil, print background image on all pages.
912 X, Y, XSCALE, YSCALE and ROTATION may be a floating point number,
913 an integer number or a string. If it is a string, the string should contain
914 PostScript programming that returns a float or integer value.
916 For example, if you wish to print an EPS image on all pages do:
918 '((\"~/images/EPS-image.ps\"))"
919 :type '(repeat (list file
920 (choice :tag "X" number string (const nil))
921 (choice :tag "Y" number string (const nil))
922 (choice :tag "X Scale" number string (const nil))
923 (choice :tag "Y Scale" number string (const nil))
924 (choice :tag "Rotation" number string (const nil))
925 (repeat :tag "Pages" :inline t
926 (radio integer
927 (cons :tag "Range"
928 (integer :tag "From")
929 (integer :tag "To"))))))
930 :group 'ps-print)
932 (defcustom ps-print-background-text nil
933 "*Text list to be printed on background.
935 The elements are:
937 (STRING X Y FONT FONTSIZE GRAY ROTATION PAGES...)
939 STRING is the text to be printed on background.
941 X and Y are positions on paper to put the text.
942 If X and Y are nil, the text is positioned at lower left corner.
944 FONT is a font name to be used on printing the text.
945 If nil, \"Times-Roman\" is used.
947 FONTSIZE is font size to be used, if nil, 200 is used.
949 GRAY is the text gray factor (should be very light like 0.8).
950 If nil, the default is 0.85.
952 ROTATION is the text rotation angle; if nil, the angle is given by
953 the diagonal from lower left corner to upper right corner.
955 PAGES designates the page to print background text.
956 PAGES may be a number or a cons cell (FROM . TO) designating FROM page
957 to TO page.
958 If PAGES is nil, print background text on all pages.
960 X, Y, FONTSIZE, GRAY and ROTATION may be a floating point number,
961 an integer number or a string. If it is a string, the string should contain
962 PostScript programming that returns a float or integer value.
964 For example, if you wish to print text \"Preliminary\" on all pages do:
966 '((\"Preliminary\"))"
967 :type '(repeat (list string
968 (choice :tag "X" number string (const nil))
969 (choice :tag "Y" number string (const nil))
970 (choice :tag "Font" string (const nil))
971 (choice :tag "Fontsize" number string (const nil))
972 (choice :tag "Gray" number string (const nil))
973 (choice :tag "Rotation" number string (const nil))
974 (repeat :tag "Pages" :inline t
975 (radio integer
976 (cons :tag "Range"
977 (integer :tag "From")
978 (integer :tag "To"))))))
979 :group 'ps-print)
981 ;;; Horizontal layout
983 ;; ------------------------------------------
984 ;; | | | | | | | |
985 ;; | lm | text | ic | text | ic | text | rm |
986 ;; | | | | | | | |
987 ;; ------------------------------------------
989 (defcustom ps-left-margin (/ (* 72 2.0) 2.54) ; 2 cm
990 "*Left margin in points (1/72 inch)."
991 :type 'number
992 :group 'ps-print-horizontal)
994 (defcustom ps-right-margin (/ (* 72 2.0) 2.54) ; 2 cm
995 "*Right margin in points (1/72 inch)."
996 :type 'number
997 :group 'ps-print-horizontal)
999 (defcustom ps-inter-column (/ (* 72 2.0) 2.54) ; 2 cm
1000 "*Horizontal space between columns in points (1/72 inch)."
1001 :type 'number
1002 :group 'ps-print-horizontal)
1004 ;;; Vertical layout
1006 ;; |--------|
1007 ;; | tm |
1008 ;; |--------|
1009 ;; | header |
1010 ;; |--------|
1011 ;; | ho |
1012 ;; |--------|
1013 ;; | text |
1014 ;; |--------|
1015 ;; | bm |
1016 ;; |--------|
1018 (defcustom ps-bottom-margin (/ (* 72 1.5) 2.54) ; 1.5 cm
1019 "*Bottom margin in points (1/72 inch)."
1020 :type 'number
1021 :group 'ps-print-vertical)
1023 (defcustom ps-top-margin (/ (* 72 1.5) 2.54) ; 1.5 cm
1024 "*Top margin in points (1/72 inch)."
1025 :type 'number
1026 :group 'ps-print-vertical)
1028 (defcustom ps-header-offset (/ (* 72 1.0) 2.54) ; 1.0 cm
1029 "*Vertical space in points (1/72 inch) between the main text and the header."
1030 :type 'number
1031 :group 'ps-print-vertical)
1033 (defcustom ps-header-line-pad 0.15
1034 "*Portion of a header title line height to insert between the header frame
1035 and the text it contains, both in the vertical and horizontal directions."
1036 :type 'number
1037 :group 'ps-print-vertical)
1039 ;;; Header setup
1041 (defcustom ps-print-header t
1042 "*Non-nil means print a header at the top of each page.
1043 By default, the header displays the buffer name, page number, and, if
1044 the buffer is visiting a file, the file's directory. Headers are
1045 customizable by changing variables `ps-left-header' and
1046 `ps-right-header'."
1047 :type 'boolean
1048 :group 'ps-print-header)
1050 (defcustom ps-print-header-frame t
1051 "*Non-nil means draw a gaudy frame around the header."
1052 :type 'boolean
1053 :group 'ps-print-header)
1055 (defcustom ps-header-lines 2
1056 "*Number of lines to display in page header, when generating Postscript."
1057 :type 'integer
1058 :group 'ps-print-header)
1059 (make-variable-buffer-local 'ps-header-lines)
1061 (defcustom ps-show-n-of-n t
1062 "*Non-nil means show page numbers as N/M, meaning page N of M.
1063 Note: page numbers are displayed as part of headers, see variable
1064 `ps-print-header'."
1065 :type 'boolean
1066 :group 'ps-print-header)
1068 (defcustom ps-spool-duplex nil ; Not many people have duplex
1069 ; printers, so default to nil.
1070 "*Non-nil indicates spooling is for a two-sided printer.
1071 For a duplex printer, the `ps-spool-*' commands will insert blank pages
1072 as needed between print jobs so that the next buffer printed will
1073 start on the right page. Also, if headers are turned on, the headers
1074 will be reversed on duplex printers so that the page numbers fall to
1075 the left on even-numbered pages."
1076 :type 'boolean
1077 :group 'ps-print-header)
1079 ;;; Fonts
1081 (defcustom ps-font-info-database
1082 '((Courier ; the family key
1083 "Courier" "Courier-Bold" "Courier-Oblique" "Courier-BoldOblique"
1084 10.0 10.55 6.0 6.0)
1085 (Helvetica ; the family key
1086 "Helvetica" "Helvetica-Bold" "Helvetica-Oblique" "Helvetica-BoldOblique"
1087 10.0 11.56 2.78 5.09243)
1088 (Times
1089 "Times-Roman" "Times-Bold" "Times-Italic" "Times-BoldItalic"
1090 10.0 11.0 2.5 4.71432)
1091 (Palatino
1092 "Palatino-Roman" "Palatino-Bold" "Palatino-Italic" "Palatino-BoldItalic"
1093 10.0 12.1 2.5 5.08676)
1094 (Helvetica-Narrow
1095 "Helvetica-Narrow" "Helvetica-Narrow-Bold"
1096 "Helvetica-Narrow-Oblique" "Helvetica-Narrow-BoldOblique"
1097 10.0 11.56 2.2796 4.17579)
1098 (NewCenturySchlbk
1099 "NewCenturySchlbk-Roman" "NewCenturySchlbk-Bold"
1100 "NewCenturySchlbk-Italic" "NewCenturySchlbk-BoldItalic"
1101 10.0 12.15 2.78 5.31162)
1102 ;; got no bold for the next ones
1103 (AvantGarde-Book
1104 "AvantGarde-Book" "AvantGarde-Book"
1105 "AvantGarde-BookOblique" "AvantGarde-BookOblique"
1106 10.0 11.77 2.77 5.45189)
1107 (AvantGarde-Demi
1108 "AvantGarde-Demi" "AvantGarde-Demi"
1109 "AvantGarde-DemiOblique" "AvantGarde-DemiOblique"
1110 10.0 12.72 2.8 5.51351)
1111 (Bookman-Demi
1112 "Bookman-Demi" "Bookman-Demi"
1113 "Bookman-DemiItalic" "Bookman-DemiItalic"
1114 10.0 11.77 3.4 6.05946)
1115 (Bookman-Light
1116 "Bookman-Light" "Bookman-Light"
1117 "Bookman-LightItalic" "Bookman-LightItalic"
1118 10.0 11.79 3.2 5.67027)
1119 ;; got no bold and no italic for the next ones
1120 (Symbol
1121 "Symbol" "Symbol" "Symbol" "Symbol"
1122 10.0 13.03 2.5 3.24324)
1123 (Zapf-Dingbats
1124 "Zapf-Dingbats" "Zapf-Dingbats" "Zapf-Dingbats" "Zapf-Dingbats"
1125 10.0 9.63 2.78 2.78)
1126 (Zapf-Chancery-MediumItalic
1127 "Zapf-Chancery-MediumItalic" "Zapf-Chancery-MediumItalic"
1128 "Zapf-Chancery-MediumItalic" "Zapf-Chancery-MediumItalic"
1129 10.0 11.45 2.2 4.10811)
1131 "*Font info database: font family (the key), name, bold, italic, bold-italic,
1132 reference size, line height, space width, average character width.
1133 To get the info for another specific font (say Helvetica), do the following:
1134 - create a new buffer
1135 - generate the PostScript image to a file (C-u M-x ps-print-buffer)
1136 - open this file and delete the leading `%' (which is the Postscript
1137 comment character) from the line
1138 `% 3 cm 20 cm moveto 10 /Courier ReportFontInfo showpage'
1139 to get the line
1140 `3 cm 20 cm moveto 10 /Helvetica ReportFontInfo showpage'
1141 - add the values to `ps-font-info-database'.
1142 You can get all the fonts of YOUR printer using `ReportAllFontInfo'."
1143 :type '(repeat (list :tag "Font Definition"
1144 (symbol :tag "Font")
1145 (string :tag "Name")
1146 (string :tag "Bold")
1147 (string :tag "Italic")
1148 (string :tag "Bold-Italic")
1149 (number :tag "Reference Size")
1150 (number :tag "Line Height")
1151 (number :tag "Space Width")
1152 (number :tag "Average Character Width")))
1153 :group 'ps-print-font)
1155 (defcustom ps-font-family 'Courier
1156 "Font family name for ordinary text, when generating Postscript."
1157 :type 'symbol
1158 :group 'ps-print-font)
1160 (defcustom ps-font-size (if ps-landscape-mode 7 8.5)
1161 "Font size, in points, for ordinary text, when generating Postscript."
1162 :type 'number
1163 :group 'ps-print-font)
1165 (defcustom ps-header-font-family 'Helvetica
1166 "Font family name for text in the header, when generating Postscript."
1167 :type 'symbol
1168 :group 'ps-print-font)
1170 (defcustom ps-header-font-size (if ps-landscape-mode 10 12)
1171 "Font size, in points, for text in the header, when generating Postscript."
1172 :type 'number
1173 :group 'ps-print-font)
1175 (defcustom ps-header-title-font-size (if ps-landscape-mode 12 14)
1176 "Font size, in points, for the top line of text in the header,
1177 when generating Postscript."
1178 :type 'number
1179 :group 'ps-print-font)
1181 ;;; Colors
1183 ;; Printing color requires x-color-values.
1184 (defcustom ps-print-color-p (or (fboundp 'x-color-values) ; Emacs
1185 (fboundp 'pixel-components)) ; XEmacs
1186 "*If non-nil, print the buffer's text in color."
1187 :type 'boolean
1188 :group 'ps-print-color)
1190 (defcustom ps-default-fg '(0.0 0.0 0.0)
1191 "*RGB values of the default foreground color. Defaults to black."
1192 :type '(list (number :tag "Red") (number :tag "Green") (number :tag "Blue"))
1193 :group 'ps-print-color)
1195 (defcustom ps-default-bg '(1.0 1.0 1.0)
1196 "*RGB values of the default background color. Defaults to white."
1197 :type '(list (number :tag "Red") (number :tag "Green") (number :tag "Blue"))
1198 :group 'ps-print-color)
1200 (defcustom ps-auto-font-detect t
1201 "*Non-nil means automatically detect bold/italic face attributes.
1202 If nil, we rely solely on the lists `ps-bold-faces', `ps-italic-faces',
1203 and `ps-underlined-faces'."
1204 :type 'boolean
1205 :group 'ps-print-font)
1207 (defcustom ps-bold-faces
1208 (unless ps-print-color-p
1209 '(font-lock-function-name-face
1210 font-lock-builtin-face
1211 font-lock-variable-name-face
1212 font-lock-keyword-face
1213 font-lock-warning-face))
1214 "*A list of the \(non-bold\) faces that should be printed in bold font.
1215 This applies to generating Postscript."
1216 :type '(repeat face)
1217 :group 'ps-print-face)
1219 (defcustom ps-italic-faces
1220 (unless ps-print-color-p
1221 '(font-lock-variable-name-face
1222 font-lock-string-face
1223 font-lock-comment-face
1224 font-lock-warning-face))
1225 "*A list of the \(non-italic\) faces that should be printed in italic font.
1226 This applies to generating Postscript."
1227 :type '(repeat face)
1228 :group 'ps-print-face)
1230 (defcustom ps-underlined-faces
1231 (unless ps-print-color-p
1232 '(font-lock-function-name-face
1233 font-lock-type-face
1234 font-lock-reference-face
1235 font-lock-warning-face))
1236 "*A list of the \(non-underlined\) faces that should be printed underlined.
1237 This applies to generating Postscript."
1238 :type '(repeat face)
1239 :group 'ps-print-face)
1241 (defcustom ps-left-header
1242 (list 'ps-get-buffer-name 'ps-header-dirpart)
1243 "*The items to display (each on a line) on the left part of the page header.
1244 This applies to generating Postscript.
1246 The value should be a list of strings and symbols, each representing an
1247 entry in the PostScript array HeaderLinesLeft.
1249 Strings are inserted unchanged into the array; those representing
1250 PostScript string literals should be delimited with PostScript string
1251 delimiters '(' and ')'.
1253 For symbols with bound functions, the function is called and should
1254 return a string to be inserted into the array. For symbols with bound
1255 values, the value should be a string to be inserted into the array.
1256 In either case, function or variable, the string value has PostScript
1257 string delimiters added to it."
1258 :type '(repeat (choice string symbol))
1259 :group 'ps-print-header)
1260 (make-variable-buffer-local 'ps-left-header)
1262 (defcustom ps-right-header
1263 (list "/pagenumberstring load" 'time-stamp-mon-dd-yyyy 'time-stamp-hh:mm:ss)
1264 "*The items to display (each on a line) on the right part of the page header.
1265 This applies to generating Postscript.
1267 See the variable `ps-left-header' for a description of the format of
1268 this variable."
1269 :type '(repeat (choice string symbol))
1270 :group 'ps-print-header)
1271 (make-variable-buffer-local 'ps-right-header)
1273 (defcustom ps-razzle-dazzle t
1274 "*Non-nil means report progress while formatting buffer."
1275 :type 'boolean
1276 :group 'ps-print)
1278 (defcustom ps-adobe-tag "%!PS-Adobe-3.0\n"
1279 "*Contains the header line identifying the output as PostScript.
1280 By default, `ps-adobe-tag' contains the standard identifier. Some
1281 printers require slightly different versions of this line."
1282 :type 'string
1283 :group 'ps-print)
1285 (defcustom ps-build-face-reference t
1286 "*Non-nil means build the reference face lists.
1288 Ps-print sets this value to nil after it builds its internal reference
1289 lists of bold and italic faces. By settings its value back to t, you
1290 can force ps-print to rebuild the lists the next time you invoke one
1291 of the ...-with-faces commands.
1293 You should set this value back to t after you change the attributes of
1294 any face, or create new faces. Most users shouldn't have to worry
1295 about its setting, though."
1296 :type 'boolean
1297 :group 'ps-print-face)
1299 (defcustom ps-always-build-face-reference nil
1300 "*Non-nil means always rebuild the reference face lists.
1302 If this variable is non-nil, ps-print will rebuild its internal
1303 reference lists of bold and italic faces *every* time one of the
1304 -with-faces commands is called. Most users shouldn't need to set this
1305 variable."
1306 :type 'boolean
1307 :group 'ps-print-face)
1309 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1310 ;; User commands
1312 ;;;###autoload
1313 (defun ps-print-buffer (&optional filename)
1314 "Generate and print a PostScript image of the buffer.
1316 When called with a numeric prefix argument (C-u), prompts the user for
1317 the name of a file to save the PostScript image in, instead of sending
1318 it to the printer.
1320 More specifically, the FILENAME argument is treated as follows: if it
1321 is nil, send the image to the printer. If FILENAME is a string, save
1322 the PostScript image in a file with that name. If FILENAME is a
1323 number, prompt the user for the name of the file to save in."
1324 (interactive (list (ps-print-preprint current-prefix-arg)))
1325 (ps-print-without-faces (point-min) (point-max) filename))
1328 ;;;###autoload
1329 (defun ps-print-buffer-with-faces (&optional filename)
1330 "Generate and print a PostScript image of the buffer.
1331 Like `ps-print-buffer', but includes font, color, and underline
1332 information in the generated image. This command works only if you
1333 are using a window system, so it has a way to determine color values."
1334 (interactive (list (ps-print-preprint current-prefix-arg)))
1335 (ps-print-with-faces (point-min) (point-max) filename))
1338 ;;;###autoload
1339 (defun ps-print-region (from to &optional filename)
1340 "Generate and print a PostScript image of the region.
1341 Like `ps-print-buffer', but prints just the current region."
1342 (interactive (list (point) (mark) (ps-print-preprint current-prefix-arg)))
1343 (ps-print-without-faces from to filename t))
1346 ;;;###autoload
1347 (defun ps-print-region-with-faces (from to &optional filename)
1348 "Generate and print a PostScript image of the region.
1349 Like `ps-print-region', but includes font, color, and underline
1350 information in the generated image. This command works only if you
1351 are using a window system, so it has a way to determine color values."
1352 (interactive (list (point) (mark) (ps-print-preprint current-prefix-arg)))
1353 (ps-print-with-faces from to filename t))
1356 ;;;###autoload
1357 (defun ps-spool-buffer ()
1358 "Generate and spool a PostScript image of the buffer.
1359 Like `ps-print-buffer' except that the PostScript image is saved in a
1360 local buffer to be sent to the printer later.
1362 Use the command `ps-despool' to send the spooled images to the printer."
1363 (interactive)
1364 (ps-spool-without-faces (point-min) (point-max)))
1367 ;;;###autoload
1368 (defun ps-spool-buffer-with-faces ()
1369 "Generate and spool a PostScript image of the buffer.
1370 Like `ps-spool-buffer', but includes font, color, and underline
1371 information in the generated image. This command works only if you
1372 are using a window system, so it has a way to determine color values.
1374 Use the command `ps-despool' to send the spooled images to the printer."
1375 (interactive)
1376 (ps-spool-with-faces (point-min) (point-max)))
1379 ;;;###autoload
1380 (defun ps-spool-region (from to)
1381 "Generate a PostScript image of the region and spool locally.
1382 Like `ps-spool-buffer', but spools just the current region.
1384 Use the command `ps-despool' to send the spooled images to the printer."
1385 (interactive "r")
1386 (ps-spool-without-faces from to t))
1389 ;;;###autoload
1390 (defun ps-spool-region-with-faces (from to)
1391 "Generate a PostScript image of the region and spool locally.
1392 Like `ps-spool-region', but includes font, color, and underline
1393 information in the generated image. This command works only if you
1394 are using a window system, so it has a way to determine color values.
1396 Use the command `ps-despool' to send the spooled images to the printer."
1397 (interactive "r")
1398 (ps-spool-with-faces from to t))
1400 ;;;###autoload
1401 (defun ps-despool (&optional filename)
1402 "Send the spooled PostScript to the printer.
1404 When called with a numeric prefix argument (C-u), prompt the user for
1405 the name of a file to save the spooled PostScript in, instead of sending
1406 it to the printer.
1408 More specifically, the FILENAME argument is treated as follows: if it
1409 is nil, send the image to the printer. If FILENAME is a string, save
1410 the PostScript image in a file with that name. If FILENAME is a
1411 number, prompt the user for the name of the file to save in."
1412 (interactive (list (ps-print-preprint current-prefix-arg)))
1413 (ps-do-despool filename))
1415 ;;;###autoload
1416 (defun ps-line-lengths ()
1417 "Display the correspondence between a line length and a font size,
1418 using the current ps-print setup.
1419 Try: pr -t file | awk '{printf \"%3d %s\n\", length($0), $0}' | sort -r | head"
1420 (interactive)
1421 (ps-line-lengths-internal))
1423 ;;;###autoload
1424 (defun ps-nb-pages-buffer (nb-lines)
1425 "Display number of pages to print this buffer, for various font heights.
1426 The table depends on the current ps-print setup."
1427 (interactive (list (count-lines (point-min) (point-max))))
1428 (ps-nb-pages nb-lines))
1430 ;;;###autoload
1431 (defun ps-nb-pages-region (nb-lines)
1432 "Display number of pages to print the region, for various font heights.
1433 The table depends on the current ps-print setup."
1434 (interactive (list (count-lines (mark) (point))))
1435 (ps-nb-pages nb-lines))
1437 ;;;###autoload
1438 (defun ps-setup ()
1439 "Return the current setup."
1440 (format
1442 \(setq ps-print-color-p %s
1443 ps-lpr-command \"%s\"
1444 ps-lpr-switches %s
1446 ps-paper-type '%s
1447 ps-landscape-mode %s
1448 ps-number-of-columns %s
1450 ps-zebra-stripes %s
1451 ps-zebra-stripe-height %s
1452 ps-line-number %s
1454 ps-print-background-image %s
1456 ps-print-background-text %s
1458 ps-left-margin %s
1459 ps-right-margin %s
1460 ps-inter-column %s
1461 ps-bottom-margin %s
1462 ps-top-margin %s
1463 ps-header-offset %s
1464 ps-header-line-pad %s
1465 ps-print-header %s
1466 ps-print-header-frame %s
1467 ps-header-lines %s
1468 ps-show-n-of-n %s
1469 ps-spool-duplex %s
1471 ps-font-family '%s
1472 ps-font-size %s
1473 ps-header-font-family '%s
1474 ps-header-font-size %s
1475 ps-header-title-font-size %s)
1477 ps-print-color-p
1478 ps-lpr-command
1479 ps-lpr-switches
1480 ps-paper-type
1481 ps-landscape-mode
1482 ps-number-of-columns
1483 ps-zebra-stripes
1484 ps-zebra-stripe-height
1485 ps-line-number
1486 ps-print-background-image
1487 ps-print-background-text
1488 ps-left-margin
1489 ps-right-margin
1490 ps-inter-column
1491 ps-bottom-margin
1492 ps-top-margin
1493 ps-header-offset
1494 ps-header-line-pad
1495 ps-print-header
1496 ps-print-header-frame
1497 ps-header-lines
1498 ps-show-n-of-n
1499 ps-spool-duplex
1500 ps-font-family
1501 ps-font-size
1502 ps-header-font-family
1503 ps-header-font-size
1504 ps-header-title-font-size))
1506 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1507 ;; Utility functions and variables:
1509 (defvar ps-print-emacs-type
1510 (cond ((string-match "XEmacs" emacs-version) 'xemacs)
1511 ((string-match "Lucid" emacs-version) 'lucid)
1512 ((string-match "Epoch" emacs-version) 'epoch)
1513 (t 'emacs)))
1515 (if (or (eq ps-print-emacs-type 'lucid)
1516 (eq ps-print-emacs-type 'xemacs))
1517 (if (< emacs-minor-version 12)
1518 (setq ps-print-color-p nil))
1519 (require 'faces)) ; face-font, face-underline-p,
1520 ; x-font-regexp
1522 (require 'time-stamp)
1524 (defvar ps-font nil
1525 "Font family name for ordinary text, when generating Postscript.")
1527 (defvar ps-font-bold nil
1528 "Font family name for bold text, when generating Postscript.")
1530 (defvar ps-font-italic nil
1531 "Font family name for italic text, when generating Postscript.")
1533 (defvar ps-font-bold-italic nil
1534 "Font family name for bold italic text, when generating Postscript.")
1536 (defvar ps-avg-char-width nil
1537 "The average width, in points, of a character, for generating Postscript.
1538 This is the value that ps-print uses to determine the length,
1539 x-dimension, of the text it has printed, and thus affects the point at
1540 which long lines wrap around.")
1542 (defvar ps-space-width nil
1543 "The width of a space character, for generating Postscript.
1544 This value is used in expanding tab characters.")
1546 (defvar ps-line-height nil
1547 "The height of a line, for generating Postscript.
1548 This is the value that ps-print uses to determine the height,
1549 y-dimension, of the lines of text it has printed, and thus affects the
1550 point at which page-breaks are placed.
1551 The line-height is *not* the same as the point size of the font.")
1553 (defvar ps-print-prologue-1
1554 "% ISOLatin1Encoding stolen from ps_init.ps in GhostScript 2.6.1.4:
1555 /ISOLatin1Encoding where { pop } {
1556 % -- The ISO Latin-1 encoding vector isn't known, so define it.
1557 % -- The first half is the same as the standard encoding,
1558 % -- except for minus instead of hyphen at code 055.
1559 /ISOLatin1Encoding
1560 StandardEncoding 0 45 getinterval aload pop
1561 /minus
1562 StandardEncoding 46 82 getinterval aload pop
1563 %*** NOTE: the following are missing in the Adobe documentation,
1564 %*** but appear in the displayed table:
1565 %*** macron at 0225, dieresis at 0230, cedilla at 0233, space at 0240.
1566 % 0200 (128)
1567 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
1568 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
1569 /dotlessi /grave /acute /circumflex /tilde /macron /breve /dotaccent
1570 /dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron
1571 % 0240 (160)
1572 /space /exclamdown /cent /sterling
1573 /currency /yen /brokenbar /section
1574 /dieresis /copyright /ordfeminine /guillemotleft
1575 /logicalnot /hyphen /registered /macron
1576 /degree /plusminus /twosuperior /threesuperior
1577 /acute /mu /paragraph /periodcentered
1578 /cedilla /onesuperior /ordmasculine /guillemotright
1579 /onequarter /onehalf /threequarters /questiondown
1580 % 0300 (192)
1581 /Agrave /Aacute /Acircumflex /Atilde
1582 /Adieresis /Aring /AE /Ccedilla
1583 /Egrave /Eacute /Ecircumflex /Edieresis
1584 /Igrave /Iacute /Icircumflex /Idieresis
1585 /Eth /Ntilde /Ograve /Oacute
1586 /Ocircumflex /Otilde /Odieresis /multiply
1587 /Oslash /Ugrave /Uacute /Ucircumflex
1588 /Udieresis /Yacute /Thorn /germandbls
1589 % 0340 (224)
1590 /agrave /aacute /acircumflex /atilde
1591 /adieresis /aring /ae /ccedilla
1592 /egrave /eacute /ecircumflex /edieresis
1593 /igrave /iacute /icircumflex /idieresis
1594 /eth /ntilde /ograve /oacute
1595 /ocircumflex /otilde /odieresis /divide
1596 /oslash /ugrave /uacute /ucircumflex
1597 /udieresis /yacute /thorn /ydieresis
1598 256 packedarray def
1599 } ifelse
1601 /reencodeFontISO { %def
1603 length 12 add dict % Make a new font (a new dict the same size
1604 % as the old one) with room for our new symbols.
1606 begin % Make the new font the current dictionary.
1609 { 1 index /FID ne
1610 { def } { pop pop } ifelse
1611 } forall % Copy each of the symbols from the old dictionary
1612 % to the new one except for the font ID.
1614 /Encoding ISOLatin1Encoding def % Override the encoding with
1615 % the ISOLatin1 encoding.
1617 % Use the font's bounding box to determine the ascent, descent,
1618 % and overall height; don't forget that these values have to be
1619 % transformed using the font's matrix.
1621 % ^ (x2 y2)
1622 % | |
1623 % | v
1624 % | +----+ - -
1625 % | | | ^
1626 % | | | | Ascent (usually > 0)
1627 % | | | |
1628 % (0 0) -> +--+----+-------->
1629 % | | |
1630 % | | v Descent (usually < 0)
1631 % (x1 y1) --> +----+ - -
1633 FontBBox % -- x1 y1 x2 y2
1634 FontMatrix transform /Ascent exch def pop
1635 FontMatrix transform /Descent exch def pop
1636 /FontHeight Ascent Descent sub def % use `sub' because descent < 0
1638 % Define these in case they're not in the FontInfo
1639 % (also, here they're easier to get to).
1640 /UnderlinePosition Descent 0.70 mul def
1641 /OverlinePosition Descent UnderlinePosition sub Ascent add def
1642 /StrikeoutPosition Ascent 0.30 mul def
1643 /LineThickness 0 50 FontMatrix transform exch pop def
1644 /Xshadow 0 80 FontMatrix transform exch pop def
1645 /Yshadow 0 -90 FontMatrix transform exch pop def
1646 /SpaceBackground Descent neg UnderlinePosition add def
1647 /XBox Descent neg def
1648 /YBox LineThickness 0.7 mul def
1650 currentdict % Leave the new font on the stack
1651 end % Stop using the font as the current dictionary.
1652 definefont % Put the font into the font dictionary
1653 pop % Discard the returned font.
1654 } bind def
1656 /DefFont { % Font definition
1657 findfont exch scalefont reencodeFontISO
1658 } def
1660 /F { % Font selection
1661 findfont
1662 dup /Ascent get /Ascent exch def
1663 dup /Descent get /Descent exch def
1664 dup /FontHeight get /FontHeight exch def
1665 dup /UnderlinePosition get /UnderlinePosition exch def
1666 dup /OverlinePosition get /OverlinePosition exch def
1667 dup /StrikeoutPosition get /StrikeoutPosition exch def
1668 dup /LineThickness get /LineThickness exch def
1669 dup /Xshadow get /Xshadow exch def
1670 dup /Yshadow get /Yshadow exch def
1671 dup /SpaceBackground get /SpaceBackground exch def
1672 dup /XBox get /XBox exch def
1673 dup /YBox get /YBox exch def
1674 setfont
1675 } def
1677 /FG /setrgbcolor load def
1679 /bg false def
1680 /BG {
1681 dup /bg exch def
1682 {mark 4 1 roll ]}
1683 {[ 1.0 1.0 1.0 ]}
1684 ifelse
1685 /bgcolor exch def
1686 } def
1688 % B width C
1689 % +-----------+
1690 % | Ascent (usually > 0)
1691 % A + +
1692 % | Descent (usually < 0)
1693 % +-----------+
1694 % E width D
1696 /dobackground { % width --
1697 currentpoint % -- width x y
1698 gsave
1699 newpath
1700 moveto % A (x y)
1701 0 Ascent rmoveto % B
1702 dup 0 rlineto % C
1703 0 Descent Ascent sub rlineto % D
1704 neg 0 rlineto % E
1705 closepath
1706 bgcolor aload pop setrgbcolor
1707 fill
1708 grestore
1709 } def
1711 /eolbg { % dobackground until right margin
1712 PrintWidth % -- x-eol
1713 currentpoint pop % -- cur-x
1714 sub % -- width until eol
1715 dobackground
1716 } def
1718 /PLN {PrintLineNumber {doLineNumber}if} def
1720 /SL { % Soft Linefeed
1721 bg { eolbg } if
1722 0 currentpoint exch pop LineHeight sub moveto
1723 } def
1725 /HL {SL PLN} def % Hard Linefeed
1727 % Some debug
1728 /dcp { currentpoint exch 40 string cvs print (, ) print = } def
1729 /dp { print 2 copy exch 40 string cvs print (, ) print = } def
1731 /W {
1732 ( ) stringwidth % Get the width of a space in the current font.
1733 pop % Discard the Y component.
1734 mul % Multiply the width of a space
1735 % by the number of spaces to plot
1736 bg { dup dobackground } if
1737 0 rmoveto
1738 } def
1740 /Effect 0 def
1741 /EF {/Effect exch def} def
1743 % stack: string |- --
1744 % effect: 1 - underline 2 - strikeout 4 - overline
1745 % 8 - shadow 16 - box 32 - outline
1746 /S {
1747 /xx currentpoint dup Descent add /yy exch def
1748 Ascent add /YY exch def def
1749 dup stringwidth pop xx add /XX exch def
1750 Effect 8 and 0 ne {
1751 /yy yy Yshadow add def
1752 /XX XX Xshadow add def
1753 } if
1754 bg {
1755 true
1756 Effect 16 and 0 ne
1757 {SpaceBackground doBox}
1758 {xx yy XX YY doRect}
1759 ifelse
1760 } if % background
1761 Effect 16 and 0 ne {false 0 doBox}if % box
1762 Effect 8 and 0 ne {dup doShadow}if % shadow
1763 Effect 32 and 0 ne
1764 {true doOutline} % outline
1765 {show} % normal text
1766 ifelse
1767 Effect 1 and 0 ne {UnderlinePosition Hline}if % underline
1768 Effect 2 and 0 ne {StrikeoutPosition Hline}if % strikeout
1769 Effect 4 and 0 ne {OverlinePosition Hline}if % overline
1770 } bind def
1772 % stack: position |- --
1773 /Hline {
1774 currentpoint exch pop add dup
1775 gsave
1776 newpath
1777 xx exch moveto
1778 XX exch lineto
1779 closepath
1780 LineThickness setlinewidth stroke
1781 grestore
1782 } bind def
1784 % stack: fill-or-not delta |- --
1785 /doBox {
1786 /dd exch def
1787 xx XBox sub dd sub yy YBox sub dd sub
1788 XX XBox add dd add YY YBox add dd add
1789 doRect
1790 } bind def
1792 % stack: fill-or-not lower-x lower-y upper-x upper-y |- --
1793 /doRect {
1794 /rYY exch def
1795 /rXX exch def
1796 /ryy exch def
1797 /rxx exch def
1798 gsave
1799 newpath
1800 rXX rYY moveto
1801 rxx rYY lineto
1802 rxx ryy lineto
1803 rXX ryy lineto
1804 closepath
1805 % top of stack: fill-or-not
1806 {FillBgColor}
1807 {LineThickness setlinewidth stroke}
1808 ifelse
1809 grestore
1810 } bind def
1812 % stack: string |- --
1813 /doShadow {
1814 gsave
1815 Xshadow Yshadow rmoveto
1816 false doOutline
1817 grestore
1818 } bind def
1820 /st 1 string def
1822 % stack: string fill-or-not |- --
1823 /doOutline {
1824 /-fillp- exch def
1825 /-ox- currentpoint /-oy- exch def def
1826 gsave
1827 LineThickness setlinewidth
1829 st 0 3 -1 roll put
1830 st dup true charpath
1831 -fillp- {gsave FillBgColor grestore}if
1832 stroke stringwidth
1833 -oy- add /-oy- exch def
1834 -ox- add /-ox- exch def
1835 -ox- -oy- moveto
1836 } forall
1837 grestore
1838 -ox- -oy- moveto
1839 } bind def
1841 % stack: --
1842 /FillBgColor {bgcolor aload pop setrgbcolor fill} bind def
1844 /L0 6 /Times-Italic DefFont
1846 % stack: --
1847 /doLineNumber {
1848 currentfont
1849 gsave
1850 0.0 0.0 0.0 setrgbcolor
1851 /L0 findfont setfont
1852 LineNumber Lines ge
1853 {(end )}
1854 {LineNumber 6 string cvs ( ) strcat}
1855 ifelse
1856 dup stringwidth pop neg 0 rmoveto
1857 show
1858 grestore
1859 setfont
1860 /LineNumber LineNumber 1 add def
1861 } def
1863 % stack: --
1864 /printZebra {
1865 gsave
1866 0.985 setgray
1867 /double-zebra NumberOfZebra NumberOfZebra add def
1868 /yiter double-zebra LineHeight mul neg def
1869 /xiter PrintWidth InterColumn add def
1870 NumberOfColumns {LinesPerColumn doColumnZebra xiter 0 rmoveto}repeat
1871 grestore
1872 } def
1874 % stack: lines-per-column |- --
1875 /doColumnZebra {
1876 gsave
1877 dup double-zebra idiv {NumberOfZebra doZebra 0 yiter rmoveto}repeat
1878 double-zebra mod
1879 dup 0 le {pop}{dup NumberOfZebra gt {pop NumberOfZebra}if doZebra}ifelse
1880 grestore
1881 } def
1883 % stack: zebra-height (in lines) |- --
1884 /doZebra {
1885 /zh exch 0.05 sub LineHeight mul def
1886 gsave
1887 0 LineHeight 0.65 mul rmoveto
1888 PrintWidth 0 rlineto
1889 0 zh neg rlineto
1890 PrintWidth neg 0 rlineto
1891 0 zh rlineto
1892 fill
1893 grestore
1894 } def
1896 % tx ty rotation xscale yscale xpos ypos BeginBackImage
1897 /BeginBackImage {
1898 /-save-image- save def
1899 /showpage {}def
1900 translate
1901 scale
1902 rotate
1903 translate
1904 } def
1906 /EndBackImage {
1907 -save-image- restore
1908 } def
1910 % string fontsize fontname rotation gray xpos ypos ShowBackText
1911 /ShowBackText {
1912 gsave
1913 translate
1914 setgray
1915 rotate
1916 findfont exch dup /-offset- exch -0.25 mul def scalefont setfont
1917 0 -offset- moveto
1918 /-saveLineThickness- LineThickness def
1919 /LineThickness 1 def
1920 false doOutline
1921 /LineThickness -saveLineThickness- def
1922 grestore
1923 } def
1925 /BeginDoc {
1926 % ---- save the state of the document (useful for ghostscript!)
1927 /docState save def
1928 % ---- [jack] Kludge: my ghostscript window is 21x27.7 instead of 21x29.7
1929 /JackGhostscript where {
1930 pop 1 27.7 29.7 div scale
1931 } if
1932 LandscapeMode {
1933 % ---- translate to bottom-right corner of Portrait page
1934 LandscapePageHeight 0 translate
1935 90 rotate
1936 } if
1937 /ColumnWidth PrintWidth InterColumn add def
1938 % ---- translate to lower left corner of TEXT
1939 LeftMargin BottomMargin translate
1940 % ---- define where printing will start
1941 /f0 F % this installs Ascent
1942 /PrintStartY PrintHeight Ascent sub def
1943 /ColumnIndex 1 def
1944 } def
1946 /EndDoc {
1947 % ---- on last page but not last column, spit out the page
1948 ColumnIndex 1 eq not { showpage } if
1949 % ---- restore the state of the document (useful for ghostscript!)
1950 docState restore
1951 } def
1953 /BeginDSCPage {
1954 % ---- when 1st column, save the state of the page
1955 ColumnIndex 1 eq { /pageState save def } if
1956 % ---- save the state of the column
1957 /columnState save def
1958 } def
1960 /BeginPage {
1961 % ---- when 1st column, print all background effects
1962 ColumnIndex 1 eq {
1963 0 PrintStartY moveto % move to where printing will start
1964 Zebra {printZebra}if
1965 printGlobalBackground
1966 printLocalBackground
1967 } if
1968 PrintHeader {
1969 PrintHeaderFrame { HeaderFrame } if
1970 HeaderText
1971 } if
1972 0 PrintStartY moveto % move to where printing will start
1974 } def
1976 /EndPage {
1977 bg { eolbg } if
1978 } def
1980 /EndDSCPage {
1981 ColumnIndex NumberOfColumns eq {
1982 % ---- on last column, spit out the page
1983 showpage
1984 % ---- restore the state of the page
1985 pageState restore
1986 /ColumnIndex 1 def
1987 } { % else
1988 % ---- restore the state of the current column
1989 columnState restore
1990 % ---- and translate to the next column
1991 ColumnWidth 0 translate
1992 /ColumnIndex ColumnIndex 1 add def
1993 } ifelse
1994 } def
1996 /SetHeaderLines { % nb-lines --
1997 /HeaderLines exch def
1998 % ---- bottom up
1999 HeaderPad
2000 HeaderLines 1 sub HeaderLineHeight mul add
2001 HeaderTitleLineHeight add
2002 HeaderPad add
2003 /HeaderHeight exch def
2004 } def
2006 % |---------|
2007 % | tm |
2008 % |---------|
2009 % | header |
2010 % |-+-------| <-- (x y)
2011 % | ho |
2012 % |---------|
2013 % | text |
2014 % |-+-------| <-- (0 0)
2015 % | bm |
2016 % |---------|
2018 /HeaderFrameStart { % -- x y
2019 0 PrintHeight HeaderOffset add
2020 } def
2022 /HeaderFramePath {
2023 PrintWidth 0 rlineto
2024 0 HeaderHeight rlineto
2025 PrintWidth neg 0 rlineto
2026 0 HeaderHeight neg rlineto
2027 } def
2029 /HeaderFrame {
2030 gsave
2031 0.4 setlinewidth
2032 % ---- fill a black rectangle (the shadow of the next one)
2033 HeaderFrameStart moveto
2034 1 -1 rmoveto
2035 HeaderFramePath
2036 0 setgray fill
2037 % ---- do the next rectangle ...
2038 HeaderFrameStart moveto
2039 HeaderFramePath
2040 gsave 0.9 setgray fill grestore % filled with grey
2041 gsave 0 setgray stroke grestore % drawn with black
2042 grestore
2043 } def
2045 /HeaderStart {
2046 HeaderFrameStart
2047 exch HeaderPad add exch % horizontal pad
2048 % ---- bottom up
2049 HeaderPad add % vertical pad
2050 HeaderDescent sub
2051 HeaderLineHeight HeaderLines 1 sub mul add
2052 } def
2054 /strcat {
2055 dup length 3 -1 roll dup length dup 4 -1 roll add string dup
2056 0 5 -1 roll putinterval
2057 dup 4 2 roll exch putinterval
2058 } def
2060 /pagenumberstring {
2061 PageNumber 32 string cvs
2062 ShowNofN {
2063 (/) strcat
2064 PageCount 32 string cvs strcat
2065 } if
2066 } def
2068 /HeaderText {
2069 HeaderStart moveto
2071 HeaderLinesRight HeaderLinesLeft % -- rightLines leftLines
2073 % ---- hack: `PN 1 and' == `PN 2 modulo'
2075 % ---- if duplex and even page number, then exchange left and right
2076 Duplex PageNumber 1 and 0 eq and { exch } if
2078 { % ---- process the left lines
2079 aload pop
2080 exch F
2081 gsave
2082 dup xcheck { exec } if
2083 show
2084 grestore
2085 0 HeaderLineHeight neg rmoveto
2086 } forall
2088 HeaderStart moveto
2090 { % ---- process the right lines
2091 aload pop
2092 exch F
2093 gsave
2094 dup xcheck { exec } if
2095 dup stringwidth pop
2096 PrintWidth exch sub HeaderPad 2 mul sub 0 rmoveto
2097 show
2098 grestore
2099 0 HeaderLineHeight neg rmoveto
2100 } forall
2101 } def
2103 /ReportFontInfo {
2104 2 copy
2105 /t0 3 1 roll DefFont
2106 /t0 F
2107 /lh FontHeight def
2108 /sw ( ) stringwidth pop def
2109 /aw (01234567890abcdefghijklmnopqrstuvwxyz) dup length exch
2110 stringwidth pop exch div def
2111 /t1 12 /Helvetica-Oblique DefFont
2112 /t1 F
2113 gsave
2114 (For ) show
2115 128 string cvs show
2116 ( ) show
2117 32 string cvs show
2118 ( point, the line height is ) show
2119 lh 32 string cvs show
2120 (, the space width is ) show
2121 sw 32 string cvs show
2122 (,) show
2123 grestore
2124 0 FontHeight neg rmoveto
2125 gsave
2126 (and a crude estimate of average character width is ) show
2127 aw 32 string cvs show
2128 (.) show
2129 grestore
2130 0 FontHeight neg rmoveto
2131 } def
2133 /cm { % cm to point
2134 72 mul 2.54 div
2135 } def
2137 /ReportAllFontInfo {
2138 FontDirectory
2139 { % key = font name value = font dictionary
2140 pop 10 exch ReportFontInfo
2141 } forall
2142 } def
2144 % 3 cm 20 cm moveto 10 /Courier ReportFontInfo showpage
2145 % 3 cm 20 cm moveto ReportAllFontInfo showpage
2149 (defvar ps-print-prologue-2
2151 % ---- These lines must be kept together because...
2153 /h0 F
2154 /HeaderTitleLineHeight FontHeight def
2156 /h1 F
2157 /HeaderLineHeight FontHeight def
2158 /HeaderDescent Descent def
2160 % ---- ...because `F' has a side-effect on `FontHeight' and `Descent'
2164 ;; Start Editing Here:
2166 (defvar ps-source-buffer nil)
2167 (defvar ps-spool-buffer-name "*PostScript*")
2168 (defvar ps-spool-buffer nil)
2170 (defvar ps-output-head nil)
2171 (defvar ps-output-tail nil)
2173 (defvar ps-page-count 0)
2174 (defvar ps-showline-count 1)
2176 (defvar ps-background-pages nil)
2177 (defvar ps-background-all-pages nil)
2178 (defvar ps-background-text-count 0)
2179 (defvar ps-background-image-count 0)
2181 (defvar ps-current-font 0)
2182 (defvar ps-default-color (if ps-print-color-p ps-default-fg)) ; black
2183 (defvar ps-current-color ps-default-color)
2184 (defvar ps-current-bg nil)
2186 (defvar ps-razchunk 0)
2188 (defvar ps-color-format
2189 (if (eq ps-print-emacs-type 'emacs)
2191 ;;Emacs understands the %f format; we'll
2192 ;;use it to limit color RGB values to
2193 ;;three decimals to cut down some on the
2194 ;;size of the PostScript output.
2195 "%0.3f %0.3f %0.3f"
2197 ;; Lucid emacsen will have to make do with
2198 ;; %s (princ) for floats.
2199 "%s %s %s"))
2201 ;; These values determine how much print-height to deduct when headers
2202 ;; are turned on. This is a pretty clumsy way of handling it, but
2203 ;; it'll do for now.
2205 (defvar ps-header-font nil)
2206 (defvar ps-header-title-font nil)
2208 (defvar ps-header-line-height nil)
2209 (defvar ps-header-title-line-height nil)
2210 (defvar ps-header-pad 0
2211 "Vertical and horizontal space in points (1/72 inch) between the header frame
2212 and the text it contains.")
2214 ;; Define accessors to the dimensions list.
2216 (defmacro ps-page-dimensions-get-width (dims) `(nth 0 ,dims))
2217 (defmacro ps-page-dimensions-get-height (dims) `(nth 1 ,dims))
2219 (defvar ps-landscape-page-height nil)
2221 (defvar ps-print-width nil)
2222 (defvar ps-print-height nil)
2224 (defvar ps-height-remaining)
2225 (defvar ps-width-remaining)
2227 (defvar ps-print-color-scale nil)
2230 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2231 ;; Internal Variables
2234 (defvar ps-print-face-extension-alist nil
2235 "Alist of symbolic faces *WITH* extension features (box, outline, etc).
2236 An element of this list has the following form:
2238 (FACE . [BITS FG BG])
2240 FACE is a symbol denoting a face name
2241 BITS is a bit vector, where each bit correspond
2242 to a feature (bold, underline, etc)
2243 (see documentation for `ps-print-face-map-alist')
2244 FG foreground color (string or nil)
2245 BG background color (string or nil)
2247 Don't change this list directly; instead,
2248 use `ps-extend-face' and `ps-extend-face-list'.
2249 See documentation for `ps-extend-face' for valid extension symbol.")
2252 (defvar ps-print-face-alist nil
2253 "Alist of symbolic faces *WITHOUT* extension features (box, outline, etc).
2255 An element of this list has the same form as an element of
2256 `ps-print-face-extension-alist'.
2258 Don't change this list directly; this list is used by `ps-face-attributes',
2259 `ps-map-face' and `ps-build-reference-face-lists'.")
2262 (defconst ps-print-face-map-alist
2263 '((bold . 1)
2264 (italic . 2)
2265 (underline . 4)
2266 (strikeout . 8)
2267 (overline . 16)
2268 (shadow . 32)
2269 (box . 64)
2270 (outline . 128))
2271 "Alist of all features and the corresponding bit mask.
2272 Each symbol correspond to one bit in a bit vector.")
2275 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2276 ;; Remapping Faces
2279 ;;;###autoload
2280 (defun ps-extend-face-list (face-extension-list &optional merge-p)
2281 "Extend face in `ps-print-face-extension-alist'.
2283 If optional MERGE-P is non-nil, extensions in FACE-EXTENSION-LIST are merged
2284 with face extension in `ps-print-face-extension-alist'; otherwise, overrides.
2286 The elements in FACE-EXTENSION-LIST is like those for `ps-extend-face'.
2288 See `ps-extend-face' for documentation."
2289 (while face-extension-list
2290 (ps-extend-face (car face-extension-list) merge-p)
2291 (setq face-extension-list (cdr face-extension-list))))
2294 ;;;###autoload
2295 (defun ps-extend-face (face-extension &optional merge-p)
2296 "Extend face in `ps-print-face-extension-alist'.
2298 If optional MERGE-P is non-nil, extensions in FACE-EXTENSION-LIST are merged
2299 with face extensions in `ps-print-face-extension-alist'; otherwise, overrides.
2301 The elements of FACE-EXTENSION list have the form:
2303 (FACE-NAME FOREGROUND BACKGROUND EXTENSION...)
2305 FACE-NAME is a face name symbol.
2307 FOREGROUND and BACKGROUND may be nil or a string that denotes the
2308 foreground and background colors respectively.
2310 EXTENSION is one of the following symbols:
2311 bold - use bold font.
2312 italic - use italic font.
2313 underline - put a line under text.
2314 strikeout - like underline, but the line is in middle of text.
2315 overline - like underline, but the line is over the text.
2316 shadow - text will have a shadow.
2317 box - text will be surrounded by a box.
2318 outline - print characters as hollow outlines.
2320 If EXTENSION is any other symbol, it is ignored."
2321 (let* ((face-name (nth 0 face-extension))
2322 (foreground (nth 1 face-extension))
2323 (background (nth 2 face-extension))
2324 (ps-face (cdr (assq face-name ps-print-face-extension-alist)))
2325 (face-vector (or ps-face (vector 0 nil nil)))
2326 (face-bit (ps-extension-bit face-extension)))
2327 ;; extend face
2328 (aset face-vector 0 (if merge-p
2329 (logior (aref face-vector 0) face-bit)
2330 face-bit))
2331 (and foreground (stringp foreground) (aset face-vector 1 foreground))
2332 (and background (stringp background) (aset face-vector 2 background))
2333 ;; if face does not exist, insert it
2334 (or ps-face
2335 (setq ps-print-face-extension-alist
2336 (cons (cons face-name face-vector)
2337 ps-print-face-extension-alist)))))
2340 (defun ps-extension-bit (face-extension)
2341 (let ((face-bit 0))
2342 ;; map valid symbol extension to bit vector
2343 (setq face-extension (cdr (cdr face-extension)))
2344 (while (setq face-extension (cdr face-extension))
2345 (setq face-bit (logior face-bit
2346 (or (cdr (assq (car face-extension)
2347 ps-print-face-map-alist))
2348 0))))
2349 face-bit))
2352 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2353 ;; Internal functions and variables
2356 (defun ps-print-without-faces (from to &optional filename region-p)
2357 (ps-printing-region region-p)
2358 (ps-generate (current-buffer) from to 'ps-generate-postscript)
2359 (ps-do-despool filename))
2362 (defun ps-spool-without-faces (from to &optional region-p)
2363 (ps-printing-region region-p)
2364 (ps-generate (current-buffer) from to 'ps-generate-postscript))
2367 (defun ps-print-with-faces (from to &optional filename region-p)
2368 (ps-printing-region region-p)
2369 (ps-generate (current-buffer) from to 'ps-generate-postscript-with-faces)
2370 (ps-do-despool filename))
2373 (defun ps-spool-with-faces (from to &optional region-p)
2374 (ps-printing-region region-p)
2375 (ps-generate (current-buffer) from to 'ps-generate-postscript-with-faces))
2378 (defsubst ps-count-lines (from to)
2379 (+ (count-lines from to)
2380 (save-excursion (goto-char to)
2381 (if (= (current-column) 0) 1 0))))
2384 (defvar ps-printing-region nil
2385 "Variable used to indicate if it is printing a region.
2386 If non-nil, it is a cons, the car of which is the line number
2387 where the region begins, and its cdr is the total number of lines
2388 in the buffer. Formatting functions can use this information
2389 to print the original line number (and not the number of lines printed),
2390 and to indicate in the header that the printout is of a partial file.")
2393 (defun ps-printing-region (region-p)
2394 (setq ps-printing-region
2395 (and region-p
2396 (cons (ps-count-lines (point-min) (region-beginning))
2397 (ps-count-lines (point-min) (point-max))))))
2400 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2401 ;; Internal functions
2403 (defun ps-line-lengths-internal ()
2404 "Display the correspondence between a line length and a font size,
2405 using the current ps-print setup.
2406 Try: pr -t file | awk '{printf \"%3d %s\n\", length($0), $0}' | sort -r | head"
2407 (let ((buf (get-buffer-create "*Line-lengths*"))
2408 (ifs ps-font-size) ; initial font size
2409 (icw ps-avg-char-width) ; initial character width
2410 (print-width (progn (ps-get-page-dimensions)
2411 ps-print-width))
2412 (ps-setup (ps-setup)) ; setup for the current buffer
2413 (fs-min 5) ; minimum font size
2414 cw-min ; minimum character width
2415 nb-cpl-max ; maximum nb of characters per line
2416 (fs-max 14) ; maximum font size
2417 cw-max ; maximum character width
2418 nb-cpl-min ; minimum nb of characters per line
2419 fs ; current font size
2420 cw ; current character width
2421 nb-cpl ; current nb of characters per line
2423 (setq cw-min (/ (* icw fs-min) ifs)
2424 nb-cpl-max (floor (/ print-width cw-min))
2425 cw-max (/ (* icw fs-max) ifs)
2426 nb-cpl-min (floor (/ print-width cw-max)))
2427 (setq nb-cpl nb-cpl-min)
2428 (set-buffer buf)
2429 (goto-char (point-max))
2430 (if (not (bolp)) (insert "\n"))
2431 (insert ps-setup)
2432 (insert "nb char per line / font size\n")
2433 (while (<= nb-cpl nb-cpl-max)
2434 (setq cw (/ print-width (float nb-cpl))
2435 fs (/ (* ifs cw) icw))
2436 (insert (format "%3s %s\n" nb-cpl fs))
2437 (setq nb-cpl (1+ nb-cpl)))
2438 (insert "\n")
2439 (display-buffer buf 'not-this-window)))
2441 (defun ps-nb-pages (nb-lines)
2442 "Display an approximate correspondence between a font size and the number
2443 of pages the number of lines would require to print
2444 using the current ps-print setup."
2445 (let ((buf (get-buffer-create "*Nb-Pages*"))
2446 (ifs ps-font-size) ; initial font size
2447 (ilh ps-line-height) ; initial line height
2448 (page-height (progn (ps-get-page-dimensions)
2449 ps-print-height))
2450 (ps-setup (ps-setup)) ; setup for the current buffer
2451 (fs-min 4) ; minimum font size
2452 lh-min ; minimum line height
2453 nb-lpp-max ; maximum nb of lines per page
2454 nb-page-min ; minimum nb of pages
2455 (fs-max 14) ; maximum font size
2456 lh-max ; maximum line height
2457 nb-lpp-min ; minimum nb of lines per page
2458 nb-page-max ; maximum nb of pages
2459 fs ; current font size
2460 lh ; current line height
2461 nb-lpp ; current nb of lines per page
2462 nb-page ; current nb of pages
2464 (setq lh-min (/ (* ilh fs-min) ifs)
2465 nb-lpp-max (floor (/ page-height lh-min))
2466 nb-page-min (ceiling (/ (float nb-lines) nb-lpp-max))
2467 lh-max (/ (* ilh fs-max) ifs)
2468 nb-lpp-min (floor (/ page-height lh-max))
2469 nb-page-max (ceiling (/ (float nb-lines) nb-lpp-min)))
2470 (setq nb-page nb-page-min)
2471 (set-buffer buf)
2472 (goto-char (point-max))
2473 (if (not (bolp)) (insert "\n"))
2474 (insert ps-setup)
2475 (insert (format "%d lines\n" nb-lines))
2476 (insert "nb page / font size\n")
2477 (while (<= nb-page nb-page-max)
2478 (setq nb-lpp (ceiling (/ nb-lines (float nb-page)))
2479 lh (/ page-height nb-lpp)
2480 fs (/ (* ifs lh) ilh))
2481 (insert (format "%s %s\n" nb-page fs))
2482 (setq nb-page (1+ nb-page)))
2483 (insert "\n")
2484 (display-buffer buf 'not-this-window)))
2486 (defun ps-select-font ()
2487 "Choose the font name and size (scaling data)."
2488 (let ((assoc (assq ps-font-family ps-font-info-database))
2489 l fn fb fi bi sz lh sw aw)
2490 (if (null assoc)
2491 (error "Don't have data to scale font %s. Known fonts families are %s"
2492 ps-font-family
2493 (mapcar 'car ps-font-info-database)))
2494 (setq l (cdr assoc)
2495 fn (prog1 (car l) (setq l (cdr l))) ; need `pop'
2496 fb (prog1 (car l) (setq l (cdr l)))
2497 fi (prog1 (car l) (setq l (cdr l)))
2498 bi (prog1 (car l) (setq l (cdr l)))
2499 sz (prog1 (car l) (setq l (cdr l)))
2500 lh (prog1 (car l) (setq l (cdr l)))
2501 sw (prog1 (car l) (setq l (cdr l)))
2502 aw (prog1 (car l) (setq l (cdr l))))
2504 (setq ps-font fn)
2505 (setq ps-font-bold fb)
2506 (setq ps-font-italic fi)
2507 (setq ps-font-bold-italic bi)
2508 ;; These data just need to be rescaled:
2509 (setq ps-line-height (/ (* lh ps-font-size) sz))
2510 (setq ps-space-width (/ (* sw ps-font-size) sz))
2511 (setq ps-avg-char-width (/ (* aw ps-font-size) sz))
2512 ps-font-family))
2514 (defun ps-select-header-font ()
2515 "Choose the font name and size (scaling data) for the header."
2516 (let ((assoc (assq ps-header-font-family ps-font-info-database))
2517 l fn fb fi bi sz lh sw aw)
2518 (if (null assoc)
2519 (error "Don't have data to scale font %s. Known fonts families are %s"
2520 ps-font-family
2521 (mapcar 'car ps-font-info-database)))
2522 (setq l (cdr assoc)
2523 fn (prog1 (car l) (setq l (cdr l))) ; need `pop'
2524 fb (prog1 (car l) (setq l (cdr l)))
2525 fi (prog1 (car l) (setq l (cdr l)))
2526 bi (prog1 (car l) (setq l (cdr l)))
2527 sz (prog1 (car l) (setq l (cdr l)))
2528 lh (prog1 (car l) (setq l (cdr l)))
2529 sw (prog1 (car l) (setq l (cdr l)))
2530 aw (prog1 (car l) (setq l (cdr l))))
2532 ;; Font name
2533 (setq ps-header-font fn)
2534 (setq ps-header-title-font fb)
2535 ;; Line height: These data just need to be rescaled:
2536 (setq ps-header-title-line-height (/ (* lh ps-header-title-font-size) sz))
2537 (setq ps-header-line-height (/ (* lh ps-header-font-size) sz))
2538 ps-header-font-family))
2540 (defun ps-get-page-dimensions ()
2541 (let ((page-dimensions (cdr (assq ps-paper-type ps-page-dimensions-database)))
2542 page-width page-height)
2543 (cond
2544 ((null page-dimensions)
2545 (error "`ps-paper-type' must be one of:\n%s"
2546 (mapcar 'car ps-page-dimensions-database)))
2547 ((< ps-number-of-columns 1)
2548 (error "The number of columns %d should not be negative" ps-number-of-columns)))
2550 (ps-select-font)
2551 (ps-select-header-font)
2553 (setq page-width (ps-page-dimensions-get-width page-dimensions)
2554 page-height (ps-page-dimensions-get-height page-dimensions))
2556 ;; Landscape mode
2557 (if ps-landscape-mode
2558 ;; exchange width and height
2559 (setq page-width (prog1 page-height (setq page-height page-width))))
2561 ;; It is used to get the lower right corner (only in landscape mode)
2562 (setq ps-landscape-page-height page-height)
2564 ;; | lm | text | ic | text | ic | text | rm |
2565 ;; page-width == lm + n * pw + (n - 1) * ic + rm
2566 ;; => pw == (page-width - lm -rm - (n - 1) * ic) / n
2567 (setq ps-print-width
2568 (/ (- page-width
2569 ps-left-margin ps-right-margin
2570 (* (1- ps-number-of-columns) ps-inter-column))
2571 ps-number-of-columns))
2572 (if (<= ps-print-width 0)
2573 (error "Bad horizontal layout:
2574 page-width == %s
2575 ps-left-margin == %s
2576 ps-right-margin == %s
2577 ps-inter-column == %s
2578 ps-number-of-columns == %s
2579 | lm | text | ic | text | ic | text | rm |
2580 page-width == lm + n * print-width + (n - 1) * ic + rm
2581 => print-width == %d !"
2582 page-width
2583 ps-left-margin
2584 ps-right-margin
2585 ps-inter-column
2586 ps-number-of-columns
2587 ps-print-width))
2589 (setq ps-print-height
2590 (- page-height ps-bottom-margin ps-top-margin))
2591 (if (<= ps-print-height 0)
2592 (error "Bad vertical layout:
2593 ps-top-margin == %s
2594 ps-bottom-margin == %s
2595 page-height == bm + print-height + tm
2596 => print-height == %d !"
2597 ps-top-margin
2598 ps-bottom-margin
2599 ps-print-height))
2600 ;; If headers are turned on, deduct the height of the header from
2601 ;; the print height.
2602 (cond
2603 (ps-print-header
2604 (setq ps-header-pad
2605 (* ps-header-line-pad ps-header-title-line-height))
2606 (setq ps-print-height
2607 (- ps-print-height
2608 ps-header-offset
2609 ps-header-pad
2610 ps-header-title-line-height
2611 (* ps-header-line-height (- ps-header-lines 1))
2612 ps-header-pad))))
2613 (if (<= ps-print-height 0)
2614 (error "Bad vertical layout:
2615 ps-top-margin == %s
2616 ps-bottom-margin == %s
2617 ps-header-offset == %s
2618 ps-header-pad == %s
2619 header-height == %s
2620 page-height == bm + print-height + tm - ho - hh
2621 => print-height == %d !"
2622 ps-top-margin
2623 ps-bottom-margin
2624 ps-header-offset
2625 ps-header-pad
2626 (+ ps-header-pad
2627 ps-header-title-line-height
2628 (* ps-header-line-height (- ps-header-lines 1))
2629 ps-header-pad)
2630 ps-print-height))))
2632 (defun ps-print-preprint (&optional filename)
2633 (if (and filename
2634 (or (numberp filename)
2635 (listp filename)))
2636 (let* ((name (concat (buffer-name) ".ps"))
2637 (prompt (format "Save PostScript to file: (default %s) "
2638 name))
2639 (res (read-file-name prompt default-directory name nil)))
2640 (if (file-directory-p res)
2641 (expand-file-name name (file-name-as-directory res))
2642 res))))
2644 ;; The following functions implement a simple list-buffering scheme so
2645 ;; that ps-print doesn't have to repeatedly switch between buffers
2646 ;; while spooling. The functions ps-output and ps-output-string build
2647 ;; up the lists; the function ps-flush-output takes the lists and
2648 ;; insert its contents into the spool buffer (*PostScript*).
2650 (defun ps-output-string-prim (string)
2651 (insert "(") ;insert start-string delimiter
2652 (save-excursion ;insert string
2653 (insert string))
2655 ;; Find and quote special characters as necessary for PS
2656 (while (re-search-forward "[()\\]" nil t)
2657 (save-excursion
2658 (forward-char -1)
2659 (insert "\\")))
2661 (goto-char (point-max))
2662 (insert ")")) ;insert end-string delimiter
2664 (defun ps-init-output-queue ()
2665 (setq ps-output-head (list ""))
2666 (setq ps-output-tail ps-output-head))
2668 (defun ps-output (&rest args)
2669 (setcdr ps-output-tail args)
2670 (while (cdr ps-output-tail)
2671 (setq ps-output-tail (cdr ps-output-tail))))
2673 (defun ps-output-string (string)
2674 (ps-output t string))
2676 (defun ps-output-list (the-list)
2677 (mapcar 'ps-output the-list))
2679 (defun ps-flush-output ()
2680 (save-excursion
2681 (set-buffer ps-spool-buffer)
2682 (goto-char (point-max))
2683 (while ps-output-head
2684 (let ((it (car ps-output-head)))
2685 (if (not (eq t it))
2686 (insert it)
2687 (setq ps-output-head (cdr ps-output-head))
2688 (ps-output-string-prim (car ps-output-head))))
2689 (setq ps-output-head (cdr ps-output-head))))
2690 (ps-init-output-queue))
2692 (defun ps-insert-file (fname)
2693 (ps-flush-output)
2694 ;; Check to see that the file exists and is readable; if not, throw
2695 ;; an error.
2696 (or (file-readable-p fname)
2697 (error "Could not read file `%s'" fname))
2698 (save-excursion
2699 (set-buffer ps-spool-buffer)
2700 (goto-char (point-max))
2701 (insert-file fname)))
2703 ;; These functions insert the arrays that define the contents of the
2704 ;; headers.
2706 (defun ps-generate-header-line (fonttag &optional content)
2707 (ps-output " [ " fonttag " ")
2708 (cond
2709 ;; Literal strings should be output as is -- the string must
2710 ;; contain its own PS string delimiters, '(' and ')', if necessary.
2711 ((stringp content)
2712 (ps-output content))
2714 ;; Functions are called -- they should return strings; they will be
2715 ;; inserted as strings and the PS string delimiters added.
2716 ((and (symbolp content) (fboundp content))
2717 (ps-output-string (funcall content)))
2719 ;; Variables will have their contents inserted. They should
2720 ;; contain strings, and will be inserted as strings.
2721 ((and (symbolp content) (boundp content))
2722 (ps-output-string (symbol-value content)))
2724 ;; Anything else will get turned into an empty string.
2726 (ps-output-string "")))
2727 (ps-output " ]\n"))
2729 (defun ps-generate-header (name contents)
2730 (ps-output "/" name " [\n")
2731 (if (> ps-header-lines 0)
2732 (let ((count 1))
2733 (ps-generate-header-line "/h0" (car contents))
2734 (while (and (< count ps-header-lines)
2735 (setq contents (cdr contents)))
2736 (ps-generate-header-line "/h1" (car contents))
2737 (setq count (+ count 1)))
2738 (ps-output "] def\n"))))
2740 (defun ps-output-boolean (name bool)
2741 (ps-output (format "/%s %s def\n" name (if bool "true" "false"))))
2744 (defun ps-background-pages (page-list func)
2745 (if page-list
2746 (mapcar
2747 '(lambda (pages)
2748 (let ((start (if (consp pages) (car pages) pages))
2749 (end (if (consp pages) (cdr pages) pages)))
2750 (and (integerp start) (integerp end) (<= start end)
2751 (add-to-list 'ps-background-pages (vector start end func)))))
2752 page-list)
2753 (setq ps-background-all-pages (cons func ps-background-all-pages))))
2756 (defun ps-get-boundingbox ()
2757 (save-excursion
2758 (set-buffer ps-spool-buffer)
2759 (save-excursion
2760 (if (re-search-forward
2761 "^%%BoundingBox:\\s-+\\([0-9.]+\\)\\s-+\\([0-9.]+\\)\\s-+\\([0-9.]+\\)\\s-+\\([0-9.]+\\)"
2762 nil t)
2763 (vector (string-to-number ; lower x
2764 (buffer-substring (match-beginning 1) (match-end 1)))
2765 (string-to-number ; lower y
2766 (buffer-substring (match-beginning 2) (match-end 2)))
2767 (string-to-number ; upper x
2768 (buffer-substring (match-beginning 3) (match-end 3)))
2769 (string-to-number ; upper y
2770 (buffer-substring (match-beginning 4) (match-end 4))))
2771 (vector 0 0 0 0)))))
2774 ;; Emacs understands the %f format; we'll use it to limit color RGB values
2775 ;; to three decimals to cut down some on the size of the PostScript output.
2776 ;; Lucid emacsen will have to make do with %s (princ) for floats.
2778 (defvar ps-float-format (if (eq ps-print-emacs-type 'emacs)
2779 "%0.3f " ; emacs
2780 "%s ")) ; Lucid emacsen
2783 (defun ps-float-format (value &optional default)
2784 (let ((literal (or value default)))
2785 (if literal
2786 (format (if (numberp literal)
2787 ps-float-format
2788 "%s ")
2789 literal)
2790 " ")))
2793 (defun ps-background-text ()
2794 (mapcar
2795 '(lambda (text)
2796 (setq ps-background-text-count (1+ ps-background-text-count))
2797 (ps-output (format "/ShowBackText-%d {\n" ps-background-text-count))
2798 (ps-output-string (nth 0 text)) ; text
2799 (ps-output
2800 "\n"
2801 (ps-float-format (nth 4 text) 200.0) ; font size
2802 (format "/%s " (or (nth 3 text) "Times-Roman")) ; font name
2803 (ps-float-format (nth 6 text)
2804 "PrintHeight PrintPageWidth atan") ; rotation
2805 (ps-float-format (nth 5 text) 0.85) ; gray
2806 (ps-float-format (nth 1 text) "0") ; x position
2807 (ps-float-format (nth 2 text) "BottomMargin") ; y position
2808 "\nShowBackText} def\n")
2809 (ps-background-pages (nthcdr 7 text) ; page list
2810 (format "ShowBackText-%d\n"
2811 ps-background-text-count)))
2812 ps-print-background-text))
2815 (defun ps-background-image ()
2816 (mapcar
2817 '(lambda (image)
2818 (let ((image-file (expand-file-name (nth 0 image))))
2819 (if (file-readable-p image-file)
2820 (progn
2821 (setq ps-background-image-count (1+ ps-background-image-count))
2822 (ps-output
2823 (format "/ShowBackImage-%d {\n--back-- " ps-background-image-count)
2824 (ps-float-format (nth 5 image) 0.0) ; rotation
2825 (ps-float-format (nth 3 image) 1.0) ; x scale
2826 (ps-float-format (nth 4 image) 1.0) ; y scale
2827 (ps-float-format (nth 1 image) ; x position
2828 "PrintPageWidth 2 div")
2829 (ps-float-format (nth 2 image) ; y position
2830 "PrintHeight 2 div BottomMargin add")
2831 "\nBeginBackImage\n")
2832 (ps-insert-file image-file)
2833 ;; coordinate adjustment to centralize image
2834 ;; around x and y position
2835 (let ((box (ps-get-boundingbox)))
2836 (save-excursion
2837 (set-buffer ps-spool-buffer)
2838 (save-excursion
2839 (if (re-search-backward "^--back--" nil t)
2840 (replace-match
2841 (format "%s %s"
2842 (ps-float-format
2843 (- (+ (/ (- (aref box 2) (aref box 0)) 2.0)
2844 (aref box 0))))
2845 (ps-float-format
2846 (- (+ (/ (- (aref box 3) (aref box 1)) 2.0)
2847 (aref box 1)))))
2848 t)))))
2849 (ps-output "\nEndBackImage} def\n")
2850 (ps-background-pages (nthcdr 6 image) ; page list
2851 (format "ShowBackImage-%d\n"
2852 ps-background-image-count))))))
2853 ps-print-background-image))
2856 (defun ps-background (page-number)
2857 (let (has-local-background)
2858 (mapcar '(lambda (range)
2859 (and (<= (aref range 0) page-number)
2860 (<= page-number (aref range 1))
2861 (if has-local-background
2862 (ps-output (aref range 2))
2863 (setq has-local-background t)
2864 (ps-output "/printLocalBackground {\n"
2865 (aref range 2)))))
2866 ps-background-pages)
2867 (and has-local-background (ps-output "} def\n"))))
2870 (defun ps-begin-file ()
2871 (ps-get-page-dimensions)
2872 (setq ps-showline-count (if ps-printing-region (car ps-printing-region) 1)
2873 ps-background-text-count 0
2874 ps-background-image-count 0
2875 ps-background-pages nil
2876 ps-background-all-pages nil)
2878 (ps-output ps-adobe-tag)
2879 (ps-output "%%Title: " (buffer-name)) ;Take job name from name of
2880 ;first buffer printed
2881 (ps-output "\n%%Creator: " (user-full-name))
2882 (ps-output "\n%%CreationDate: "
2883 (time-stamp-hh:mm:ss) " " (time-stamp-mon-dd-yyyy)
2884 "\n%%Orientation: "
2885 (if ps-landscape-mode "Landscape" "Portrait"))
2886 (ps-output "\n%% DocumentFonts: Times-Roman Times-Italic "
2887 ps-font " " ps-font-bold " " ps-font-italic " "
2888 ps-font-bold-italic " "
2889 ps-header-font " " ps-header-title-font)
2890 (ps-output "\n%%Pages: (atend)\n")
2891 (ps-output "%%EndComments\n\n")
2893 (ps-output-boolean "LandscapeMode" ps-landscape-mode)
2894 (ps-output (format "/NumberOfColumns %d def\n" ps-number-of-columns))
2896 (ps-output (format "/LandscapePageHeight %s def\n" ps-landscape-page-height))
2897 (ps-output (format "/PrintPageWidth %s def\n"
2898 (- (* (+ ps-print-width ps-inter-column)
2899 ps-number-of-columns)
2900 ps-inter-column)))
2901 (ps-output (format "/PrintWidth %s def\n" ps-print-width))
2902 (ps-output (format "/PrintHeight %s def\n" ps-print-height))
2904 (ps-output (format "/LeftMargin %s def\n" ps-left-margin))
2905 (ps-output (format "/RightMargin %s def\n" ps-right-margin)) ; not used
2906 (ps-output (format "/InterColumn %s def\n" ps-inter-column))
2908 (ps-output (format "/BottomMargin %s def\n" ps-bottom-margin))
2909 (ps-output (format "/TopMargin %s def\n" ps-top-margin)) ; not used
2910 (ps-output (format "/HeaderOffset %s def\n" ps-header-offset))
2911 (ps-output (format "/HeaderPad %s def\n" ps-header-pad))
2913 (ps-output-boolean "PrintHeader" ps-print-header)
2914 (ps-output-boolean "PrintHeaderFrame" ps-print-header-frame)
2915 (ps-output-boolean "ShowNofN" ps-show-n-of-n)
2916 (ps-output-boolean "Duplex" ps-spool-duplex)
2918 (ps-output (format "/LineHeight %s def\n" ps-line-height)
2919 (format "/LinesPerColumn %d def\n"
2920 (round (/ (+ ps-print-height
2921 (* ps-line-height 0.45))
2922 ps-line-height))))
2924 (ps-output-boolean "Zebra" ps-zebra-stripes)
2925 (ps-output (format "/NumberOfZebra %d def\n" ps-zebra-stripe-height))
2927 (ps-output-boolean "PrintLineNumber" ps-line-number)
2928 (ps-output (format "/Lines %d def\n"
2929 (if ps-printing-region
2930 (cdr ps-printing-region)
2931 (ps-count-lines (point-min) (point-max)))))
2933 (ps-background-text)
2934 (ps-background-image)
2935 (setq ps-background-all-pages (nreverse ps-background-all-pages)
2936 ps-background-pages (nreverse ps-background-pages))
2938 (ps-output ps-print-prologue-1)
2940 (ps-output "/printGlobalBackground {\n")
2941 (ps-output-list ps-background-all-pages)
2942 (ps-output "} def\n/printLocalBackground {\n} def\n")
2944 ;; Header fonts
2945 (ps-output ; /h0 14 /Helvetica-Bold Font
2946 (format "/h0 %s /%s DefFont\n" ps-header-title-font-size ps-header-title-font))
2947 (ps-output ; /h1 12 /Helvetica Font
2948 (format "/h1 %s /%s DefFont\n" ps-header-font-size ps-header-font))
2950 (ps-output ps-print-prologue-2)
2952 ;; Text fonts
2953 (ps-output (format "/f0 %s /%s DefFont\n" ps-font-size ps-font))
2954 (ps-output (format "/f1 %s /%s DefFont\n" ps-font-size ps-font-bold))
2955 (ps-output (format "/f2 %s /%s DefFont\n" ps-font-size ps-font-italic))
2956 (ps-output (format "/f3 %s /%s DefFont\n" ps-font-size ps-font-bold-italic))
2958 (ps-output "\nBeginDoc\n\n")
2959 (ps-output "%%EndPrologue\n"))
2961 (defun ps-header-dirpart ()
2962 (let ((fname (buffer-file-name)))
2963 (if fname
2964 (if (string-equal (buffer-name) (file-name-nondirectory fname))
2965 (file-name-directory fname)
2966 fname)
2967 "")))
2969 (defun ps-get-buffer-name ()
2970 (cond
2971 ;; Indulge Jim this little easter egg:
2972 ((string= (buffer-name) "ps-print.el")
2973 "Hey, Cool! It's ps-print.el!!!")
2974 ;; Indulge Jack this other little easter egg:
2975 ((string= (buffer-name) "sokoban.el")
2976 "Super! C'est sokoban.el!")
2977 (t (concat
2978 (and ps-printing-region "Subset of: ")
2979 (buffer-name)
2980 (and (buffer-modified-p) " (unsaved)")))))
2982 (defun ps-begin-job ()
2983 (setq ps-page-count 0))
2985 (defun ps-end-file ()
2986 (ps-output "\n%%Trailer\n")
2987 (ps-output (format "%%%%Pages: %d\n" (1+ (/ (1- ps-page-count)
2988 ps-number-of-columns))))
2989 (ps-output "\nEndDoc\n\n%%EOF\n"))
2992 (defun ps-next-page ()
2993 (ps-end-page)
2994 (ps-flush-output)
2995 (ps-begin-page))
2997 (defun ps-header-page (&optional inc-p)
2998 (if (zerop (mod ps-page-count ps-number-of-columns))
2999 ;; Print only when a new real page begins.
3000 (let ((page-number (1+ (/ ps-page-count ps-number-of-columns))))
3001 (ps-output (format "\n%%%%Page: %d %d\n" page-number page-number))
3002 (ps-output "BeginDSCPage\n")
3003 (ps-background page-number)
3004 (and inc-p (incf ps-page-count)))
3005 ;; Print when any other page begins.
3006 (ps-output "BeginDSCPage\n")))
3008 (defun ps-begin-page (&optional dummypage)
3009 (ps-get-page-dimensions)
3010 (setq ps-width-remaining ps-print-width)
3011 (setq ps-height-remaining ps-print-height)
3013 (ps-header-page)
3015 (ps-output (format "/LineNumber %d def\n" ps-showline-count)
3016 (format "/PageNumber %d def\n" (incf ps-page-count)))
3017 (ps-output "/PageCount 0 def\n")
3019 (when ps-print-header
3020 (ps-generate-header "HeaderLinesLeft" ps-left-header)
3021 (ps-generate-header "HeaderLinesRight" ps-right-header)
3022 (ps-output (format "%d SetHeaderLines\n" ps-header-lines)))
3024 (ps-output "BeginPage\n")
3025 (ps-set-font ps-current-font)
3026 (ps-set-bg ps-current-bg)
3027 (ps-set-color ps-current-color))
3029 (defun ps-end-page ()
3030 (ps-output "EndPage\nEndDSCPage\n"))
3032 (defun ps-dummy-page ()
3033 (ps-header-page t)
3034 (ps-output "/PrintHeader false def
3035 BeginPage
3036 EndPage
3037 EndDSCPage\n"))
3039 (defun ps-next-line ()
3040 (setq ps-showline-count (1+ ps-showline-count))
3041 (if (< ps-height-remaining ps-line-height)
3042 (ps-next-page)
3043 (setq ps-width-remaining ps-print-width)
3044 (setq ps-height-remaining (- ps-height-remaining ps-line-height))
3045 (ps-hard-lf)))
3047 (defun ps-continue-line ()
3048 (if (< ps-height-remaining ps-line-height)
3049 (ps-next-page)
3050 (setq ps-width-remaining ps-print-width)
3051 (setq ps-height-remaining (- ps-height-remaining ps-line-height))
3052 (ps-soft-lf)))
3054 ;; [jack] Why hard and soft ?
3056 (defun ps-hard-lf ()
3057 (ps-output "HL\n"))
3059 (defun ps-soft-lf ()
3060 (ps-output "SL\n"))
3062 (defun ps-find-wrappoint (from to char-width)
3063 (let ((avail (truncate (/ ps-width-remaining char-width)))
3064 (todo (- to from)))
3065 (if (< todo avail)
3066 (cons to (* todo char-width))
3067 (cons (+ from avail) ps-width-remaining))))
3069 (defun ps-basic-plot-string (from to &optional bg-color)
3070 (let* ((wrappoint (ps-find-wrappoint from to ps-avg-char-width))
3071 (to (car wrappoint))
3072 (string (buffer-substring-no-properties from to)))
3073 (ps-output-string string)
3074 (ps-output " S\n")
3075 wrappoint))
3077 (defun ps-basic-plot-whitespace (from to &optional bg-color)
3078 (let* ((wrappoint (ps-find-wrappoint from to ps-space-width))
3079 (to (car wrappoint)))
3080 (ps-output (format "%d W\n" (- to from)))
3081 wrappoint))
3083 (defun ps-plot (plotfunc from to &optional bg-color)
3084 (while (< from to)
3085 (let* ((wrappoint (funcall plotfunc from to bg-color))
3086 (plotted-to (car wrappoint))
3087 (plotted-width (cdr wrappoint)))
3088 (setq from plotted-to)
3089 (setq ps-width-remaining (- ps-width-remaining plotted-width))
3090 (if (< from to)
3091 (ps-continue-line))))
3092 (if ps-razzle-dazzle
3093 (let* ((q-todo (- (point-max) (point-min)))
3094 (q-done (- (point) (point-min)))
3095 (chunkfrac (/ q-todo 8))
3096 (chunksize (if (> chunkfrac 1000) 1000 chunkfrac)))
3097 (if (> (- q-done ps-razchunk) chunksize)
3098 (let (foo)
3099 (setq ps-razchunk q-done)
3100 (setq foo
3101 (if (< q-todo 100)
3102 (/ (* 100 q-done) q-todo)
3103 (/ q-done (/ q-todo 100))))
3104 (message "Formatting...%3d%%" foo))))))
3106 (defun ps-set-font (font)
3107 (setq ps-current-font font)
3108 (ps-output (format "/f%d F\n" ps-current-font)))
3110 (defun ps-set-bg (color)
3111 (if (setq ps-current-bg color)
3112 (ps-output (format ps-color-format (nth 0 color) (nth 1 color)
3113 (nth 2 color))
3114 " true BG\n")
3115 (ps-output "false BG\n")))
3117 (defun ps-set-color (color)
3118 (setq ps-current-color (or color ps-default-fg))
3119 (ps-output (format ps-color-format (nth 0 ps-current-color)
3120 (nth 1 ps-current-color) (nth 2 ps-current-color))
3121 " FG\n"))
3124 (defvar ps-current-effect 0)
3127 (defun ps-plot-region (from to font &optional fg-color bg-color effects)
3128 (if (not (equal font ps-current-font))
3129 (ps-set-font font))
3131 ;; Specify a foreground color only if one's specified and it's
3132 ;; different than the current.
3133 (if (not (equal fg-color ps-current-color))
3134 (ps-set-color fg-color))
3136 (if (not (equal bg-color ps-current-bg))
3137 (ps-set-bg bg-color))
3139 ;; Specify effects (underline, overline, box, etc)
3140 (cond
3141 ((not (integerp effects))
3142 (ps-output "0 EF\n")
3143 (setq ps-current-effect 0))
3144 ((/= effects ps-current-effect)
3145 (ps-output (number-to-string effects) " EF\n")
3146 (setq ps-current-effect effects)))
3148 ;; Starting at the beginning of the specified region...
3149 (save-excursion
3150 (goto-char from)
3152 ;; ...break the region up into chunks separated by tabs, linefeeds,
3153 ;; pagefeeds, control characters, and plot each chunk.
3154 (while (< from to)
3155 (if (re-search-forward "[\000-\037\177-\377]" to t)
3156 ;; region with some control characters
3157 (let ((match (char-after (match-beginning 0))))
3158 (if (= match ?\t) ; tab
3159 (let ((linestart
3160 (save-excursion (beginning-of-line) (point))))
3161 (ps-plot 'ps-basic-plot-string from (- (point) 1)
3162 bg-color)
3163 (forward-char -1)
3164 (setq from (+ linestart (current-column)))
3165 (if (re-search-forward "[ \t]+" to t)
3166 (ps-plot 'ps-basic-plot-whitespace
3167 from (+ linestart (current-column))
3168 bg-color)))
3169 ;; any other control character except tab
3170 (ps-plot 'ps-basic-plot-string from (- (point) 1) bg-color)
3171 (cond
3172 ((= match ?\n) ; newline
3173 (ps-next-line))
3175 ((= match ?\f) ; form feed
3176 (ps-next-page))
3178 ((<= match ?\037) ; characters from ^@ to ^_
3179 (ps-control-character (format "^%c" (+ match ?@))))
3181 ((= match ?\177) ; del (127) is printed ^?
3182 (ps-control-character "^?"))
3184 (t ; characters from 128 to 255
3185 (ps-control-character (format "\\%o" match)))))
3186 (setq from (point)))
3187 ;; region without control characters
3188 (ps-plot 'ps-basic-plot-string from to bg-color)
3189 (setq from to)))))
3191 (defun ps-control-character (str)
3192 (let* ((from (1- (point)))
3193 (len (length str))
3194 (to (+ from len))
3195 (wrappoint (ps-find-wrappoint from to ps-avg-char-width)))
3196 (if (< (car wrappoint) to)
3197 (ps-continue-line))
3198 (setq ps-width-remaining (- ps-width-remaining (* len ps-avg-char-width)))
3199 (ps-output-string str)
3200 (ps-output " S\n")))
3202 (defun ps-color-value (x-color-value)
3203 ;; Scale 16-bit X-COLOR-VALUE to PostScript color value in [0, 1] interval.
3204 (/ x-color-value ps-print-color-scale))
3206 (defun ps-color-values (x-color)
3207 (cond ((fboundp 'x-color-values)
3208 (x-color-values x-color))
3209 ((fboundp 'pixel-components)
3210 (pixel-components x-color))
3211 (t (error "No available function to determine X color values."))))
3214 (defun ps-face-attributes (face)
3215 "Return face attribute vector.
3217 If FACE is not in `ps-print-face-extension-alist' or in
3218 `ps-print-face-alist', insert it on `ps-print-face-alist' and
3219 return the attribute vector.
3221 If FACE is not a valid face name, it is used default face."
3222 (cdr (or (assq face ps-print-face-extension-alist)
3223 (assq face ps-print-face-alist)
3224 (let* ((the-face (if (facep face) face 'default))
3225 (new-face (ps-screen-to-bit-face the-face)))
3226 (or (and (eq the-face 'default)
3227 (assq the-face ps-print-face-alist))
3228 (setq ps-print-face-alist (cons new-face ps-print-face-alist)))
3229 new-face))))
3232 (defun ps-face-attribute-list (face-or-list)
3233 (if (listp face-or-list)
3234 ;; list of faces
3235 (let ((effects 0) foreground background face-attr face)
3236 (while face-or-list
3237 (setq face (car face-or-list)
3238 face-attr (ps-face-attributes face)
3239 effects (logior effects (aref face-attr 0)))
3240 (or foreground (setq foreground (aref face-attr 1)))
3241 (or background (setq background (aref face-attr 2)))
3242 (setq face-or-list (cdr face-or-list)))
3243 (vector effects foreground background))
3244 ;; simple face
3245 (ps-face-attributes face-or-list)))
3248 (defun ps-plot-with-face (from to face)
3249 (if face
3250 (let* ((face-bit (ps-face-attribute-list face))
3251 (effect (aref face-bit 0))
3252 (foreground (aref face-bit 1))
3253 (background (aref face-bit 2))
3254 (fg-color (if (and ps-print-color-p foreground)
3255 (mapcar 'ps-color-value
3256 (ps-color-values foreground))
3257 ps-default-color))
3258 (bg-color (if (and ps-print-color-p background)
3259 (mapcar 'ps-color-value
3260 (ps-color-values background)))))
3261 (ps-plot-region from to (logand effect 3)
3262 fg-color bg-color (lsh effect -2)))
3263 (ps-plot-region from to 0))
3264 (goto-char to))
3267 (defun ps-xemacs-face-kind-p (face kind kind-regex kind-list)
3268 (let* ((frame-font (or (face-font face) (face-font 'default)))
3269 (kind-cons (assq kind (x-font-properties frame-font)))
3270 (kind-spec (cdr-safe kind-cons))
3271 (case-fold-search t))
3273 (or (and kind-spec (string-match kind-regex kind-spec))
3274 ;; Kludge-compatible:
3275 (memq face kind-list))))
3277 (defun ps-face-bold-p (face)
3278 (if (eq ps-print-emacs-type 'emacs)
3279 (or (face-bold-p face)
3280 (memq face ps-bold-faces))
3281 (ps-xemacs-face-kind-p face 'WEIGHT_NAME "bold\\|demibold"
3282 ps-bold-faces)))
3284 (defun ps-face-italic-p (face)
3285 (if (eq ps-print-emacs-type 'emacs)
3286 (or (face-italic-p face)
3287 (memq face ps-italic-faces))
3289 (ps-xemacs-face-kind-p face 'ANGLE_NAME "i\\|o" ps-italic-faces)
3290 (ps-xemacs-face-kind-p face 'SLANT "i\\|o" ps-italic-faces))))
3292 (defun ps-face-underlined-p (face)
3293 (or (face-underline-p face)
3294 (memq face ps-underlined-faces)))
3297 ;; Ensure that face-list is fbound.
3298 (or (fboundp 'face-list) (defalias 'face-list 'list-faces))
3301 (defun ps-build-reference-face-lists ()
3302 (setq ps-print-face-alist nil)
3303 (if ps-auto-font-detect
3304 (mapcar 'ps-map-face (face-list))
3305 (mapcar 'ps-set-face-bold ps-bold-faces)
3306 (mapcar 'ps-set-face-italic ps-italic-faces)
3307 (mapcar 'ps-set-face-underline ps-underlined-faces))
3308 (setq ps-build-face-reference nil))
3311 (defun ps-set-face-bold (face)
3312 (ps-set-face-attribute face 1))
3314 (defun ps-set-face-italic (face)
3315 (ps-set-face-attribute face 2))
3317 (defun ps-set-face-underline (face)
3318 (ps-set-face-attribute face 4))
3321 (defun ps-set-face-attribute (face effect)
3322 (let ((face-bit (cdr (ps-map-face face))))
3323 (aset face-bit 0 (logior (aref face-bit 0) effect))))
3326 (defun ps-map-face (face)
3327 (let* ((face-map (ps-screen-to-bit-face face))
3328 (ps-face-bit (cdr (assq (car face-map) ps-print-face-alist))))
3329 (if ps-face-bit
3330 ;; if face exists, merge both
3331 (let ((face-bit (cdr face-map)))
3332 (aset ps-face-bit 0 (logior (aref ps-face-bit 0) (aref face-bit 0)))
3333 (or (aref ps-face-bit 1) (aset ps-face-bit 1 (aref face-bit 1)))
3334 (or (aref ps-face-bit 2) (aset ps-face-bit 2 (aref face-bit 2))))
3335 ;; if face does not exist, insert it
3336 (setq ps-print-face-alist (cons face-map ps-print-face-alist)))
3337 face-map))
3340 (defun ps-screen-to-bit-face (face)
3341 (cons face
3342 (vector (logior (if (ps-face-bold-p face) 1 0) ; bold
3343 (if (ps-face-italic-p face) 2 0) ; italic
3344 (if (ps-face-underlined-p face) 4 0)) ; underline
3345 (face-foreground face)
3346 (face-background face))))
3349 (defun ps-mapper (extent list)
3350 (nconc list (list (list (extent-start-position extent) 'push extent)
3351 (list (extent-end-position extent) 'pull extent)))
3352 nil)
3354 (defun ps-extent-sorter (a b)
3355 (< (extent-priority a) (extent-priority b)))
3357 (defun ps-print-ensure-fontified (start end)
3358 (if (and (boundp 'lazy-lock-mode) lazy-lock-mode)
3359 (if (fboundp 'lazy-lock-fontify-region)
3360 (lazy-lock-fontify-region start end) ; the new
3361 (lazy-lock-fontify-buffer)))) ; the old
3363 (defun ps-generate-postscript-with-faces (from to)
3364 ;; Some initialization...
3365 (setq ps-current-effect 0)
3367 ;; Build the reference lists of faces if necessary.
3368 (if (or ps-always-build-face-reference
3369 ps-build-face-reference)
3370 (progn
3371 (message "Collecting face information...")
3372 (ps-build-reference-face-lists)))
3373 ;; Set the color scale. We do it here instead of in the defvar so
3374 ;; that ps-print can be dumped into emacs. This expression can't be
3375 ;; evaluated at dump-time because X isn't initialized.
3376 (setq ps-print-color-scale
3377 (if ps-print-color-p
3378 (float (car (ps-color-values "white")))
3379 1.0))
3380 ;; Generate some PostScript.
3381 (save-restriction
3382 (narrow-to-region from to)
3383 (let ((face 'default)
3384 (position to))
3385 (ps-print-ensure-fontified from to)
3386 (cond
3387 ((or (eq ps-print-emacs-type 'lucid)
3388 (eq ps-print-emacs-type 'xemacs))
3389 ;; Build the list of extents...
3390 (let ((a (cons 'dummy nil))
3391 record type extent extent-list)
3392 (map-extents 'ps-mapper nil from to a)
3393 (setq a (sort (cdr a) 'car-less-than-car))
3395 (setq extent-list nil)
3397 ;; Loop through the extents...
3398 (while a
3399 (setq record (car a))
3401 (setq position (car record))
3402 (setq record (cdr record))
3404 (setq type (car record))
3405 (setq record (cdr record))
3407 (setq extent (car record))
3409 ;; Plot up to this record.
3410 ;; XEmacs 19.12: for some reason, we're getting into a
3411 ;; situation in which some of the records have
3412 ;; positions less than 'from'. Since we've narrowed
3413 ;; the buffer, this'll generate errors. This is a
3414 ;; hack, but don't call ps-plot-with-face unless from >
3415 ;; point-min.
3416 (if (and (>= from (point-min))
3417 (<= position (point-max)))
3418 (ps-plot-with-face from position face))
3420 (cond
3421 ((eq type 'push)
3422 (if (extent-face extent)
3423 (setq extent-list (sort (cons extent extent-list)
3424 'ps-extent-sorter))))
3426 ((eq type 'pull)
3427 (setq extent-list (sort (delq extent extent-list)
3428 'ps-extent-sorter))))
3430 (setq face
3431 (if extent-list
3432 (extent-face (car extent-list))
3433 'default))
3435 (setq from position)
3436 (setq a (cdr a)))))
3438 ((eq ps-print-emacs-type 'emacs)
3439 (let ((property-change from)
3440 (overlay-change from))
3441 (while (< from to)
3442 (if (< property-change to) ; Don't search for property change
3443 ; unless previous search succeeded.
3444 (setq property-change
3445 (next-property-change from nil to)))
3446 (if (< overlay-change to) ; Don't search for overlay change
3447 ; unless previous search succeeded.
3448 (setq overlay-change
3449 (min (next-overlay-change from) to)))
3450 (setq position
3451 (min property-change overlay-change))
3452 ;; The code below is not quite correct,
3453 ;; because a non-nil overlay invisible property
3454 ;; which is inactive according to the current value
3455 ;; of buffer-invisibility-spec nonetheless overrides
3456 ;; a face text property.
3457 (setq face
3458 (cond ((let ((prop (get-text-property from 'invisible)))
3459 ;; Decide whether this invisible property
3460 ;; really makes the text invisible.
3461 (if (eq buffer-invisibility-spec t)
3462 (not (null prop))
3463 (or (memq prop buffer-invisibility-spec)
3464 (assq prop buffer-invisibility-spec))))
3465 nil)
3466 ((get-text-property from 'face))
3467 (t 'default)))
3468 (let ((overlays (overlays-at from))
3469 (face-priority -1)) ; text-property
3470 (while overlays
3471 (let* ((overlay (car overlays))
3472 (overlay-face (overlay-get overlay 'face))
3473 (overlay-invisible (overlay-get overlay 'invisible))
3474 (overlay-priority (or (overlay-get overlay
3475 'priority)
3476 0)))
3477 (if (and (or overlay-invisible overlay-face)
3478 (> overlay-priority face-priority))
3479 (setq face (cond ((if (eq buffer-invisibility-spec t)
3480 (not (null overlay-invisible))
3481 (or (memq overlay-invisible
3482 buffer-invisibility-spec)
3483 (assq overlay-invisible
3484 buffer-invisibility-spec)))
3485 nil)
3486 ((and face overlay-face)))
3487 face-priority overlay-priority)))
3488 (setq overlays (cdr overlays))))
3489 ;; Plot up to this record.
3490 (ps-plot-with-face from position face)
3491 (setq from position)))))
3492 (ps-plot-with-face from to face))))
3494 (defun ps-generate-postscript (from to)
3495 (ps-plot-region from to 0 nil))
3497 (defun ps-generate (buffer from to genfunc)
3498 (save-excursion
3499 (let ((from (min to from))
3500 (to (max to from))
3501 ;; This avoids trouble if chars with read-only properties
3502 ;; are copied into ps-spool-buffer.
3503 (inhibit-read-only t))
3504 (save-restriction
3505 (narrow-to-region from to)
3506 (if ps-razzle-dazzle
3507 (message "Formatting...%3d%%" (setq ps-razchunk 0)))
3508 (set-buffer buffer)
3509 (setq ps-source-buffer buffer)
3510 (setq ps-spool-buffer (get-buffer-create ps-spool-buffer-name))
3511 (ps-init-output-queue)
3512 (let (safe-marker completed-safely needs-begin-file)
3513 (unwind-protect
3514 (progn
3515 (set-buffer ps-spool-buffer)
3517 ;; Get a marker and make it point to the current end of the
3518 ;; buffer, If an error occurs, we'll delete everything from
3519 ;; the end of this marker onwards.
3520 (setq safe-marker (make-marker))
3521 (set-marker safe-marker (point-max))
3523 (goto-char (point-min))
3524 (if (looking-at (regexp-quote ps-adobe-tag))
3526 (setq needs-begin-file t))
3527 (save-excursion
3528 (set-buffer ps-source-buffer)
3529 (if needs-begin-file (ps-begin-file))
3530 (ps-begin-job)
3531 (ps-begin-page))
3532 (set-buffer ps-source-buffer)
3533 (funcall genfunc from to)
3534 (ps-end-page)
3536 (if (and ps-spool-duplex
3537 (= (mod ps-page-count 2) 1))
3538 (ps-dummy-page))
3539 (ps-flush-output)
3541 ;; Back to the PS output buffer to set the page count
3542 (set-buffer ps-spool-buffer)
3543 (goto-char (point-max))
3544 (while (re-search-backward "^/PageCount 0 def$" nil t)
3545 (replace-match (format "/PageCount %d def" ps-page-count) t))
3547 ;; Setting this variable tells the unwind form that the
3548 ;; the postscript was generated without error.
3549 (setq completed-safely t))
3551 ;; Unwind form: If some bad mojo occurred while generating
3552 ;; postscript, delete all the postscript that was generated.
3553 ;; This protects the previously spooled files from getting
3554 ;; corrupted.
3555 (if (and (markerp safe-marker) (not completed-safely))
3556 (progn
3557 (set-buffer ps-spool-buffer)
3558 (delete-region (marker-position safe-marker) (point-max))))))
3560 (if ps-razzle-dazzle
3561 (message "Formatting...done"))))))
3563 (defun ps-do-despool (filename)
3564 (if (or (not (boundp 'ps-spool-buffer))
3565 (not (symbol-value 'ps-spool-buffer)))
3566 (message "No spooled PostScript to print")
3567 (ps-end-file)
3568 (ps-flush-output)
3569 (if filename
3570 (save-excursion
3571 (if ps-razzle-dazzle
3572 (message "Saving..."))
3573 (set-buffer ps-spool-buffer)
3574 (setq filename (expand-file-name filename))
3575 (write-region (point-min) (point-max) filename)
3576 (if ps-razzle-dazzle
3577 (message "Wrote %s" filename)))
3578 ;; Else, spool to the printer
3579 (if ps-razzle-dazzle
3580 (message "Printing..."))
3581 (save-excursion
3582 (set-buffer ps-spool-buffer)
3583 (if (and (eq system-type 'ms-dos)
3584 (stringp (symbol-value 'dos-ps-printer)))
3585 (write-region (point-min) (point-max)
3586 (symbol-value 'dos-ps-printer) t 0)
3587 (let ((binary-process-input t)) ; for MS-DOS
3588 (apply 'call-process-region
3589 (point-min) (point-max) ps-lpr-command nil
3590 (if (fboundp 'start-process) 0 nil)
3592 ps-lpr-switches))))
3593 (if ps-razzle-dazzle
3594 (message "Printing...done")))
3595 (kill-buffer ps-spool-buffer)))
3597 (defun ps-kill-emacs-check ()
3598 (let (ps-buffer)
3599 (if (and (setq ps-buffer (get-buffer ps-spool-buffer-name))
3600 (buffer-modified-p ps-buffer))
3601 (if (y-or-n-p "Unprinted PostScript waiting; print now? ")
3602 (ps-despool)))
3603 (if (and (setq ps-buffer (get-buffer ps-spool-buffer-name))
3604 (buffer-modified-p ps-buffer))
3605 (if (yes-or-no-p "Unprinted PostScript waiting; exit anyway? ")
3607 (error "Unprinted PostScript")))))
3609 (if (fboundp 'add-hook)
3610 (funcall 'add-hook 'kill-emacs-hook 'ps-kill-emacs-check)
3611 (if kill-emacs-hook
3612 (message "Won't override existing kill-emacs-hook")
3613 (setq kill-emacs-hook 'ps-kill-emacs-check)))
3615 ;;; Sample Setup Code:
3617 ;; This stuff is for anybody that's brave enough to look this far,
3618 ;; and able to figure out how to use it. It isn't really part of
3619 ;; ps-print, but I'll leave it here in hopes it might be useful:
3621 ;; WARNING!!! The following code is *sample* code only. Don't use it
3622 ;; unless you understand what it does!
3624 (defmacro ps-prsc ()
3625 `(if (eq ps-print-emacs-type 'emacs) [f22] 'f22))
3626 (defmacro ps-c-prsc ()
3627 `(if (eq ps-print-emacs-type 'emacs) [C-f22] '(control f22)))
3628 (defmacro ps-s-prsc ()
3629 `(if (eq ps-print-emacs-type 'emacs) [S-f22] '(shift f22)))
3631 ;; A hook to bind to `rmail-mode-hook' to locally bind prsc and set the
3632 ;; `ps-left-headers' specially for mail messages.
3633 (defun ps-rmail-mode-hook ()
3634 (local-set-key (ps-prsc) 'ps-rmail-print-message-from-summary)
3635 (setq ps-header-lines 3
3636 ps-left-header
3637 ;; The left headers will display the message's subject, its
3638 ;; author, and the name of the folder it was in.
3639 '(ps-article-subject ps-article-author buffer-name)))
3641 ;; See `ps-gnus-print-article-from-summary'. This function does the
3642 ;; same thing for rmail.
3643 (defun ps-rmail-print-message-from-summary ()
3644 (interactive)
3645 (ps-print-message-from-summary 'rmail-summary-buffer "RMAIL"))
3647 ;; Used in `ps-rmail-print-article-from-summary',
3648 ;; `ps-gnus-print-article-from-summary' and `ps-vm-print-message-from-summary'.
3649 (defun ps-print-message-from-summary (summary-buffer summary-default)
3650 (let ((ps-buf (or (and (boundp summary-buffer)
3651 (symbol-value summary-buffer))
3652 summary-default)))
3653 (and (get-buffer ps-buf)
3654 (save-excursion
3655 (set-buffer ps-buf)
3656 (ps-spool-buffer-with-faces)))))
3658 ;; Look in an article or mail message for the Subject: line. To be
3659 ;; placed in `ps-left-headers'.
3660 (defun ps-article-subject ()
3661 (save-excursion
3662 (goto-char (point-min))
3663 (if (re-search-forward "^Subject:[ \t]+\\(.*\\)$" nil t)
3664 (buffer-substring-no-properties (match-beginning 1) (match-end 1))
3665 "Subject ???")))
3667 ;; Look in an article or mail message for the From: line. Sorta-kinda
3668 ;; understands RFC-822 addresses and can pull the real name out where
3669 ;; it's provided. To be placed in `ps-left-headers'.
3670 (defun ps-article-author ()
3671 (save-excursion
3672 (goto-char (point-min))
3673 (if (re-search-forward "^From:[ \t]+\\(.*\\)$" nil t)
3674 (let ((fromstring (buffer-substring-no-properties (match-beginning 1)
3675 (match-end 1))))
3676 (cond
3678 ;; Try first to match addresses that look like
3679 ;; thompson@wg2.waii.com (Jim Thompson)
3680 ((string-match ".*[ \t]+(\\(.*\\))" fromstring)
3681 (substring fromstring (match-beginning 1) (match-end 1)))
3683 ;; Next try to match addresses that look like
3684 ;; Jim Thompson <thompson@wg2.waii.com>
3685 ((string-match "\\(.*\\)[ \t]+<.*>" fromstring)
3686 (substring fromstring (match-beginning 1) (match-end 1)))
3688 ;; Couldn't find a real name -- show the address instead.
3689 (t fromstring)))
3690 "From ???")))
3692 ;; A hook to bind to `gnus-article-prepare-hook'. This will set the
3693 ;; `ps-left-headers' specially for gnus articles. Unfortunately,
3694 ;; `gnus-article-mode-hook' is called only once, the first time the *Article*
3695 ;; buffer enters that mode, so it would only work for the first time
3696 ;; we ran gnus. The second time, this hook wouldn't get set up. The
3697 ;; only alternative is `gnus-article-prepare-hook'.
3698 (defun ps-gnus-article-prepare-hook ()
3699 (setq ps-header-lines 3)
3700 (setq ps-left-header
3701 ;; The left headers will display the article's subject, its
3702 ;; author, and the newsgroup it was in.
3703 (list 'ps-article-subject 'ps-article-author 'gnus-newsgroup-name)))
3705 ;; A hook to bind to `vm-mode-hook' to locally bind prsc and set the
3706 ;; `ps-left-headers' specially for mail messages.
3707 (defun ps-vm-mode-hook ()
3708 (local-set-key (ps-prsc) 'ps-vm-print-message-from-summary)
3709 (setq ps-header-lines 3)
3710 (setq ps-left-header
3711 ;; The left headers will display the message's subject, its
3712 ;; author, and the name of the folder it was in.
3713 (list 'ps-article-subject 'ps-article-author 'buffer-name)))
3715 ;; Every now and then I forget to switch from the *Summary* buffer to
3716 ;; the *Article* before hitting prsc, and a nicely formatted list of
3717 ;; article subjects shows up at the printer. This function, bound to
3718 ;; prsc for the gnus *Summary* buffer means I don't have to switch
3719 ;; buffers first.
3720 ;; sb: Updated for Gnus 5.
3721 (defun ps-gnus-print-article-from-summary ()
3722 (interactive)
3723 (ps-print-message-from-summary 'gnus-article-buffer "*Article*"))
3725 ;; See `ps-gnus-print-article-from-summary'. This function does the
3726 ;; same thing for vm.
3727 (defun ps-vm-print-message-from-summary ()
3728 (interactive)
3729 (ps-print-message-from-summary 'vm-mail-buffer ""))
3731 ;; A hook to bind to bind to `gnus-summary-setup-buffer' to locally bind
3732 ;; prsc.
3733 (defun ps-gnus-summary-setup ()
3734 (local-set-key (ps-prsc) 'ps-gnus-print-article-from-summary))
3736 ;; Look in an article or mail message for the Subject: line. To be
3737 ;; placed in `ps-left-headers'.
3738 (defun ps-info-file ()
3739 (save-excursion
3740 (goto-char (point-min))
3741 (if (re-search-forward "File:[ \t]+\\([^, \t\n]*\\)" nil t)
3742 (buffer-substring-no-properties (match-beginning 1) (match-end 1))
3743 "File ???")))
3745 ;; Look in an article or mail message for the Subject: line. To be
3746 ;; placed in `ps-left-headers'.
3747 (defun ps-info-node ()
3748 (save-excursion
3749 (goto-char (point-min))
3750 (if (re-search-forward "Node:[ \t]+\\([^,\t\n]*\\)" nil t)
3751 (buffer-substring-no-properties (match-beginning 1) (match-end 1))
3752 "Node ???")))
3754 (defun ps-info-mode-hook ()
3755 (setq ps-left-header
3756 ;; The left headers will display the node name and file name.
3757 (list 'ps-info-node 'ps-info-file)))
3759 ;; WARNING! The following function is a *sample* only, and is *not*
3760 ;; meant to be used as a whole unless you understand what the effects
3761 ;; will be! (In fact, this is a copy of Jim's setup for ps-print --
3762 ;; I'd be very surprised if it was useful to *anybody*, without
3763 ;; modification.)
3765 (defun ps-jts-ps-setup ()
3766 (global-set-key (ps-prsc) 'ps-spool-buffer-with-faces) ;f22 is prsc
3767 (global-set-key (ps-s-prsc) 'ps-spool-region-with-faces)
3768 (global-set-key (ps-c-prsc) 'ps-despool)
3769 (add-hook 'gnus-article-prepare-hook 'ps-gnus-article-prepare-hook)
3770 (add-hook 'gnus-summary-mode-hook 'ps-gnus-summary-setup)
3771 (add-hook 'vm-mode-hook 'ps-vm-mode-hook)
3772 (add-hook 'vm-mode-hooks 'ps-vm-mode-hook)
3773 (add-hook 'Info-mode-hook 'ps-info-mode-hook)
3774 (setq ps-spool-duplex t)
3775 (setq ps-print-color-p nil)
3776 (setq ps-lpr-command "lpr")
3777 (setq ps-lpr-switches '("-Jjct,duplex_long"))
3778 'ps-jts-ps-setup)
3780 ;; WARNING! The following function is a *sample* only, and is *not*
3781 ;; meant to be used as a whole unless it corresponds to your needs.
3782 ;; (In fact, this is a copy of Jack's setup for ps-print --
3783 ;; I would not be that surprised if it was useful to *anybody*,
3784 ;; without modification.)
3786 (defun ps-jack-setup ()
3787 (setq ps-print-color-p nil
3788 ps-lpr-command "lpr"
3789 ps-lpr-switches (list)
3791 ps-paper-type 'a4
3792 ps-landscape-mode t
3793 ps-number-of-columns 2
3795 ps-left-margin (/ (* 72 1.0) 2.54) ; 1.0 cm
3796 ps-right-margin (/ (* 72 1.0) 2.54) ; 1.0 cm
3797 ps-inter-column (/ (* 72 1.0) 2.54) ; 1.0 cm
3798 ps-bottom-margin (/ (* 72 1.5) 2.54) ; 1.5 cm
3799 ps-top-margin (/ (* 72 1.5) 2.54) ; 1.5 cm
3800 ps-header-offset (/ (* 72 1.0) 2.54) ; 1.0 cm
3801 ps-header-line-pad .15
3802 ps-print-header t
3803 ps-print-header-frame t
3804 ps-header-lines 2
3805 ps-show-n-of-n t
3806 ps-spool-duplex nil
3808 ps-font-family 'Courier
3809 ps-font-size 5.5
3810 ps-header-font-family 'Helvetica
3811 ps-header-font-size 6
3812 ps-header-title-font-size 8)
3813 'ps-jack-setup)
3815 (provide 'ps-print)
3817 ;;; ps-print.el ends here