]> code.delx.au - gnu-emacs/blobdiff - lisp/ps-print.el
(flyspell-mode-on): fix kill-buffer-hook
[gnu-emacs] / lisp / ps-print.el
index 0ded650e1eac7d2d9ad9bcf5518b7cd345cac225..a44cfbee23558cdd21c842865e2f7c0c2406585e 100644 (file)
@@ -502,7 +502,7 @@ Please send all bug fixes and enhancements to
 ;; which lists the currently available font families.
 ;;
 ;; The variable `ps-font-size' determines the size (in points)
-;; of the font for ordinary text, when generating Postscript.
+;; of the font for ordinary text, when generating PostScript.
 ;; Its value is a float.
 ;;
 ;; Similarly, the variable `ps-header-font-family' determines
@@ -852,11 +852,17 @@ Please send all bug fixes and enhancements to
 ;; Acknowledgements
 ;; ----------------
 ;;
+;; Thanks to Kein'ichi Handa <handa@etl.go.jp> for multi-byte buffer handling.
+;;
+;; Thanks to Matthew O Persico <Matthew.Persico@lazard.com> for line number on
+;; empty columns.
+;;
+;; Thanks to Theodore Jump <tjump@cais.com> for adjust PostScript code order on
+;; last page.
+;;
 ;; Thanks to Roland Ducournau <ducour@lirmm.fr> for
 ;; `ps-print-control-characters' variable documentation.
 ;;
-;; Thanks to Kein'ichi Handa <handa@etl.go.jp> for multi-byte buffer handling.
-;;
 ;; Thanks to Marcus G Daniels <marcus@cathcart.sysc.pdx.edu> for a better
 ;; database font management.
 ;;
@@ -1053,7 +1059,7 @@ example `letter', `legal' or `a4'."
 (defcustom ps-print-control-characters 'control-8-bit
   "*Specifies the printable form for control and 8-bit characters.
 That is, instead of sending, for example, a ^D (\004) to printer,
-you can send ^ and D.
+it is sent the string \"^D\".
 
 Valid values are:
 
@@ -2792,7 +2798,7 @@ which long lines wrap around."
 ;; Maintainer: Kenichi Handa <handa@etl.go.jp>
 
 (eval-and-compile
-  (if (fboundp 'set-buffer-multibyte)
+  (if (not (string< mule-version "4.0"))
       (progn
        (defalias 'ps-mule-next-point '1+)
        (defalias 'ps-mule-chars-in-string 'length)
@@ -2875,16 +2881,16 @@ See also the variable `ps-font-info-database'.")
 Currently, data for Japanese and Korean PostScript printers are listed.")
 
 (defconst ps-mule-font-info-database-bdf
-  '(;;(ascii
-    ;; (normal bdf "etl24-latin1.bdf" nil 1)
-    ;; (bold bdf "etl16b-latin1.bdf" iso-latin-1 1)
-    ;; (italic bdf "etl16i-latin1.bdf" iso-latin-1 1)
-    ;; (bold-italic bdf "etl16bi-latin1.bdf" iso-latin-1 1))
-    ;;(latin-iso8859-1
-    ;; (normal bdf "etl24-latin1.bdf" iso-latin-1 1)
-    ;; (bold bdf "etl16b-latin1.bdf" iso-latin-1 1)
-    ;; (italic bdf "etl16i-latin1.bdf" iso-latin-1 1)
-    ;; (bold-italic bdf "etl16bi-latin1.bdf" iso-latin-1 1))
+  '((ascii
+     (normal bdf "etl24-latin1.bdf" nil 1)
+     (bold bdf "etl16b-latin1.bdf" iso-latin-1 1)
+     (italic bdf "etl16i-latin1.bdf" iso-latin-1 1)
+     (bold-italic bdf "etl16bi-latin1.bdf" iso-latin-1 1))
+    (latin-iso8859-1
+     (normal bdf "etl24-latin1.bdf" iso-latin-1 1)
+     (bold bdf "etl16b-latin1.bdf" iso-latin-1 1)
+     (italic bdf "etl16i-latin1.bdf" iso-latin-1 1)
+     (bold-italic bdf "etl16bi-latin1.bdf" iso-latin-1 1))
     (latin-iso8859-1
      (normal nil nil iso-latin-1))
     (latin-iso8859-2
@@ -2966,10 +2972,31 @@ Currently, data for Japanese and Korean PostScript printers are listed.")
     (tibetan
      (normal bdf "mule-tibmdx-24.bdf" ps-mule-encode-7bit 2)))
   "Sample setting of the `ps-mule-font-info-database' to use BDF fonts.
