comparison lisp/ps-print.el @ 56504:8d030ffc0866

Improve DSC compliance.
author Vinicius Jose Latorre <viniciusjl@ig.com.br>
date Fri, 23 Jul 2004 01:16:06 +0000
parents a39b3f6d1177
children 12ee8343c078 b9eee0a7bef5
comparison
equal deleted inserted replaced
56503:8bbd2323fbf2 56504:8d030ffc0866
8 ;; Vinicius Jose Latorre <viniciusjl@ig.com.br> 8 ;; Vinicius Jose Latorre <viniciusjl@ig.com.br>
9 ;; Kenichi Handa <handa@etl.go.jp> (multi-byte characters) 9 ;; Kenichi Handa <handa@etl.go.jp> (multi-byte characters)
10 ;; Maintainer: Kenichi Handa <handa@etl.go.jp> (multi-byte characters) 10 ;; Maintainer: Kenichi Handa <handa@etl.go.jp> (multi-byte characters)
11 ;; Vinicius Jose Latorre <viniciusjl@ig.com.br> 11 ;; Vinicius Jose Latorre <viniciusjl@ig.com.br>
12 ;; Keywords: wp, print, PostScript 12 ;; Keywords: wp, print, PostScript
13 ;; Time-stamp: <2004/03/10 18:57:00 vinicius> 13 ;; Time-stamp: <2004/07/21 23:12:05 vinicius>
14 ;; Version: 6.6.4 14 ;; Version: 6.6.5
15 ;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/ 15 ;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/
16 16
17 (defconst ps-print-version "6.6.4" 17 (defconst ps-print-version "6.6.5"
18 "ps-print.el, v 6.6.4 <2004/03/10 vinicius> 18 "ps-print.el, v 6.6.5 <2004/07/21 vinicius>
19 19
20 Vinicius's last change version -- this file may have been edited as part of 20 Vinicius's last change version -- this file may have been edited as part of
21 Emacs without changes to the version number. When reporting bugs, please also 21 Emacs without changes to the version number. When reporting bugs, please also
22 report the version of Emacs, if any, that ps-print was distributed with. 22 report the version of Emacs, if any, that ps-print was distributed with.
23 23
1351 ;; 1351 ;;
1352 ;; 1352 ;;
1353 ;; Acknowledgments 1353 ;; Acknowledgments
1354 ;; --------------- 1354 ;; ---------------
1355 ;; 1355 ;;
1356 ;; Thanks to Michael Piotrowski <mxp@dynalabs.de> for improving the DSC
1357 ;; compliance of the generated PostScript.
1358 ;;
1356 ;; Thanks to Adam Doppelt <adoppelt@avogadro.com> for face mapping suggestion 1359 ;; Thanks to Adam Doppelt <adoppelt@avogadro.com> for face mapping suggestion
1357 ;; for black/white PostScript printers. 1360 ;; for black/white PostScript printers.
1358 ;; 1361 ;;
1359 ;; Thanks to Toni Ronkko <tronkko@hytti.uku.fi> for line and paragraph spacing, 1362 ;; Thanks to Toni Ronkko <tronkko@hytti.uku.fi> for line and paragraph spacing,
1360 ;; region to cut out when printing and footer suggestions. 1363 ;; region to cut out when printing and footer suggestions.
1422 ;; 1425 ;;
1423 ;; Thanks to Avishai Yacobi, avishaiy@mcil.comm.mot.com, for writing the 1426 ;; Thanks to Avishai Yacobi, avishaiy@mcil.comm.mot.com, for writing the
1424 ;; initial port to Emacs 19. His code is no longer part of ps-print, but his 1427 ;; initial port to Emacs 19. His code is no longer part of ps-print, but his
1425 ;; work is still appreciated. 1428 ;; work is still appreciated.
1426 ;; 1429 ;;
1427 ;; Thanks to Remi Houdaille and Michel Train, michel@metasoft.fdn.org, for 1430 ;; Thanks to Remi Houdaille and Michel Train <michel@metasoft.fdn.org> for
1428 ;; adding underline support. Their code also is no longer part of ps-print, 1431 ;; adding underline support. Their code also is no longer part of ps-print,
1429 ;; but their efforts are not forgotten. 1432 ;; but their efforts are not forgotten.
1430 ;; 1433 ;;
1431 ;; Thanks also to all of you who mailed code to add features to ps-print; 1434 ;; Thanks also to all of you who mailed code to add features to ps-print;
1432 ;; although I didn't use your code, I still appreciate your sharing it with me. 1435 ;; although I didn't use your code, I still appreciate your sharing it with me.
4160 ;; Internal functions and variables 4163 ;; Internal functions and variables
4161 4164
4162 4165
4163 (defun ps-message-log-max () 4166 (defun ps-message-log-max ()
4164 (and (not (string= (buffer-name) "*Messages*")) 4167 (and (not (string= (buffer-name) "*Messages*"))
4168 (boundp 'message-log-max)
4165 message-log-max)) 4169 message-log-max))
4166 4170
4167 4171
4168 (defvar ps-print-hook nil) 4172 (defvar ps-print-hook nil)
4169 (defvar ps-print-begin-sheet-hook nil) 4173 (defvar ps-print-begin-sheet-hook nil)
4208 (goto-char to) 4212 (goto-char to)
4209 (if (= (current-column) 0) 1 0)))) 4213 (if (= (current-column) 0) 1 0))))
4210 4214
4211 4215
4212 (defvar ps-printing-region nil 4216 (defvar ps-printing-region nil
4213 "Variable used to indicate if the region that ps-print is printing. 4217 "Variable used to indicate the region that ps-print is printing.
4214 It is a cons, the car of which is the line number where the region begins, and 4218 It is a cons, the car of which is the line number where the region begins, and
4215 its cdr is the total number of lines in the buffer. Formatting functions can 4219 its cdr is the total number of lines in the buffer. Formatting functions can
4216 use this information to print the original line number (and not the number of 4220 use this information to print the original line number (and not the number of
4217 lines printed), and to indicate in the header that the printout is of a partial 4221 lines printed), and to indicate in the header that the printout is of a partial
4218 file.") 4222 file.")
4727 4731
4728 (defun ps-generate-string-list (content) 4732 (defun ps-generate-string-list (content)
4729 (let (str) 4733 (let (str)
4730 (while content 4734 (while content
4731 (setq str (cons (cond 4735 (setq str (cons (cond
4736 ;; string
4732 ((stringp (car content)) 4737 ((stringp (car content))
4733 (car content)) 4738 (car content))
4739 ;; function symbol
4734 ((and (symbolp (car content)) (fboundp (car content))) 4740 ((and (symbolp (car content)) (fboundp (car content)))
4735 (concat "(" (funcall (car content)) ")")) 4741 (concat "(" (funcall (car content)) ")"))
4742 ;; variable symbol
4736 ((and (symbolp (car content)) (boundp (car content))) 4743 ((and (symbolp (car content)) (boundp (car content)))
4737 (concat "(" (symbol-value (car content)) ")")) 4744 (concat "(" (symbol-value (car content)) ")"))
4745 ;; otherwise, empty string
4738 (t 4746 (t
4739 "")) 4747 ""))
4740 str) 4748 str)
4741 content (cdr content))) 4749 content (cdr content)))
4742 (nreverse str))) 4750 (nreverse str)))
5422 (and ps-n-up-on (setq tumble (not tumble))) 5430 (and ps-n-up-on (setq tumble (not tumble)))
5423 (ps-output 5431 (ps-output
5424 ps-adobe-tag 5432 ps-adobe-tag
5425 "%%Title: " (buffer-name) ; Take job name from name of 5433 "%%Title: " (buffer-name) ; Take job name from name of
5426 ; first buffer printed 5434 ; first buffer printed
5427 "\n%%Creator: " (user-full-name) 5435 "\n%%Creator: ps-print v" ps-print-version
5428 " (using ps-print v" ps-print-version 5436 "\n%%For: " (user-full-name)
5429 ")\n%%CreationDate: " (format-time-string "%T %b %d %Y") 5437 "\n%%CreationDate: " (format-time-string "%T %b %d %Y")
5430 "\n%%Orientation: " 5438 "\n%%Orientation: "
5431 (if ps-landscape-mode "Landscape" "Portrait") 5439 (if ps-landscape-mode "Landscape" "Portrait")
5432 "\n%%DocumentNeededResources: font Times-Roman Times-Italic\n%%+ font " 5440 "\n%%DocumentNeededResources: font Times-Roman Times-Italic\n%%+ font "
5433 (mapconcat 'identity 5441 (mapconcat 'identity
5434 (ps-remove-duplicates 5442 (ps-remove-duplicates
5435 (append (ps-fonts 'ps-font-for-text) 5443 (append (ps-fonts 'ps-font-for-text)
5436 (list (ps-font 'ps-font-for-header 'normal) 5444 (list (ps-font 'ps-font-for-header 'normal)
5437 (ps-font 'ps-font-for-header 'bold)))) 5445 (ps-font 'ps-font-for-header 'bold)
5446 (ps-font 'ps-font-for-footer 'normal)
5447 (ps-font 'ps-font-for-footer 'bold))))
5438 "\n%%+ font ") 5448 "\n%%+ font ")
5449 "\n%%DocumentSuppliedResources: procset PSPrintUserDefinedPrologue-" (user-login-name) " 0 0"
5439 "\n%%DocumentMedia: " (ps-page-dimensions-get-media dimensions) 5450 "\n%%DocumentMedia: " (ps-page-dimensions-get-media dimensions)
5440 (format " %d" (round (ps-page-dimensions-get-width dimensions))) 5451 (format " %d" (round (ps-page-dimensions-get-width dimensions)))
5441 (format " %d" (round (ps-page-dimensions-get-height dimensions))) 5452 (format " %d" (round (ps-page-dimensions-get-height dimensions)))
5442 " 0 () ()\n%%PageOrder: Ascend\n%%Pages: (atend)\n%%Requirements:" 5453 " 0 () ()\n%%PageOrder: Ascend\n%%Pages: (atend)\n%%Requirements:"
5443 (if ps-spool-duplex 5454 (if ps-spool-duplex
5453 (format "/ErrorMessage %s def\n\n" 5464 (format "/ErrorMessage %s def\n\n"
5454 (or (cdr (assoc ps-error-handler-message 5465 (or (cdr (assoc ps-error-handler-message
5455 ps-error-handler-alist)) 5466 ps-error-handler-alist))
5456 1)) ; send to paper 5467 1)) ; send to paper
5457 ps-print-prologue-0 5468 ps-print-prologue-0
5458 "\n%%BeginProcSet: UserDefinedPrologue\n\n") 5469 "\n%%BeginResource: procset PSPrintUserDefinedPrologue-" (user-login-name) " 0 0\n\n")
5459 5470
5460 (ps-insert-string ps-user-defined-prologue) 5471 (ps-insert-string ps-user-defined-prologue)
5461 5472
5462 (ps-output "\n%%EndProcSet\n\n") 5473 (ps-output "\n%%EndResource\n\n")
5463 5474
5464 (ps-output-boolean "LandscapeMode " 5475 (ps-output-boolean "LandscapeMode "
5465 (or ps-landscape-mode 5476 (or ps-landscape-mode
5466 (eq (ps-n-up-landscape n-up) 'pag))) 5477 (eq (ps-n-up-landscape n-up) 'pag)))
5467 (ps-output-boolean "UpsideDown " ps-print-upside-down) 5478 (ps-output-boolean "UpsideDown " ps-print-upside-down)
5569 5580
5570 (ps-output "\n/printGlobalBackground{\n") 5581 (ps-output "\n/printGlobalBackground{\n")
5571 (mapcar 'ps-output ps-background-all-pages) 5582 (mapcar 'ps-output ps-background-all-pages)
5572 (ps-output "}def\n/printLocalBackground{\n}def\n") 5583 (ps-output "}def\n/printLocalBackground{\n}def\n")
5573 5584
5585 (ps-output "\n%%EndProlog\n\n%%BeginSetup\n")
5586
5587 (ps-output
5588 "\n%%IncludeResource: font Times-Roman"
5589 "\n%%IncludeResource: font Times-Italic\n%%IncludeResource: font "
5590 (mapconcat 'identity
5591 (ps-remove-duplicates
5592 (append (ps-fonts 'ps-font-for-text)
5593 (list (ps-font 'ps-font-for-header 'normal)
5594 (ps-font 'ps-font-for-header 'bold)
5595 (ps-font 'ps-font-for-footer 'normal)
5596 (ps-font 'ps-font-for-footer 'bold))))
5597 "\n%%IncludeResource: font ")
5598 "\n")
5599
5574 ;; Header/line number fonts 5600 ;; Header/line number fonts
5575 (ps-output (format "/h0 %s(%s)cvn DefFont\n" ; /h0 14/Helvetica-Bold DefFont 5601 (ps-output (format "/h0 %s(%s)cvn DefFont\n" ; /h0 14/Helvetica-Bold DefFont
5576 ps-header-title-font-size-internal 5602 ps-header-title-font-size-internal
5577 (ps-font 'ps-font-for-header 'bold)) 5603 (ps-font 'ps-font-for-header 'bold))
5578 (format "/h1 %s(%s)cvn DefFont\n" ; /h1 12/Helvetica DefFont 5604 (format "/h1 %s(%s)cvn DefFont\n" ; /h1 12/Helvetica DefFont
5612 5638
5613 (let ((font-entry (cdr (assq ps-font-family ps-font-info-database)))) 5639 (let ((font-entry (cdr (assq ps-font-family ps-font-info-database))))
5614 (ps-output (format "/SpaceWidthRatio %f def\n" 5640 (ps-output (format "/SpaceWidthRatio %f def\n"
5615 (/ (ps-lookup 'space-width) (ps-lookup 'size))))) 5641 (/ (ps-lookup 'space-width) (ps-lookup 'size)))))
5616 5642
5617 (ps-output "\n%%EndProlog\n\n%%BeginSetup\n")
5618 (unless (eq ps-spool-config 'lpr-switches) 5643 (unless (eq ps-spool-config 'lpr-switches)
5619 (ps-output "\n%%BeginFeature: *Duplex " 5644 (ps-output "\n%%BeginFeature: *Duplex "
5620 (ps-boolean-capitalized ps-spool-duplex) 5645 (ps-boolean-capitalized ps-spool-duplex)
5621 " *Tumble " 5646 " *Tumble "
5622 (ps-boolean-capitalized tumble) 5647 (ps-boolean-capitalized tumble)