aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa1999-02-27 01:37:15 +0000
committerKenichi Handa1999-02-27 01:37:15 +0000
commit7d8b7e8e8b75d02adbc30fc6d7aacb3e71ef6438 (patch)
tree23a5e19ddb49837f74957d7aa092240a8d9655fa
parent5e532c5c1f932cf62212b66ad07e28235d4b871d (diff)
downloademacs-7d8b7e8e8b75d02adbc30fc6d7aacb3e71ef6438.tar.gz
emacs-7d8b7e8e8b75d02adbc30fc6d7aacb3e71ef6438.zip
Doc fix, font size specifies landscape and portrait sizes.
(ps-print-version): New version number (4.1.4). (ps-font-size, ps-header-font-size, ps-header-title-font-size): Specifies landscape and portrait sizes. (ps-setup, ps-print-quote, ps-line-lengths-internal, ps-nb-pages) (ps-get-page-dimensions, ps-begin-file, ps-begin-job, ps-generate): Fun fix. (ps-get-font-size): New fun. (ps-font-size-internal, ps-header-font-size-internal) (ps-header-title-font-size-internal): New vars. PostScript programming fix. (ps-print-prologue-1): Fix BeginDoc PostScript procedure (do'nt use setpagedevice operator).
-rw-r--r--lisp/ps-print.el173
1 files changed, 108 insertions, 65 deletions
diff --git a/lisp/ps-print.el b/lisp/ps-print.el
index 1b3f3855d41..9a1d55f2577 100644
--- a/lisp/ps-print.el
+++ b/lisp/ps-print.el
@@ -1,6 +1,6 @@
1;;; ps-print.el --- Print text from the buffer as PostScript 1;;; ps-print.el --- Print text from the buffer as PostScript
2 2
3;; Copyright (C) 1993, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. 3;; Copyright (C) 1993, 94, 95, 96, 97, 98, 1999 Free Software Foundation, Inc.
4 4
5;; Author: Jim Thompson (was <thompson@wg2.waii.com>) 5;; Author: Jim Thompson (was <thompson@wg2.waii.com>)
6;; Author: Jacques Duthen (was <duthen@cegelec-red.fr>) 6;; Author: Jacques Duthen (was <duthen@cegelec-red.fr>)
@@ -9,11 +9,11 @@
9;; Maintainer: Kenichi Handa <handa@etl.go.jp> (multi-byte characters) 9;; Maintainer: Kenichi Handa <handa@etl.go.jp> (multi-byte characters)
10;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br> 10;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br>
11;; Keywords: print, PostScript 11;; Keywords: print, PostScript
12;; Time-stamp: <98/11/23 15:02:20 vinicius> 12;; Time-stamp: <99/02/19 11:47:32 vinicius>
13;; Version: 4.1.3 13;; Version: 4.1.4
14 14
15(defconst ps-print-version "4.1.3" 15(defconst ps-print-version "4.1.4"
16 "ps-print.el, v 4.1.3 <98/11/23 vinicius> 16 "ps-print.el, v 4.1.4 <99/02/19 vinicius>
17 17
18Vinicius's last change version -- this file may have been edited as part of 18Vinicius's last change version -- this file may have been edited as part of
19Emacs without changes to the version number. When reporting bugs, 19Emacs without changes to the version number. When reporting bugs,
@@ -501,30 +501,32 @@ Please send all bug fixes and enhancements to
501;; Font Managing 501;; Font Managing
502;; ------------- 502;; -------------
503;; 503;;
504;; ps-print now knows rather precisely some fonts: 504;; ps-print now knows rather precisely some fonts: the variable
505;; the variable `ps-font-info-database' contains information 505;; `ps-font-info-database' contains information for a list of font families
506;; for a list of font families (currently mainly `Courier' `Helvetica' 506;; (currently mainly `Courier' `Helvetica' `Times' `Palatino' `Helvetica-Narrow'
507;; `Times' `Palatino' `Helvetica-Narrow' `NewCenturySchlbk'). 507;; `NewCenturySchlbk'). Each font family contains the font names for standard,
508;; Each font family contains the font names for standard, bold, italic 508;; bold, italic and bold-italic characters, a reference size (usually 10) and
509;; and bold-italic characters, a reference size (usually 10) and the 509;; the corresponding line height, width of a space and average character width.
510;; corresponding line height, width of a space and average character width.
511;; 510;;
512;; The variable `ps-font-family' determines which font family 511;; The variable `ps-font-family' determines which font family is to be used for
513;; is to be used for ordinary text. 512;; ordinary text. If its value does not correspond to a known font family, an
514;; If its value does not correspond to a known font family, 513;; error message is printed into the `*Messages*' buffer, which lists the
515;; an error message is printed into the `*Messages*' buffer, 514;; currently available font families.
516;; which lists the currently available font families.
517;; 515;;
518;; The variable `ps-font-size' determines the size (in points) 516;; The variable `ps-font-size' determines the size (in points) of the font for
519;; of the font for ordinary text, when generating PostScript. 517;; ordinary text, when generating PostScript. Its value is a float or a cons of
520;; Its value is a float. 518;; floats which has the following form:
521;; 519;;
522;; Similarly, the variable `ps-header-font-family' determines 520;; (LANDSCAPE-SIZE . PORTRAIT-SIZE)
523;; which font family is to be used for text in the header. 521;;
524;; The variable `ps-header-font-size' determines the font size, 522;; Similarly, the variable `ps-header-font-family' determines which font family
525;; in points, for text in the header. 523;; is to be used for text in the header.
526;; The variable `ps-header-title-font-size' determines the font size, 524;;
527;; in points, for the top line of text in the header. 525;; The variable `ps-header-font-size' determines the font size, in points, for
526;; text in the header (similar to `ps-font-size').
527;;
528;; The variable `ps-header-title-font-size' determines the font size, in points,
529;; for the top line of text in the header (similar to `ps-font-size').
528;; 530;;
529;; 531;;
530;; Adding a New Font Family 532;; Adding a New Font Family
@@ -1525,9 +1527,12 @@ You can get all the fonts of YOUR printer using `ReportAllFontInfo'."
1525 :type 'symbol 1527 :type 'symbol
1526 :group 'ps-print-font) 1528 :group 'ps-print-font)
1527 1529
1528(defcustom ps-font-size (if ps-landscape-mode 7 8.5) 1530(defcustom ps-font-size '(7 . 8.5)
1529 "*Font size, in points, for ordinary text, when generating PostScript." 1531 "*Font size, in points, for ordinary text, when generating PostScript."
1530 :type 'number 1532 :type '(choice (number :tag "Text Size")
1533 (cons :tag "Landscape/Portrait"
1534 (number :tag "Landscape Text Size")
1535 (number :tag "Portrait Text Size")))
1531 :group 'ps-print-font) 1536 :group 'ps-print-font)
1532 1537
1533(defcustom ps-header-font-family 'Helvetica 1538(defcustom ps-header-font-family 'Helvetica
@@ -1535,14 +1540,20 @@ You can get all the fonts of YOUR printer using `ReportAllFontInfo'."
1535 :type 'symbol 1540 :type 'symbol
1536 :group 'ps-print-font) 1541 :group 'ps-print-font)
1537 1542
1538(defcustom ps-header-font-size (if ps-landscape-mode 10 12) 1543(defcustom ps-header-font-size '(10 . 12)
1539 "*Font size, in points, for text in the header, when generating PostScript." 1544 "*Font size, in points, for text in the header, when generating PostScript."
1540 :type 'number 1545 :type '(choice (number :tag "Header Size")
1546 (cons :tag "Landscape/Portrait"
1547 (number :tag "Landscape Header Size")
1548 (number :tag "Portrait Header Size")))
1541 :group 'ps-print-font) 1549 :group 'ps-print-font)
1542 1550
1543(defcustom ps-header-title-font-size (if ps-landscape-mode 12 14) 1551(defcustom ps-header-title-font-size '(12 . 14)
1544 "*Font size, in points, for the top line of text in header, in PostScript." 1552 "*Font size, in points, for the top line of text in header, in PostScript."
1545 :type 'number 1553 :type '(choice (number :tag "Header Title Size")
1554 (cons :tag "Landscape/Portrait"
1555 (number :tag "Landscape Header Title Size")
1556 (number :tag "Portrait Header Title Size")))
1546 :group 'ps-print-font) 1557 :group 'ps-print-font)
1547 1558
1548;;; Colors 1559;;; Colors
@@ -1807,10 +1818,10 @@ The table depends on the current ps-print setup."
1807 " 1818 "
1808\(setq ps-print-color-p %s 1819\(setq ps-print-color-p %s
1809 ps-lpr-command %S 1820 ps-lpr-command %S
1810 ps-lpr-switches %S 1821 ps-lpr-switches %s
1811 ps-printer-name %S 1822 ps-printer-name %S
1812 1823
1813 ps-paper-type %S 1824 ps-paper-type %s
1814 ps-landscape-mode %s 1825 ps-landscape-mode %s
1815 ps-number-of-columns %s 1826 ps-number-of-columns %s
1816 1827
@@ -1818,13 +1829,13 @@ The table depends on the current ps-print setup."
1818 ps-zebra-stripe-height %s 1829 ps-zebra-stripe-height %s
1819 ps-line-number %s 1830 ps-line-number %s
1820 1831
1821 ps-print-control-characters %S 1832 ps-print-control-characters %s
1822 1833
1823 ps-print-background-image %S 1834 ps-print-background-image %s
1824 1835
1825 ps-print-background-text %S 1836 ps-print-background-text %s
1826 1837
1827 ps-print-prologue-header %S 1838 ps-print-prologue-header %s
1828 1839
1829 ps-left-margin %s 1840 ps-left-margin %s
1830 ps-right-margin %s 1841 ps-right-margin %s
@@ -1840,10 +1851,10 @@ The table depends on the current ps-print setup."
1840 ps-show-n-of-n %s 1851 ps-show-n-of-n %s
1841 ps-spool-duplex %s 1852 ps-spool-duplex %s
1842 1853
1843 ps-multibyte-buffer %S 1854 ps-multibyte-buffer %s
1844 ps-font-family %S 1855 ps-font-family %s
1845 ps-font-size %s 1856 ps-font-size %s
1846 ps-header-font-family %S 1857 ps-header-font-family %s
1847 ps-header-font-size %s 1858 ps-header-font-size %s
1848 ps-header-title-font-size %s) 1859 ps-header-title-font-size %s)
1849" 1860"
@@ -1876,18 +1887,22 @@ The table depends on the current ps-print setup."
1876 ps-spool-duplex 1887 ps-spool-duplex
1877 (ps-print-quote ps-multibyte-buffer) ; see `ps-mule.el' 1888 (ps-print-quote ps-multibyte-buffer) ; see `ps-mule.el'
1878 (ps-print-quote ps-font-family) 1889 (ps-print-quote ps-font-family)
1879 ps-font-size 1890 (ps-print-quote ps-font-size)
1880 (ps-print-quote ps-header-font-family) 1891 (ps-print-quote ps-header-font-family)
1881 ps-header-font-size 1892 (ps-print-quote ps-header-font-size)
1882 ps-header-title-font-size)) 1893 (ps-print-quote ps-header-title-font-size)))
1883 1894
1884;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1895;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1885;; Utility functions and variables: 1896;; Utility functions and variables:
1886 1897
1887(defun ps-print-quote (sym) 1898(defun ps-print-quote (sym)
1888 (and sym 1899 (cond ((null sym)
1889 (if (or (symbolp sym) (listp sym)) 1900 nil)
1890 (format "'%S" sym) 1901 ((or (symbolp sym) (listp sym))
1902 (format "'%S" sym))
1903 ((stringp sym)
1904 (format "%S" sym))
1905 (t
1891 sym))) 1906 sym)))
1892 1907
1893(defvar ps-print-emacs-type 1908(defvar ps-print-emacs-type
@@ -2314,19 +2329,19 @@ StandardEncoding 46 82 getinterval aload pop
2314 % ---- [jack] Kludge: my ghostscript window is 21x27.7 instead of 21x29.7 2329 % ---- [jack] Kludge: my ghostscript window is 21x27.7 instead of 21x29.7
2315 /JackGhostscript where {pop 1 27.7 29.7 div scale}if 2330 /JackGhostscript where {pop 1 27.7 29.7 div scale}if
2316 % ---- [andrewi] set PageSize based on chosen dimensions 2331 % ---- [andrewi] set PageSize based on chosen dimensions
2317 /setpagedevice where { 2332% /setpagedevice where {
2318 pop 2333% pop
2319 1 dict dup 2334% 1 dict dup
2320 /PageSize [ PrintPageWidth LeftMargin add RightMargin add 2335% /PageSize [ PrintPageWidth LeftMargin add RightMargin add
2321 LandscapePageHeight ] put 2336% LandscapePageHeight ] put
2322 setpagedevice 2337% setpagedevice
2323 }{ 2338% }{
2324 LandscapeMode { 2339 LandscapeMode {
2325 % ---- translate to bottom-right corner of Portrait page 2340 % ---- translate to bottom-right corner of Portrait page
2326 LandscapePageHeight 0 translate 2341 LandscapePageHeight 0 translate
2327 90 rotate 2342 90 rotate
2328 }if 2343 }if
2329 }ifelse 2344% }ifelse
2330 /ColumnWidth PrintWidth InterColumn add def 2345 /ColumnWidth PrintWidth InterColumn add def
2331 % ---- translate to lower left corner of TEXT 2346 % ---- translate to lower left corner of TEXT
2332 LeftMargin BottomMargin translate 2347 LeftMargin BottomMargin translate
@@ -2620,6 +2635,10 @@ This is in units of points (1/72 inch).")
2620 2635
2621(defvar ps-print-color-scale nil) 2636(defvar ps-print-color-scale nil)
2622 2637
2638(defvar ps-font-size-internal nil)
2639(defvar ps-header-font-size-internal nil)
2640(defvar ps-header-title-font-size-internal nil)
2641
2623 2642
2624;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2643;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2625;; Internal Variables 2644;; Internal Variables
@@ -2892,7 +2911,7 @@ which long lines wrap around."
2892using the current ps-print setup. 2911using the current ps-print setup.
2893Try: pr -t file | awk '{printf \"%3d %s\n\", length($0), $0}' | sort -r | head" 2912Try: pr -t file | awk '{printf \"%3d %s\n\", length($0), $0}' | sort -r | head"
2894 (let ((buf (get-buffer-create "*Line-lengths*")) 2913 (let ((buf (get-buffer-create "*Line-lengths*"))
2895 (ifs ps-font-size) ; initial font size 2914 (ifs ps-font-size-internal) ; initial font size
2896 (icw (ps-avg-char-width 'ps-font-for-text)) ; initial character width 2915 (icw (ps-avg-char-width 'ps-font-for-text)) ; initial character width
2897 (print-width (progn (ps-get-page-dimensions) 2916 (print-width (progn (ps-get-page-dimensions)
2898 ps-print-width)) 2917 ps-print-width))
@@ -2930,7 +2949,7 @@ Try: pr -t file | awk '{printf \"%3d %s\n\", length($0), $0}' | sort -r | head"
2930The correspondence is based on having NB-LINES lines of text, 2949The correspondence is based on having NB-LINES lines of text,
2931and on the current ps-print setup." 2950and on the current ps-print setup."
2932 (let ((buf (get-buffer-create "*Nb-Pages*")) 2951 (let ((buf (get-buffer-create "*Nb-Pages*"))
2933 (ifs ps-font-size) ; initial font size 2952 (ifs ps-font-size-internal) ; initial font size
2934 (ilh (ps-line-height 'ps-font-for-text)) ; initial line height 2953 (ilh (ps-line-height 'ps-font-for-text)) ; initial line height
2935 (page-height (progn (ps-get-page-dimensions) 2954 (page-height (progn (ps-get-page-dimensions)
2936 ps-print-height)) 2955 ps-print-height))
@@ -3000,9 +3019,10 @@ and on the current ps-print setup."
3000 ps-number-of-columns))) 3019 ps-number-of-columns)))
3001 3020
3002 (ps-select-font ps-font-family 'ps-font-for-text 3021 (ps-select-font ps-font-family 'ps-font-for-text
3003 ps-font-size ps-font-size) 3022 ps-font-size-internal ps-font-size-internal)
3004 (ps-select-font ps-header-font-family 'ps-font-for-header 3023 (ps-select-font ps-header-font-family 'ps-font-for-header
3005 ps-header-font-size ps-header-title-font-size) 3024 ps-header-font-size-internal
3025 ps-header-title-font-size-internal)
3006 3026
3007 (setq page-width (ps-page-dimensions-get-width page-dimensions) 3027 (setq page-width (ps-page-dimensions-get-width page-dimensions)
3008 page-height (ps-page-dimensions-get-height page-dimensions)) 3028 page-height (ps-page-dimensions-get-height page-dimensions))
@@ -3481,11 +3501,11 @@ page-height == bm + print-height + tm - ho - hh
3481 3501
3482 ;; Header fonts 3502 ;; Header fonts
3483 (ps-output (format "/h0 %s (%s) cvn DefFont\n" ; /h0 14 /Helvetica-Bold DefFont 3503 (ps-output (format "/h0 %s (%s) cvn DefFont\n" ; /h0 14 /Helvetica-Bold DefFont
3484 ps-header-title-font-size (ps-font 'ps-font-for-header 3504 ps-header-title-font-size-internal
3485 'bold)) 3505 (ps-font 'ps-font-for-header 'bold))
3486 (format "/h1 %s (%s) cvn DefFont\n" ; /h1 12 /Helvetica DefFont 3506 (format "/h1 %s (%s) cvn DefFont\n" ; /h1 12 /Helvetica DefFont
3487 ps-header-font-size (ps-font 'ps-font-for-header 3507 ps-header-font-size-internal
3488 'normal))) 3508 (ps-font 'ps-font-for-header 'normal)))
3489 3509
3490 (ps-output ps-print-prologue-2) 3510 (ps-output ps-print-prologue-2)
3491 3511
@@ -3495,7 +3515,7 @@ page-height == bm + print-height + tm - ho - hh
3495 (while font 3515 (while font
3496 (ps-output (format "/f%d %s (%s) cvn DefFont\n" 3516 (ps-output (format "/f%d %s (%s) cvn DefFont\n"
3497 i 3517 i
3498 ps-font-size 3518 ps-font-size-internal
3499 (ps-font 'ps-font-for-text (car (car font))))) 3519 (ps-font 'ps-font-for-text (car (car font)))))
3500 (setq font (cdr font) 3520 (setq font (cdr font)
3501 i (1+ i)))) 3521 i (1+ i))))
@@ -3527,6 +3547,21 @@ page-height == bm + print-height + tm - ho - hh
3527 (buffer-name) 3547 (buffer-name)
3528 (and (buffer-modified-p) " (unsaved)"))))) 3548 (and (buffer-modified-p) " (unsaved)")))))
3529 3549
3550
3551(defun ps-get-font-size (font-sym)
3552 (let ((font-size (symbol-value font-sym)))
3553 (cond ((numberp font-size)
3554 font-size)
3555 ((and (consp font-size)
3556 (numberp (car font-size))
3557 (numberp (cdr font-size)))
3558 (if ps-landscape-mode
3559 (car font-size)
3560 (cdr font-size)))
3561 (t
3562 (error "Invalid font size `%S' for `%S'" font-size font-sym)))))
3563
3564
3530(defun ps-begin-job () 3565(defun ps-begin-job ()
3531 (save-excursion 3566 (save-excursion
3532 (set-buffer ps-spool-buffer) 3567 (set-buffer ps-spool-buffer)
@@ -3535,6 +3570,10 @@ page-height == bm + print-height + tm - ho - hh
3535 (delete-region (match-beginning 0) (point-max)))) 3570 (delete-region (match-beginning 0) (point-max))))
3536 (setq ps-showline-count (if ps-printing-region (car ps-printing-region) 1) 3571 (setq ps-showline-count (if ps-printing-region (car ps-printing-region) 1)
3537 ps-page-count 0 3572 ps-page-count 0
3573 ps-font-size-internal (ps-get-font-size 'ps-font-size)
3574 ps-header-font-size-internal (ps-get-font-size 'ps-header-font-size)
3575 ps-header-title-font-size-internal
3576 (ps-get-font-size 'ps-header-title-font-size)
3538 ps-control-or-escape-regexp 3577 ps-control-or-escape-regexp
3539 (cond ((eq ps-print-control-characters '8-bit) 3578 (cond ((eq ps-print-control-characters '8-bit)
3540 (string-as-unibyte "[\000-\037\177-\377]")) 3579 (string-as-unibyte "[\000-\037\177-\377]"))
@@ -4169,10 +4208,10 @@ If FACE is not a valid face name, it is used default face."
4169 (setq needs-begin-file t)) 4208 (setq needs-begin-file t))
4170 (save-excursion 4209 (save-excursion
4171 (set-buffer ps-source-buffer) 4210 (set-buffer ps-source-buffer)
4211 (ps-begin-job)
4172 (when needs-begin-file 4212 (when needs-begin-file
4173 (ps-begin-file) 4213 (ps-begin-file)
4174 (ps-mule-initialize)) 4214 (ps-mule-initialize))
4175 (ps-begin-job)
4176 (ps-mule-begin-job from to) 4215 (ps-mule-begin-job from to)
4177 (ps-begin-page)) 4216 (ps-begin-page))
4178 (set-buffer ps-source-buffer) 4217 (set-buffer ps-source-buffer)
@@ -4214,6 +4253,10 @@ If FACE is not a valid face name, it is used default face."
4214 (and ps-razzle-dazzle (message "Formatting...done")))))) 4253 (and ps-razzle-dazzle (message "Formatting...done"))))))
4215 4254
4216 4255
4256;; to avoid compilation gripes.
4257(defvar dos-ps-printer nil)
4258
4259
4217;; Permit dynamic evaluation at print time of `ps-lpr-switches'. 4260;; Permit dynamic evaluation at print time of `ps-lpr-switches'.
4218(defun ps-do-despool (filename) 4261(defun ps-do-despool (filename)
4219 (if (or (not (boundp 'ps-spool-buffer)) 4262 (if (or (not (boundp 'ps-spool-buffer))