+BDF (Bitmap Distribution Format) is a format used for distributing
+X's font source file.
+
+Current default value lists BDF fonts included in `intlfonts-1.1'
+which is a collection of X11 fonts for all characters supported by
+Emacs.
+
+With the default value, all characters including ASCII and Latin-1 are
+printed by BDF fonts.   See also `ps-mule-font-info-database-ps-bdf'.")
+
+(defconst ps-mule-font-info-database-ps-bdf
+  (cons '(latin-iso8859-1
+         (normal nil nil iso-latin-1))
+       (cdr (cdr ps-mule-font-info-database-bdf)))
+  "Sample setting of the `ps-mule-font-info-database to use BDF fonts.
 
 Current default value lists BDF fonts included in `intlfonts-1.1'
 which is a collection of X11 fonts for all characters supported by
-Emacs.")
+Emacs.
+
+With the default value, all characters except for ASCII and Latin-1 are
+printed by BDF fonts.   ASCII and Latin-1 charcaters are printed by
+PostScript font specified by `ps-font-family'.
+
+See also `ps-mule-font-info-database-bdf'.")
 
 ;; Two typical encoding functions for PostScript fonts.
 
@@ -3015,19 +3042,19 @@ Emacs.")
 ;; Special encoding function for Ethiopic.
 (define-ccl-program ccl-encode-ethio-unicode
   `(1
-    (read r2)
-    (loop
-     (if (r2 == ,leading-code-private-22)
-        ((read r0)
-         (if (r0 == ,(charset-id 'ethiopic))
-             ((read r1 r2)
-              (r1 &= 127) (r2 &= 127)
-              (call ccl-encode-ethio-font)
-              (write r1)
-              (write-read-repeat r2))
-           ((write r2 r0)
-            (repeat))))
-       (write-read-repeat r2)))))
+    ((read r2)
+     (loop
+      (if (r2 == ,leading-code-private-22)
+         ((read r0)
+          (if (r0 == ,(charset-id 'ethiopic))
+              ((read r1 r2)
+               (r1 &= 127) (r2 &= 127)
+               (call ccl-encode-ethio-font)
+               (write r1)
+               (write-read-repeat r2))
+            ((write r2 r0)
+             (repeat))))
+       (write-read-repeat r2))))))
 
 (defun ps-mule-encode-ethiopic (string)
   (ccl-execute-on-string (symbol-value 'ccl-encode-ethio-unicode)
@@ -3124,7 +3151,7 @@ each element of the list."
            (format "f%02x-%d"
                    (charset-id charset) ps-current-font))))
     (if (and func (not font-cache))
-       (ps-output-prologue (funcall func font-spec)))
+       (ps-output-prologue (funcall func charset font-spec)))
     (ps-output-prologue
      (list (format "/%s %f /%s Def%sFontMule\n"
                   scaled-font-name ps-font-size font-name
@@ -3578,6 +3605,7 @@ NewBitmapDict
        0 0 setcharwidth
     } {
        1 index /FontSize get /size exch def
+       1 index /FontSpaceWidthRatio get /ratio exch def
        1 index /FontIndex get exch FirstCode exch
        GlobalCharName GetBitmap /bmp exch def
        %% bmp == [ DWIDTH BBX-WIDTH BBX-HEIGHT BBX-XOFF BBX-YOFF BITMAP ]
@@ -3592,7 +3620,7 @@ NewBitmapDict
        } ifelse
        /FirstCode -1 store
 
-       bmp 0 get size div 0            % wx wy
+       bmp 0 get SpaceWidthRatio ratio div mul size div 0      % wx wy
        setcharwidth                    % We can't use setcachedevice here.
 
        bmp 1 get 0 gt bmp 2 get 0 gt and {
@@ -3625,14 +3653,16 @@ NewBitmapDict
 
 /GlobalFontIndex 0 def
 
-%% fontname dimension fontsize relative-compose baseline-offset fbbx  |-  --
+%% fontname dim col fontsize relative-compose baseline-offset fbbx  |-  --
 /BitmapFont {
-    14 dict begin
+    15 dict begin
     /FontBBox exch def
     /BaselineOffset exch def
     /RelativeCompose exch def
     /FontSize exch def
     /FontBBox [ FontBBox { FontSize div } forall ] def
+    FontBBox 2 get FontBBox 0 get sub exch div
+    /FontSpaceWidthRatio exch def
     /FontDimension exch def
     /FontIndex GlobalFontIndex def
     /FontType 3 def
@@ -3646,7 +3676,7 @@ NewBitmapDict
 } bind def
 
 %% Define a new bitmap font.
-%% fontname dimension fontsize relative-compose baseline-offset fbbx  |-  --
+%% fontname dim col fontsize relative-compose baseline-offset fbbx  |-  --
 /NF {
     /fbbx exch def
     %% Convert BDF's FontBoundingBox to PostScript's FontBBox
@@ -3679,7 +3709,7 @@ NewBitmapDict
     (list ps-mule-bitmap-prologue)))
 
 (defun ps-mule-generate-bitmap-font (&rest args)
-  (list (apply 'format "/%s %d %f %S %d %S NF\n" args)))
+  (list (apply 'format "/%s %d %d %f %S %d %S NF\n" args)))
 
 (defun ps-mule-generate-bitmap-glyph (font-name code dwidth bbx bitmap)
   (format "/%s %d [ %d %d %d %d %d <%s> ] NG\n"
@@ -4004,8 +4034,7 @@ page-height == bm + print-height + tm - ho - hh
   (save-excursion                      ;insert string
     (insert (string-as-unibyte string)))
   ;; Find and quote special characters as necessary for PS
-  ;; This skips everything except control chars, nonascii chars,
-  ;; (, ) and \.
+  ;; This skips everything except control chars, nonascii chars, (, ) and \.
   (while (progn (skip-chars-forward " -'*-[]-~") (not (eobp)))
     (let ((special (following-char)))
       (delete-char 1)
@@ -4350,6 +4379,10 @@ page-height == bm + print-height + tm - ho - hh
       (setq font (cdr font)
            i (1+ i))))
 
+  (let ((font-entry (cdr (assq ps-font-family ps-font-info-database))))
+    (ps-output (format "/SpaceWidthRatio %f def\n"
+                      (/ (ps-lookup 'space-width) (ps-lookup 'size)))))
+
   (ps-mule-initialize)
 
   (ps-output "\nBeginDoc\n\n"
@@ -4598,7 +4631,7 @@ EndDSCPage\n"))
              (ps-plot 'ps-basic-plot-string from match-point bg-color))
            (cond
             ((= match ?\t)             ; tab
-             (let ((linestart (save-excursion (beginning-of-line) (point))))
+             (let ((linestart (line-beginning-position)))
                (forward-char -1)
                (setq from (+ linestart (current-column)))
                (when (re-search-forward "[ \t]+" to t)
@@ -5024,6 +5057,7 @@ If FACE is not a valid face name, it is used default face."
              (progn
                (set-buffer ps-spool-buffer)
                (set-buffer-multibyte nil)
+
                ;; Get a marker and make it point to the current end of the
                ;; buffer,  If an error occurs, we'll delete everything from
                ;; the end of this marker onwards.
@@ -5100,10 +5134,9 @@ If FACE is not a valid face name, it is used default face."
        (let* ((coding-system-for-write 'raw-text-unix)
               (ps-printer-name (or ps-printer-name printer-name))
               (ps-lpr-switches
-               (append
-                (and (stringp ps-printer-name)
-                     (list (concat "-P" ps-printer-name)))
-                ps-lpr-switches)))
+               (append (and (stringp ps-printer-name)
+                            (list (concat "-P" ps-printer-name)))
+                       ps-lpr-switches)))
          (if (and (memq system-type '(ms-dos windows-nt))
                   (or (stringp dos-ps-printer)
                       (stringp ps-printer-name)))