aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann2001-04-02 10:35:07 +0000
committerGerd Moellmann2001-04-02 10:35:07 +0000
commit6bf5fb46a34e07dca0f68dd89aad788d730712d9 (patch)
treeeb0b1d2c4b22f94c02b923692de2340a82f664d3
parentc0eb3c10523c99549e2253f23e6ce3f65ce469cf (diff)
downloademacs-6bf5fb46a34e07dca0f68dd89aad788d730712d9.tar.gz
emacs-6bf5fb46a34e07dca0f68dd89aad788d730712d9.zip
Line and paragraph spacing feature. Region to cut
out when printing. Doc fix. (ps-print-version): New version number (6.5). (ps-line-spacing, ps-paragraph-spacing, ps-paragraph-regexp): New vars. Line and paragraph spacing feature. (ps-begin-cut-regexp, ps-end-cut-regexp): New vars. Region to cut out when printing. (ps-setup, ps-nb-pages, ps-get-page-dimensions, ps-begin-file) (ps-get-font-size, ps-begin-job, ps-continue-line) (ps-plot-region): Code fix. (ps-print-prologue-2): Var eliminated. (ps-line-spacing-internal, ps-paragraph-spacing-internal): New internal vars. (ps-get-size): New fun. (ps-output-string-prim, ps-init-output-queue, ps-print-page-p) (ps-next-line): Replace defun by defsubst. (ps-mule-plot-string): Autoload doc fix. (ps-mule-generate-font): New arg HEADER-P. If it is non-nil, generate font for the header strings. (ps-mule-prepare-font): Likewise. (ps-mule-generate-glyphs): Likewise. (ps-mule-string-encoding): Likewise. (ps-mule-header-charsets): New variable. (ps-mule-encode-header-string): New function. (ps-mule-header-string-charsets): New function. (ps-mule-begin-job): Check charsets in the header strings. If there are non-ASCII and non-Latin1 charsets, prepare fonts for them.
-rw-r--r--lisp/ps-print.el256
1 files changed, 211 insertions, 45 deletions
diff --git a/lisp/ps-print.el b/lisp/ps-print.el
index 4238f258dc8..deb7b7b88c4 100644
--- a/lisp/ps-print.el
+++ b/lisp/ps-print.el
@@ -10,12 +10,12 @@
10;; Maintainer: Kenichi Handa <handa@etl.go.jp> (multi-byte characters) 10;; Maintainer: Kenichi Handa <handa@etl.go.jp> (multi-byte characters)
11;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br> 11;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br>
12;; Keywords: wp, print, PostScript 12;; Keywords: wp, print, PostScript
13;; Time-stamp: <2001/02/19 14:54:52 Vinicius> 13;; Time-stamp: <2001/03/23 21:27:46 Vinicius>
14;; Version: 6.4 14;; Version: 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.4" 17(defconst ps-print-version "6.5"
18 "ps-print.el, v 6.4 <2001/02/19 vinicius> 18 "ps-print.el, v 6.5 <2001/03/23 vinicius>
19 19
20Vinicius's last change version -- this file may have been edited as part of 20Vinicius's last change version -- this file may have been edited as part of
21Emacs without changes to the version number. When reporting bugs, please also 21Emacs without changes to the version number. When reporting bugs, please also
@@ -849,6 +849,35 @@ Please send all bug fixes and enhancements to
849;; The variable `ps-header-title-font-size' determines the font size, in points, 849;; The variable `ps-header-title-font-size' determines the font size, in points,
850;; for the top line of text in the header (similar to `ps-font-size'). 850;; for the top line of text in the header (similar to `ps-font-size').
851;; 851;;
852;; The variable `ps-line-spacing' determines the line spacing, in points, for
853;; ordinary text, when generating PostScript (similar to `ps-font-size'). The
854;; default value is 0 (zero = no line spacing).
855;;
856;; The variable `ps-paragraph-spacing' determines the paragraph spacing, in
857;; points, for ordinary text, when generating PostScript (similar to
858;; `ps-font-size'). The default value is 0 (zero = no paragraph spacing).
859;;
860;; To get all lines with some spacing set both `ps-line-spacing' and
861;; `ps-paragraph-spacing' variables.
862;;
863;; The variable `ps-paragraph-regexp' specifies the paragraph delimiter. It
864;; should be a regexp or nil. The default value is "[ \t]*$", that is, an
865;; empty line or a line containing only spaces and tabs.
866;;
867;; The variable `ps-begin-cut-regexp' and `ps-end-cut-regexp' specify the start
868;; and end of a region to cut out when printing.
869;;
870;; As an example, variables `ps-begin-cut-regexp' and `ps-end-cut-regexp' may
871;; be set to "^Local Variables:" and "^End:", respectively, in order to leave
872;; out some special printing instructions from the actual print. Special
873;; printing instructions may be appended to the end of the file just like any
874;; other buffer-local variables. See section "Local Variables in Files" on
875;; Emacs manual for more information.
876;;
877;; Variables `ps-begin-cut-regexp' and `ps-end-cut-regexp' control together what
878;; actually gets printed. Both variables may be set to nil in which case no
879;; cutting occurs. By default, both variables are set to nil.
880;;
852;; 881;;
853;; Adding a New Font Family 882;; Adding a New Font Family
854;; ------------------------ 883;; ------------------------
@@ -1249,8 +1278,10 @@ Please send all bug fixes and enhancements to
1249;; of folding lines. 1278;; of folding lines.
1250;; 1279;;
1251;; 1280;;
1252;; Acknowledgements 1281;; Acknowledgments
1253;; ---------------- 1282;; ---------------
1283;;
1284;; Thanks to Pavel Janik ml <Pavel@Janik.cz> for documentation correction.
1254;; 1285;;
1255;; Thanks to Corinne Ilvedson <cilvedson@draper.com> for line number font size 1286;; Thanks to Corinne Ilvedson <cilvedson@draper.com> for line number font size
1256;; suggestion. 1287;; suggestion.
@@ -1640,6 +1671,7 @@ This variable is used only when `ps-printer-name' is a non-empty string."
1640 :tag "Printer Name Option" 1671 :tag "Printer Name Option"
1641 (const :tag "None" nil) 1672 (const :tag "None" nil)
1642 (string :tag "Option")) 1673 (string :tag "Option"))
1674 :version "21.1"
1643 :group 'ps-print-printer) 1675 :group 'ps-print-printer)
1644 1676
1645(defcustom ps-lpr-command lpr-command 1677(defcustom ps-lpr-command lpr-command
@@ -1678,6 +1710,7 @@ If it's nil, automatic feeding takes place."
1678 1710
1679(defcustom ps-end-with-control-d (and ps-windows-system t) 1711(defcustom ps-end-with-control-d (and ps-windows-system t)
1680 "*Non-nil means insert C-d at end of PostScript file generated." 1712 "*Non-nil means insert C-d at end of PostScript file generated."
1713 :version "21.1"
1681 :type 'boolean 1714 :type 'boolean
1682 :group 'ps-print-printer) 1715 :group 'ps-print-printer)
1683 1716
@@ -2718,6 +2751,75 @@ By default, this directory is the same as in the variable `data-directory'."
2718 :type 'directory 2751 :type 'directory
2719 :group 'ps-print-miscellany) 2752 :group 'ps-print-miscellany)
2720 2753
2754(defcustom ps-line-spacing 0
2755 "*Specify line spacing, in points, for ordinary text.
2756
2757See also `ps-paragraph-spacing' and `ps-paragraph-regexp'.
2758
2759To get all lines with some spacing set both `ps-line-spacing' and
2760`ps-paragraph-spacing' variables."
2761 :type '(choice :menu-tag "Line Spacing For Ordinary Text"
2762 :tag "Line Spacing For Ordinary Text"
2763 (number :tag "Line Spacing")
2764 (cons :tag "Landscape/Portrait"
2765 (number :tag "Landscape Line Spacing")
2766 (number :tag "Portrait Line Spacing")))
2767 :version "21.1"
2768 :group 'ps-print-miscellany)
2769
2770(defcustom ps-paragraph-spacing 0
2771 "*Specify paragraph spacing, in points, for ordinary text.
2772
2773See also `ps-line-spacing' and `ps-paragraph-regexp'.
2774
2775To get all lines with some spacing set both `ps-line-spacing' and
2776`ps-paragraph-spacing' variables."
2777 :type '(choice :menu-tag "Paragraph Spacing For Ordinary Text"
2778 :tag "Paragraph Spacing For Ordinary Text"
2779 (number :tag "Paragraph Spacing")
2780 (cons :tag "Landscape/Portrait"
2781 (number :tag "Landscape Paragraph Spacing")
2782 (number :tag "Portrait Paragraph Spacing")))
2783 :version "21.1"
2784 :group 'ps-print-miscellany)
2785
2786(defcustom ps-paragraph-regexp "[ \t]*$"
2787 "*Specify paragraph delimiter.
2788
2789It should be a regexp or nil.
2790
2791See also `ps-paragraph-spacing'."
2792 :type '(choice :menu-tag "Paragraph Delimiter"
2793 (const :tag "No Delimiter" nil)
2794 (regexp :tag "Delimiter Regexp"))
2795 :version "21.1"
2796 :group 'ps-print-miscellany)
2797
2798(defcustom ps-begin-cut-regexp nil
2799 "*Specify regexp which is start of a region to cut out when printing.
2800
2801As an example, variables `ps-begin-cut-regexp' and `ps-end-cut-regexp' may be
2802set to \"^Local Variables:\" and \"^End:\", respectively, in order to leave out
2803some special printing instructions from the actual print. Special printing
2804instructions may be appended to the end of the file just like any other
2805buffer-local variables. See section \"Local Variables in Files\" on Emacs
2806manual for more information.
2807
2808Variables `ps-begin-cut-regexp' and `ps-end-cut-regexp' control together what
2809actually gets printed. Both variables may be set to nil in which case no
2810cutting occurs."
2811 :type 'regexp
2812 :version "21.1"
2813 :group 'ps-print-miscellany)
2814
2815(defcustom ps-end-cut-regexp nil
2816 "*Specify regexp which is end of the region to cut out when printing.
2817
2818See `ps-begin-cut-regexp' for more information."
2819 :type 'regexp
2820 :version "21.1"
2821 :group 'ps-print-miscellany)
2822
2721 2823
2722;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2824;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2723;; Selected Pages 2825;; Selected Pages
@@ -2952,6 +3054,11 @@ The table depends on the current ps-print setup."
2952 ps-header-title-font-size %s 3054 ps-header-title-font-size %s
2953 ps-line-number-font %s 3055 ps-line-number-font %s
2954 ps-line-number-font-size %s 3056 ps-line-number-font-size %s
3057 ps-line-spacing %s
3058 ps-paragraph-spacing %s
3059 ps-paragraph-regexp %s
3060 ps-begin-cut-regexp %s
3061 ps-end-cut-regexp %s
2955 3062
2956 ps-even-or-odd-pages %s 3063 ps-even-or-odd-pages %s
2957 ps-selected-pages %s 3064 ps-selected-pages %s
@@ -3035,6 +3142,11 @@ The table depends on the current ps-print setup."
3035 (ps-print-quote ps-header-title-font-size) 3142 (ps-print-quote ps-header-title-font-size)
3036 ps-line-number-font 3143 ps-line-number-font
3037 (ps-print-quote ps-line-number-font-size) 3144 (ps-print-quote ps-line-number-font-size)
3145 (ps-print-quote ps-line-spacing)
3146 (ps-print-quote ps-paragraph-spacing)
3147 (ps-print-quote ps-paragraph-regexp)
3148 (ps-print-quote ps-begin-cut-regexp)
3149 (ps-print-quote ps-end-cut-regexp)
3038 (ps-print-quote ps-even-or-odd-pages) 3150 (ps-print-quote ps-even-or-odd-pages)
3039 (ps-print-quote ps-selected-pages) 3151 (ps-print-quote ps-selected-pages)
3040 (ps-print-quote ps-last-selected-pages) 3152 (ps-print-quote ps-last-selected-pages)
@@ -3224,10 +3336,7 @@ Note: No major/minor-mode is activated and no local variables are evaluated for
3224 "ps-print PostScript error handler.") 3336 "ps-print PostScript error handler.")
3225 3337
3226(defvar ps-print-prologue-1 "" 3338(defvar ps-print-prologue-1 ""
3227 "ps-print PostScript prologue begin.") 3339 "ps-print PostScript prologue.")
3228
3229(defvar ps-print-prologue-2 ""
3230 "ps-print PostScript prologue end.")
3231 3340
3232;; Start Editing Here: 3341;; Start Editing Here:
3233 3342
@@ -3304,6 +3413,8 @@ This is in units of points (1/72 inch).")
3304(defvar ps-font-size-internal nil) 3413(defvar ps-font-size-internal nil)
3305(defvar ps-header-font-size-internal nil) 3414(defvar ps-header-font-size-internal nil)
3306(defvar ps-header-title-font-size-internal nil) 3415(defvar ps-header-title-font-size-internal nil)
3416(defvar ps-line-spacing-internal nil)
3417(defvar ps-paragraph-spacing-internal nil)
3307 3418
3308 3419
3309;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 3420;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -3641,7 +3752,11 @@ and on the current ps-print setup."
3641 (ps-header-title-font-size-internal 3752 (ps-header-title-font-size-internal
3642 (or ps-header-title-font-size-internal 3753 (or ps-header-title-font-size-internal
3643 (ps-get-font-size 'ps-header-title-font-size))) 3754 (ps-get-font-size 'ps-header-title-font-size)))
3755 (ps-line-spacing-internal
3756 (or ps-line-spacing-internal
3757 (ps-get-size ps-line-spacing "line spacing")))
3644 (buf (get-buffer-create "*Nb-Pages*")) 3758 (buf (get-buffer-create "*Nb-Pages*"))
3759 (ils ps-line-spacing-internal) ; initial line spacing
3645 (ifs ps-font-size-internal) ; initial font size 3760 (ifs ps-font-size-internal) ; initial font size
3646 (ilh (ps-line-height 'ps-font-for-text)) ; initial line height 3761 (ilh (ps-line-height 'ps-font-for-text)) ; initial line height
3647 (page-height (progn (ps-get-page-dimensions) 3762 (page-height (progn (ps-get-page-dimensions)
@@ -3660,10 +3775,10 @@ and on the current ps-print setup."
3660 nb-lpp ; current nb of lines per page 3775 nb-lpp ; current nb of lines per page
3661 nb-page ; current nb of pages 3776 nb-page ; current nb of pages
3662 ) 3777 )
3663 (setq lh-min (/ (* ilh fs-min) ifs) 3778 (setq lh-min (/ (- (* (+ ilh ils) fs-min) ils) ifs)
3664 nb-lpp-max (floor (/ page-height lh-min)) 3779 nb-lpp-max (floor (/ page-height lh-min))
3665 nb-page-min (ceiling (/ (float nb-lines) nb-lpp-max)) 3780 nb-page-min (ceiling (/ (float nb-lines) nb-lpp-max))
3666 lh-max (/ (* ilh fs-max) ifs) 3781 lh-max (/ (- (* (+ ilh ils) fs-max) ils) ifs)
3667 nb-lpp-min (floor (/ page-height lh-max)) 3782 nb-lpp-min (floor (/ page-height lh-max))
3668 nb-page-max (ceiling (/ (float nb-lines) nb-lpp-min)) 3783 nb-page-max (ceiling (/ (float nb-lines) nb-lpp-min))
3669 nb-page nb-page-min) 3784 nb-page nb-page-min)
@@ -3797,7 +3912,8 @@ page-height == bm + print-height + tm - ho - hh
3797 ;; ps-zebra-stripe-follow is `full' or `full-follow' 3912 ;; ps-zebra-stripe-follow is `full' or `full-follow'
3798 (if ps-zebra-stripe-full-p 3913 (if ps-zebra-stripe-full-p
3799 (let* ((line-height (ps-line-height 'ps-font-for-text)) 3914 (let* ((line-height (ps-line-height 'ps-font-for-text))
3800 (zebra (* line-height ps-zebra-stripe-height))) 3915 (zebra (* (+ line-height ps-line-spacing-internal)
3916 ps-zebra-stripe-height)))
3801 (setq ps-print-height (- (* (floor ps-print-height zebra) zebra) 3917 (setq ps-print-height (- (* (floor ps-print-height zebra) zebra)
3802 line-height)) 3918 line-height))
3803 (if (<= ps-print-height 0) 3919 (if (<= ps-print-height 0)
@@ -3805,11 +3921,13 @@ page-height == bm + print-height + tm - ho - hh
3805ps-zebra-stripe-follow == %s 3921ps-zebra-stripe-follow == %s
3806ps-zebra-stripe-height == %s 3922ps-zebra-stripe-height == %s
3807font-text-height == %s 3923font-text-height == %s
3808page-height == ((floor print-height (th * zh)) * (th * zh)) - th 3924line-spacing == %s
3925page-height == ((floor print-height ((th + ls) * zh)) * ((th + ls) * zh)) - th
3809=> print-height == %d !" 3926=> print-height == %d !"
3810 ps-zebra-stripe-follow 3927 ps-zebra-stripe-follow
3811 ps-zebra-stripe-height 3928 ps-zebra-stripe-height
3812 (ps-line-height 'ps-font-for-text) 3929 (ps-line-height 'ps-font-for-text)
3930 ps-line-spacing-internal
3813 ps-print-height)))))) 3931 ps-print-height))))))
3814 3932
3815(defun ps-print-preprint (prefix-arg) 3933(defun ps-print-preprint (prefix-arg)
@@ -3874,7 +3992,7 @@ page-height == ((floor print-height (th * zh)) * (th * zh)) - th
3874 table) 3992 table)
3875 "Vector used to map characters to PostScript string escape codes.") 3993 "Vector used to map characters to PostScript string escape codes.")
3876 3994
3877(defun ps-output-string-prim (string) 3995(defsubst ps-output-string-prim (string)
3878 (insert "(") ;insert start-string delimiter 3996 (insert "(") ;insert start-string delimiter
3879 (save-excursion ;insert string 3997 (save-excursion ;insert string
3880 (insert (string-as-unibyte string))) 3998 (insert (string-as-unibyte string)))
@@ -3887,7 +4005,7 @@ page-height == ((floor print-height (th * zh)) * (th * zh)) - th
3887 (goto-char (point-max)) 4005 (goto-char (point-max))
3888 (insert ")")) ;insert end-string delimiter 4006 (insert ")")) ;insert end-string delimiter
3889 4007
3890(defun ps-init-output-queue () 4008(defsubst ps-init-output-queue ()
3891 (setq ps-output-head (list "") 4009 (setq ps-output-head (list "")
3892 ps-output-tail ps-output-head)) 4010 ps-output-tail ps-output-head))
3893 4011
@@ -3901,7 +4019,7 @@ page-height == ((floor print-height (th * zh)) * (th * zh)) - th
3901 (< ps-last-page ps-page-postscript))))) 4019 (< ps-last-page ps-page-postscript)))))
3902 4020
3903 4021
3904(defun ps-print-page-p () 4022(defsubst ps-print-page-p ()
3905 (setq ps-print-page-p 4023 (setq ps-print-page-p
3906 (and (cond ((null ps-first-page)) 4024 (and (cond ((null ps-first-page))
3907 ((<= ps-page-postscript ps-last-page) 4025 ((<= ps-page-postscript ps-last-page)
@@ -3920,7 +4038,7 @@ page-height == ((floor print-height (th * zh)) * (th * zh)) - th
3920 )))) 4038 ))))
3921 4039
3922 4040
3923(defun ps-print-sheet-p () 4041(defsubst ps-print-sheet-p ()
3924 (setq ps-print-page-p 4042 (setq ps-print-page-p
3925 (cond ((eq ps-even-or-odd-pages 'even-sheet) 4043 (cond ((eq ps-even-or-odd-pages 'even-sheet)
3926 (= (logand ps-page-sheet 1) 0)) 4044 (= (logand ps-page-sheet 1) 0))
@@ -3980,17 +4098,19 @@ page-height == ((floor print-height (th * zh)) * (th * zh)) - th
3980 ;; Literal strings should be output as is -- the string must 4098 ;; Literal strings should be output as is -- the string must
3981 ;; contain its own PS string delimiters, '(' and ')', if necessary. 4099 ;; contain its own PS string delimiters, '(' and ')', if necessary.
3982 ((stringp content) 4100 ((stringp content)
3983 (ps-output content)) 4101 (ps-output (ps-mule-encode-header-string content fonttag)))
3984 4102
3985 ;; Functions are called -- they should return strings; they will be 4103 ;; Functions are called -- they should return strings; they will be
3986 ;; inserted as strings and the PS string delimiters added. 4104 ;; inserted as strings and the PS string delimiters added.
3987 ((and (symbolp content) (fboundp content)) 4105 ((and (symbolp content) (fboundp content))
3988 (ps-output-string (funcall content))) 4106 (ps-output-string (ps-mule-encode-header-string (funcall content)
4107 fonttag)))
3989 4108
3990 ;; Variables will have their contents inserted. They should 4109 ;; Variables will have their contents inserted. They should
3991 ;; contain strings, and will be inserted as strings. 4110 ;; contain strings, and will be inserted as strings.
3992 ((and (symbolp content) (boundp content)) 4111 ((and (symbolp content) (boundp content))
3993 (ps-output-string (symbol-value content))) 4112 (ps-output-string (ps-mule-encode-header-string (symbol-value content)
4113 fonttag)))
3994 4114
3995 ;; Anything else will get turned into an empty string. 4115 ;; Anything else will get turned into an empty string.
3996 (t 4116 (t
@@ -4651,7 +4771,7 @@ XSTART YSTART are the relative position for the first page in a sheet.")
4651 4771
4652 (ps-output "%%EndComments\n%%BeginDefaults\n%%PageMedia: " 4772 (ps-output "%%EndComments\n%%BeginDefaults\n%%PageMedia: "
4653 (ps-page-dimensions-get-media dimensions) 4773 (ps-page-dimensions-get-media dimensions)
4654 "\n%%EndDefaults\n\n%%BeginPrologue\n\n" 4774 "\n%%EndDefaults\n\n%%BeginProlog\n\n"
4655 "/languagelevel where{pop}{/languagelevel 1 def}ifelse\n" 4775 "/languagelevel where{pop}{/languagelevel 1 def}ifelse\n"
4656 (format "/ErrorMessage %s def\n\n" 4776 (format "/ErrorMessage %s def\n\n"
4657 (or (cdr (assoc ps-error-handler-message 4777 (or (cdr (assoc ps-error-handler-message
@@ -4696,11 +4816,16 @@ XSTART YSTART are the relative position for the first page in a sheet.")
4696 (ps-output-boolean "ShowNofN " ps-show-n-of-n) 4816 (ps-output-boolean "ShowNofN " ps-show-n-of-n)
4697 4817
4698 (let ((line-height (ps-line-height 'ps-font-for-text))) 4818 (let ((line-height (ps-line-height 'ps-font-for-text)))
4699 (ps-output (format "/LineHeight %s def\n" line-height) 4819 (ps-output (format "/LineSpacing %s def\n" ps-line-spacing-internal)
4820 (format "/ParagraphSpacing %s def\n"
4821 ps-paragraph-spacing-internal)
4822 (format "/LineHeight %s def\n" line-height)
4700 (format "/LinesPerColumn %d def\n" 4823 (format "/LinesPerColumn %d def\n"
4701 (round (/ (+ ps-print-height 4824 (let ((height (+ line-height
4702 (* line-height 0.45)) 4825 ps-line-spacing-internal)))
4703 line-height))))) 4826 (round (/ (+ ps-print-height
4827 (* height 0.45))
4828 height))))))
4704 4829
4705 (ps-output-boolean "WarnPaperSize " ps-warn-paper-type) 4830 (ps-output-boolean "WarnPaperSize " ps-warn-paper-type)
4706 (ps-output-boolean "Zebra " ps-zebra-stripes) 4831 (ps-output-boolean "Zebra " ps-zebra-stripes)
@@ -4770,7 +4895,16 @@ XSTART YSTART are the relative position for the first page in a sheet.")
4770 (ps-get-font-size 'ps-line-number-font-size) 4895 (ps-get-font-size 'ps-line-number-font-size)
4771 ps-line-number-font)) 4896 ps-line-number-font))
4772 4897
4773 (ps-output "\n" ps-print-prologue-2 "\n") 4898 (ps-output "\n\n% ---- These lines must be kept together because...
4899
4900/h0 F
4901/HeaderTitleLineHeight FontHeight def
4902
4903/h1 F
4904/HeaderLineHeight FontHeight def
4905/HeaderDescent Descent def
4906
4907% ---- ...because `F' has a side-effect on `FontHeight' and `Descent'\n\n")
4774 4908
4775 ;; Text fonts 4909 ;; Text fonts
4776 (let ((font (ps-font-alist 'ps-font-for-text)) 4910 (let ((font (ps-font-alist 'ps-font-for-text))
@@ -4787,7 +4921,7 @@ XSTART YSTART are the relative position for the first page in a sheet.")
4787 (ps-output (format "/SpaceWidthRatio %f def\n" 4921 (ps-output (format "/SpaceWidthRatio %f def\n"
4788 (/ (ps-lookup 'space-width) (ps-lookup 'size))))) 4922 (/ (ps-lookup 'space-width) (ps-lookup 'size)))))
4789 4923
4790 (ps-output "\n%%EndPrologue\n\n%%BeginSetup\n") 4924 (ps-output "\n%%EndProlog\n\n%%BeginSetup\n")
4791 (unless (eq ps-spool-config 'lpr-switches) 4925 (unless (eq ps-spool-config 'lpr-switches)
4792 (ps-output "\n%%BeginFeature: *Duplex " 4926 (ps-output "\n%%BeginFeature: *Duplex "
4793 (ps-boolean-capitalized ps-spool-duplex) 4927 (ps-boolean-capitalized ps-spool-duplex)
@@ -4864,18 +4998,28 @@ XSTART YSTART are the relative position for the first page in a sheet.")
4864 (and (buffer-modified-p) " (unsaved)"))))) 4998 (and (buffer-modified-p) " (unsaved)")))))
4865 4999
4866 5000
5001(defun ps-get-size (size mess &optional arg)
5002 (let ((siz (cond ((numberp size)
5003 size)
5004 ((and (consp size)
5005 (numberp (car size))
5006 (numberp (cdr size)))
5007 (if ps-landscape-mode
5008 (car size)
5009 (cdr size)))
5010 (t
5011 -1))))
5012 (and (< siz 0)
5013 (error "Invalid %s `%S'%s"
5014 mess size
5015 (if arg
5016 (format " for `%S'" arg)
5017 "")))
5018 siz))
5019
5020
4867(defun ps-get-font-size (font-sym) 5021(defun ps-get-font-size (font-sym)
4868 (let ((font-size (symbol-value font-sym))) 5022 (ps-get-size (symbol-value font-sym) "font size" font-sym))
4869 (cond ((numberp font-size)
4870 font-size)
4871 ((and (consp font-size)
4872 (numberp (car font-size))
4873 (numberp (cdr font-size)))
4874 (if ps-landscape-mode
4875 (car font-size)
4876 (cdr font-size)))
4877 (t
4878 (error "Invalid font size `%S' for `%S'" font-size font-sym)))))
4879 5023
4880 5024
4881(defun ps-begin-job () 5025(defun ps-begin-job ()
@@ -4883,7 +5027,6 @@ XSTART YSTART are the relative position for the first page in a sheet.")
4883 (or (equal ps-mark-code-directory ps-postscript-code-directory) 5027 (or (equal ps-mark-code-directory ps-postscript-code-directory)
4884 (setq ps-print-prologue-0 (ps-prologue-file 0) 5028 (setq ps-print-prologue-0 (ps-prologue-file 0)
4885 ps-print-prologue-1 (ps-prologue-file 1) 5029 ps-print-prologue-1 (ps-prologue-file 1)
4886 ps-print-prologue-2 (ps-prologue-file 2)
4887 ps-mark-code-directory ps-postscript-code-directory)) 5030 ps-mark-code-directory ps-postscript-code-directory))
4888 ;; selected pages 5031 ;; selected pages
4889 (let (new page) 5032 (let (new page)
@@ -4931,6 +5074,10 @@ XSTART YSTART are the relative position for the first page in a sheet.")
4931 ps-lines-printed 0 5074 ps-lines-printed 0
4932 ps-print-page-p t 5075 ps-print-page-p t
4933 ps-showline-count (car ps-printing-region) 5076 ps-showline-count (car ps-printing-region)
5077 ps-line-spacing-internal (ps-get-size ps-line-spacing
5078 "line spacing")
5079 ps-paragraph-spacing-internal (ps-get-size ps-paragraph-spacing
5080 "paragraph spacing")
4934 ps-font-size-internal (ps-get-font-size 'ps-font-size) 5081 ps-font-size-internal (ps-get-font-size 'ps-font-size)
4935 ps-header-font-size-internal (ps-get-font-size 'ps-header-font-size) 5082 ps-header-font-size-internal (ps-get-font-size 'ps-header-font-size)
4936 ps-header-title-font-size-internal 5083 ps-header-title-font-size-internal
@@ -5048,19 +5195,24 @@ XSTART YSTART are the relative position for the first page in a sheet.")
5048 (and (< (point) limit) 5195 (and (< (point) limit)
5049 (forward-char 1))) 5196 (forward-char 1)))
5050 5197
5051(defun ps-next-line () 5198(defsubst ps-next-line ()
5052 (setq ps-showline-count (1+ ps-showline-count) 5199 (setq ps-showline-count (1+ ps-showline-count)
5053 ps-lines-printed (1+ ps-lines-printed)) 5200 ps-lines-printed (1+ ps-lines-printed))
5054 (let ((lh (ps-line-height 'ps-font-for-text))) 5201 (let* ((paragraph-p (and ps-paragraph-regexp
5202 (looking-at ps-paragraph-regexp)))
5203 (lh (+ (ps-line-height 'ps-font-for-text)
5204 (if paragraph-p
5205 ps-paragraph-spacing-internal
5206 ps-line-spacing-internal))))
5055 (if (< ps-height-remaining lh) 5207 (if (< ps-height-remaining lh)
5056 (ps-next-page) 5208 (ps-next-page)
5057 (setq ps-width-remaining ps-print-width 5209 (setq ps-width-remaining ps-print-width
5058 ps-height-remaining (- ps-height-remaining lh)) 5210 ps-height-remaining (- ps-height-remaining lh))
5059 (ps-output "HL\n")))) 5211 (ps-output (if paragraph-p "PHL\n" "LHL\n")))))
5060 5212
5061(defun ps-continue-line () 5213(defun ps-continue-line ()
5062 (setq ps-lines-printed (1+ ps-lines-printed)) 5214 (setq ps-lines-printed (1+ ps-lines-printed))
5063 (let ((lh (ps-line-height 'ps-font-for-text))) 5215 (let ((lh (+ (ps-line-height 'ps-font-for-text) ps-line-spacing-internal)))
5064 (if (< ps-height-remaining lh) 5216 (if (< ps-height-remaining lh)
5065 (ps-next-page) 5217 (ps-next-page)
5066 (setq ps-width-remaining ps-print-width 5218 (setq ps-width-remaining ps-print-width
@@ -5166,6 +5318,15 @@ XSTART YSTART are the relative position for the first page in a sheet.")
5166 ;; ...break the region up into chunks separated by tabs, linefeeds, 5318 ;; ...break the region up into chunks separated by tabs, linefeeds,
5167 ;; pagefeeds, control characters, and plot each chunk. 5319 ;; pagefeeds, control characters, and plot each chunk.
5168 (while (< from to) 5320 (while (< from to)
5321 ;; skip lines between cut markers
5322 (and ps-begin-cut-regexp ps-end-cut-regexp
5323 (looking-at ps-begin-cut-regexp)
5324 (progn
5325 (goto-char (match-end 0))
5326 (and (re-search-forward ps-end-cut-regexp to 'noerror)
5327 (= (following-char) ?\n)
5328 (forward-char 1))
5329 (setq from (point))))
5169 (if (re-search-forward ps-control-or-escape-regexp to t) 5330 (if (re-search-forward ps-control-or-escape-regexp to t)
5170 ;; region with some control characters or some multi-byte characters 5331 ;; region with some control characters or some multi-byte characters
5171 (let* ((match-point (match-beginning 0)) 5332 (let* ((match-point (match-beginning 0))
@@ -5956,7 +6117,7 @@ STRING should contain only ASCII characters.")
5956 "Adjust current font if current charset is not ASCII.") 6117 "Adjust current font if current charset is not ASCII.")
5957 6118
5958(autoload 'ps-mule-plot-string "ps-mule" 6119(autoload 'ps-mule-plot-string "ps-mule"
5959 "Generate PostScript code for ploting characters in the region FROM and TO. 6120 "Generate PostScript code for plotting characters in the region FROM and TO.
5960 6121
5961It is assumed that all characters in this region belong to the same charset. 6122It is assumed that all characters in this region belong to the same charset.
5962 6123
@@ -5979,6 +6140,11 @@ This checks if all multi-byte characters in the region are printable or not.")
5979(autoload 'ps-mule-begin-page "ps-mule" 6140(autoload 'ps-mule-begin-page "ps-mule"
5980 "Initialize multi-byte charset for printing current page.") 6141 "Initialize multi-byte charset for printing current page.")
5981 6142
6143(autoload 'ps-mule-encode-header-string "ps-mule"
6144 "Generate PostScript code for plotting characters in header STRING.
6145
6146It is assumed that the length of STRING is not zero.")
6147
5982 6148
5983;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 6149;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
5984 6150