diff options
| -rw-r--r-- | lisp/ps-mule.el | 190 |
1 files changed, 113 insertions, 77 deletions
diff --git a/lisp/ps-mule.el b/lisp/ps-mule.el index d4ca6e8b5c0..fd79d32a3a4 100644 --- a/lisp/ps-mule.el +++ b/lisp/ps-mule.el | |||
| @@ -1,13 +1,13 @@ | |||
| 1 | ;;; ps-mule.el --- Provide multi-byte character facility to ps-print. | 1 | ;;; ps-mule.el --- Provide multi-byte character facility to ps-print. |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1998 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1998, 1999 Free Software Foundation, Inc. |
| 4 | 4 | ||
| 5 | ;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br> | 5 | ;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br> |
| 6 | ;; Author: Kenichi Handa <handa@etl.go.jp> (multi-byte characters) | 6 | ;; Author: Kenichi Handa <handa@etl.go.jp> (multi-byte characters) |
| 7 | ;; Maintainer: Kenichi Handa <handa@etl.go.jp> (multi-byte characters) | 7 | ;; Maintainer: Kenichi Handa <handa@etl.go.jp> (multi-byte characters) |
| 8 | ;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br> | 8 | ;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br> |
| 9 | ;; Keywords: print, PostScript, multibyte, mule | 9 | ;; Keywords: wp, print, PostScript, multibyte, mule |
| 10 | ;; Time-stamp: <99/02/19 13:15:52 vinicius> | 10 | ;; Time-stamp: <99/06/24 23:07:11 vinicius> |
| 11 | 11 | ||
| 12 | ;; This file is part of GNU Emacs. | 12 | ;; This file is part of GNU Emacs. |
| 13 | 13 | ||
| @@ -28,7 +28,7 @@ | |||
| 28 | 28 | ||
| 29 | ;;; Commentary: | 29 | ;;; Commentary: |
| 30 | 30 | ||
| 31 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 31 | ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 32 | ;; | 32 | ;; |
| 33 | ;; About ps-mule | 33 | ;; About ps-mule |
| 34 | ;; ------------- | 34 | ;; ------------- |
| @@ -46,8 +46,14 @@ | |||
| 46 | ;; | 46 | ;; |
| 47 | ;; Valid values for `ps-multibyte-buffer' are: | 47 | ;; Valid values for `ps-multibyte-buffer' are: |
| 48 | ;; | 48 | ;; |
| 49 | ;; nil This is the value to use when you are printing | 49 | ;; nil This is the value to use the default settings which |
| 50 | ;; buffer with only ASCII and Latin characters. | 50 | ;; is by default for printing buffer with only ASCII |
| 51 | ;; and Latin characters. The default setting can be | ||
| 52 | ;; changed by setting the variable | ||
| 53 | ;; `ps-mule-font-info-database-default' differently. | ||
| 54 | ;; The initial value of this variable is | ||
| 55 | ;; `ps-mule-font-info-database-latin' (see | ||
| 56 | ;; documentation). | ||
| 51 | ;; | 57 | ;; |
| 52 | ;; `non-latin-printer' This is the value to use when you have a japanese | 58 | ;; `non-latin-printer' This is the value to use when you have a japanese |
| 53 | ;; or korean PostScript printer and want to print | 59 | ;; or korean PostScript printer and want to print |
| @@ -80,61 +86,70 @@ | |||
| 80 | ;; | 86 | ;; |
| 81 | ;; The default is nil. | 87 | ;; The default is nil. |
| 82 | ;; | 88 | ;; |
| 83 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 89 | ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 84 | 90 | ||
| 85 | ;;; Code: | 91 | ;;; Code: |
| 86 | 92 | ||
| 87 | (eval-and-compile (require 'ps-print)) | 93 | (eval-and-compile (require 'ps-print)) |
| 88 | 94 | ||
| 89 | ;;;###autoload | 95 | |
| 90 | (defcustom ps-multibyte-buffer nil | 96 | (require 'ps-print-def) ; Common definitions |
| 91 | "*Specifies the multi-byte buffer handling. | 97 | |
| 92 | 98 | ||
| 93 | Valid values are: | 99 | ;;;; `ps-multibyte-buffer' definition should be placed in `ps-mule' but due to |
| 94 | 100 | ;;;; compilation and customization gripes it was moved to `ps-print-def'. | |
| 95 | nil This is the value to use the default settings which | 101 | ;; |
| 96 | is by default for printing buffer with only ASCII | 102 | ;;(defcustom ps-multibyte-buffer nil |
| 97 | and Latin characters. The default setting can be | 103 | ;; "*Specifies the multi-byte buffer handling. |
| 98 | changed by setting the variable | 104 | ;; |
| 99 | `ps-mule-font-info-database-default' differently. | 105 | ;;Valid values are: |
| 100 | The initial value of this variable is | 106 | ;; |
| 101 | `ps-mule-font-info-database-latin' (which see). | 107 | ;; nil This is the value to use the default settings which |
| 102 | 108 | ;; is by default for printing buffer with only ASCII | |
| 103 | `non-latin-printer' This is the value to use when you have a Japanese | 109 | ;; and Latin characters. The default setting can be |
| 104 | or Korean PostScript printer and want to print | 110 | ;; changed by setting the variable |
| 105 | buffer with ASCII, Latin-1, Japanese (JISX0208 and | 111 | ;; `ps-mule-font-info-database-default' differently. |
| 106 | JISX0201-Kana) and Korean characters. At present, | 112 | ;; The initial value of this variable is |
| 107 | it was not tested the Korean characters printing. | 113 | ;; `ps-mule-font-info-database-latin' (see |
| 108 | If you have a korean PostScript printer, please, | 114 | ;; documentation). |
| 109 | test it. | 115 | ;; |
| 110 | 116 | ;; `non-latin-printer' This is the value to use when you have a Japanese | |
| 111 | `bdf-font' This is the value to use when you want to print | 117 | ;; or Korean PostScript printer and want to print |
| 112 | buffer with BDF fonts. BDF fonts include both latin | 118 | ;; buffer with ASCII, Latin-1, Japanese (JISX0208 and |
| 113 | and non-latin fonts. BDF (Bitmap Distribution | 119 | ;; JISX0201-Kana) and Korean characters. At present, |
| 114 | Format) is a format used for distributing X's font | 120 | ;; it was not tested the Korean characters printing. |
| 115 | source file. BDF fonts are included in | 121 | ;; If you have a korean PostScript printer, please, |
| 116 | `intlfonts-1.1' which is a collection of X11 fonts | 122 | ;; test it. |
| 117 | for all characters supported by Emacs. In order to | 123 | ;; |
| 118 | use this value, be sure to have installed | 124 | ;; `bdf-font' This is the value to use when you want to print |
| 119 | `intlfonts-1.1' and set the variable | 125 | ;; buffer with BDF fonts. BDF fonts include both latin |
| 120 | `bdf-directory-list' appropriately (see ps-bdf.el for | 126 | ;; and non-latin fonts. BDF (Bitmap Distribution |
| 121 | documentation of this variable). | 127 | ;; Format) is a format used for distributing X's font |
| 122 | 128 | ;; source file. BDF fonts are included in | |
| 123 | `bdf-font-except-latin' This is like `bdf-font' except that it is used | 129 | ;; `intlfonts-1.1' which is a collection of X11 fonts |
| 124 | PostScript default fonts to print ASCII and Latin-1 | 130 | ;; for all characters supported by Emacs. In order to |
| 125 | characters. This is convenient when you want or | 131 | ;; use this value, be sure to have installed |
| 126 | need to use both latin and non-latin characters on | 132 | ;; `intlfonts-1.1' and set the variable |
| 127 | the same buffer. See `ps-font-family', | 133 | ;; `bdf-directory-list' appropriately (see ps-bdf.el for |
| 128 | `ps-header-font-family' and `ps-font-info-database'. | 134 | ;; documentation of this variable). |
| 129 | 135 | ;; | |
| 130 | Any other value is treated as nil." | 136 | ;; `bdf-font-except-latin' This is like `bdf-font' except that it is used |
| 131 | :type '(choice (const non-latin-printer) (const bdf-font) | 137 | ;; PostScript default fonts to print ASCII and Latin-1 |
| 132 | (const bdf-font-except-latin) (other :tag "nil" nil)) | 138 | ;; characters. This is convenient when you want or |
| 133 | :group 'ps-print-font) | 139 | ;; need to use both latin and non-latin characters on |
| 140 | ;; the same buffer. See `ps-font-family', | ||
| 141 | ;; `ps-header-font-family' and `ps-font-info-database'. | ||
| 142 | ;; | ||
| 143 | ;;Any other value is treated as nil." | ||
| 144 | ;; :type '(choice (const non-latin-printer) (const bdf-font) | ||
| 145 | ;; (const bdf-font-except-latin) (other :tag "nil" nil)) | ||
| 146 | ;; :group 'ps-print-font) | ||
| 147 | |||
| 134 | 148 | ||
| 135 | ;; For Emacs 20.2 and the earlier version. | 149 | ;; For Emacs 20.2 and the earlier version. |
| 136 | (eval-and-compile | 150 | (eval-and-compile |
| 137 | (if (not (string< mule-version "4.0")) | 151 | (if (and (boundp 'mule-version) ; only if mule package is loaded |
| 152 | (not (string< mule-version "4.0"))) | ||
| 138 | (progn | 153 | (progn |
| 139 | (defalias 'ps-mule-next-point '1+) | 154 | (defalias 'ps-mule-next-point '1+) |
| 140 | (defalias 'ps-mule-chars-in-string 'length) | 155 | (defalias 'ps-mule-chars-in-string 'length) |
| @@ -148,8 +163,7 @@ Any other value is treated as nil." | |||
| 148 | (defun ps-mule-string-char (string idx) | 163 | (defun ps-mule-string-char (string idx) |
| 149 | (string-to-char (substring string idx))) | 164 | (string-to-char (substring string idx))) |
| 150 | (defun ps-mule-next-index (string i) | 165 | (defun ps-mule-next-index (string i) |
| 151 | (+ i (charset-bytes (char-charset (string-to-char string)))))) | 166 | (+ i (charset-bytes (char-charset (string-to-char string))))))) |
| 152 | ) | ||
| 153 | 167 | ||
| 154 | (defvar ps-mule-font-info-database | 168 | (defvar ps-mule-font-info-database |
| 155 | nil | 169 | nil |
| @@ -198,9 +212,23 @@ See also the variable `ps-font-info-database'.") | |||
| 198 | (normal nil nil iso-latin-1))) | 212 | (normal nil nil iso-latin-1))) |
| 199 | "Sample setting of `ps-mule-font-info-database' to use latin fonts.") | 213 | "Sample setting of `ps-mule-font-info-database' to use latin fonts.") |
| 200 | 214 | ||
| 201 | (defvar ps-mule-font-info-database-default | 215 | (defcustom ps-mule-font-info-database-default |
| 202 | ps-mule-font-info-database-latin | 216 | ps-mule-font-info-database-latin |
| 203 | "The default setting to use if `ps-multibyte-buffer' (which see) is nil.") | 217 | "*The default setting to use if `ps-multibyte-buffer' is nil." |
| 218 | :type '(repeat :tag "Multi-Byte Buffer Database Font Default" | ||
| 219 | (list (symbol :tag "Charset") | ||
| 220 | (repeat :inline t | ||
| 221 | (list (choice :tag "Font Type" | ||
| 222 | (const normal) (const bold) | ||
| 223 | (const italic) (const bold-italic)) | ||
| 224 | (choice :tag "Font Source" | ||
| 225 | (const builtin) (const ps-bdf) | ||
| 226 | (const vflib) | ||
| 227 | (other :tag "nil" nil)) | ||
| 228 | (list (string :tag "Font Name")) | ||
| 229 | (function :tag "Encoding") | ||
| 230 | (integer :tag "Bytes"))))) | ||
| 231 | :group 'ps-print-font) | ||
| 204 | 232 | ||
| 205 | (defconst ps-mule-font-info-database-ps | 233 | (defconst ps-mule-font-info-database-ps |
| 206 | '((katakana-jisx0201 | 234 | '((katakana-jisx0201 |
| @@ -366,26 +394,34 @@ See also `ps-mule-font-info-database-bdf'.") | |||
| 366 | str)) | 394 | str)) |
| 367 | 395 | ||
| 368 | ;; Special encoding function for Ethiopic. | 396 | ;; Special encoding function for Ethiopic. |
| 369 | (define-ccl-program ccl-encode-ethio-unicode | 397 | (if (boundp 'mule-version) ; only if mule package is loaded |
| 370 | `(1 | 398 | (define-ccl-program ccl-encode-ethio-unicode |
| 371 | ((read r2) | 399 | `(1 |
| 372 | (loop | 400 | ((read r2) |
| 373 | (if (r2 == ,leading-code-private-22) | 401 | (loop |
| 374 | ((read r0) | 402 | (if (r2 == ,leading-code-private-22) |
| 375 | (if (r0 == ,(charset-id 'ethiopic)) | 403 | ((read r0) |
| 376 | ((read r1 r2) | 404 | (if (r0 == ,(charset-id 'ethiopic)) |
| 377 | (r1 &= 127) (r2 &= 127) | 405 | ((read r1 r2) |
| 378 | (call ccl-encode-ethio-font) | 406 | (r1 &= 127) (r2 &= 127) |
| 379 | (write r1) | 407 | (call ccl-encode-ethio-font) |
| 380 | (write-read-repeat r2)) | 408 | (write r1) |
| 381 | ((write r2 r0) | 409 | (write-read-repeat r2)) |
| 382 | (repeat)))) | 410 | ((write r2 r0) |
| 383 | (write-read-repeat r2)))))) | 411 | (repeat)))) |
| 384 | 412 | (write-read-repeat r2)))))) | |
| 385 | (defun ps-mule-encode-ethiopic (string) | 413 | ;; to avoid compilation gripes |
| 386 | (ccl-execute-on-string (symbol-value 'ccl-encode-ethio-unicode) | 414 | (defvar ccl-encode-ethio-unicode nil)) |
| 387 | (make-vector 9 nil) | 415 | |
| 388 | string)) | 416 | (if (boundp 'mule-version) |
| 417 | ;; bound mule-version | ||
| 418 | (defun ps-mule-encode-ethiopic (string) | ||
| 419 | (ccl-execute-on-string (symbol-value 'ccl-encode-ethio-unicode) | ||
| 420 | (make-vector 9 nil) | ||
| 421 | string)) | ||
| 422 | ;; unbound mule-version | ||
| 423 | (defun ps-mule-encode-ethiopic (string) | ||
| 424 | string)) | ||
| 389 | 425 | ||
| 390 | ;; A charset which we are now processing. | 426 | ;; A charset which we are now processing. |
| 391 | (defvar ps-mule-current-charset nil) | 427 | (defvar ps-mule-current-charset nil) |