diff options
| author | Gerd Moellmann | 2001-04-02 10:36:32 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-04-02 10:36:32 +0000 |
| commit | 922be0197ddc5f73bf77c228ef6078f82158434b (patch) | |
| tree | 4f27b74416a5373328ddae497a2eac1c1b10df4f | |
| parent | 64d8e7fd0e81cc3e89d04a27e30bc96075415f86 (diff) | |
| download | emacs-922be0197ddc5f73bf77c228ef6078f82158434b.tar.gz emacs-922be0197ddc5f73bf77c228ef6078f82158434b.zip | |
XEmacs compatibility. Doc fix.
(leading-code-private-22): Declare var if it's not declared yet.
(charset-bytes, charset-dimension, charset-id, charset-width)
(find-charset-region, split-char, char-width, chars-in-region)
(forward-point, decompose-composite-char, encode-coding-string)
(coding-system-p, ccl-execute-on-string, define-ccl-program):
Define funs if not defined yet.
(encode-composition-rule, find-composition): Define funs if not
loaded yet.
(ps-mule-prologue): PostScript code 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-mule.el | 304 |
1 files changed, 242 insertions, 62 deletions
diff --git a/lisp/ps-mule.el b/lisp/ps-mule.el index 7cf3c781242..efc9820253c 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, 1999, 2000 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1998,99,00,2001 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: wp, print, PostScript, multibyte, mule | 9 | ;; Keywords: wp, print, PostScript, multibyte, mule |
| 10 | ;; Time-stamp: <2000/08/01 11:17:35 vinicius> | 10 | ;; Time-stamp: <2001/03/16 18:50:59 Handa> |
| 11 | 11 | ||
| 12 | ;; This file is part of GNU Emacs. | 12 | ;; This file is part of GNU Emacs. |
| 13 | 13 | ||
| @@ -68,10 +68,10 @@ | |||
| 68 | ;; and non-latin fonts. BDF (Bitmap Distribution | 68 | ;; and non-latin fonts. BDF (Bitmap Distribution |
| 69 | ;; Format) is a format used for distributing X's font | 69 | ;; Format) is a format used for distributing X's font |
| 70 | ;; source file. BDF fonts are included in | 70 | ;; source file. BDF fonts are included in |
| 71 | ;; `intlfonts-1.1' which is a collection of X11 fonts | 71 | ;; `intlfonts-1.2' which is a collection of X11 fonts |
| 72 | ;; for all characters supported by Emacs. In order to | 72 | ;; for all characters supported by Emacs. In order to |
| 73 | ;; use this value, be sure to have installed | 73 | ;; use this value, be sure to have installed |
| 74 | ;; `intlfonts-1.1' and set the variable | 74 | ;; `intlfonts-1.2' and set the variable |
| 75 | ;; `bdf-directory-list' appropriately (see ps-bdf.el | 75 | ;; `bdf-directory-list' appropriately (see ps-bdf.el |
| 76 | ;; for documentation of this variable). | 76 | ;; for documentation of this variable). |
| 77 | ;; | 77 | ;; |
| @@ -90,7 +90,63 @@ | |||
| 90 | 90 | ||
| 91 | ;;; Code: | 91 | ;;; Code: |
| 92 | 92 | ||
| 93 | (eval-and-compile (require 'ps-print)) | 93 | (eval-and-compile |
| 94 | (require 'ps-print) | ||
| 95 | |||
| 96 | ;; to avoid XEmacs compilation gripes | ||
| 97 | (defvar leading-code-private-22 157) | ||
| 98 | (or (fboundp 'charset-bytes) | ||
| 99 | (defun charset-bytes (charset) 1)) ; ascii | ||
| 100 | (or (fboundp 'charset-dimension) | ||
| 101 | (defun charset-dimension (charset) 1)) ; ascii | ||
| 102 | (or (fboundp 'charset-id) | ||
| 103 | (defun charset-id (charset) 0)) ; ascii | ||
| 104 | (or (fboundp 'charset-width) | ||
| 105 | (defun charset-width (charset) 1)) ; ascii | ||
| 106 | (or (fboundp 'find-charset-region) | ||
| 107 | (defun find-charset-region (beg end &optional table) | ||
| 108 | (list 'ascii))) | ||
| 109 | (or (fboundp 'split-char) | ||
| 110 | (defun split-char (char) | ||
| 111 | (list (if (char-valid-p char) | ||
| 112 | 'ascii | ||
| 113 | 'unknow) | ||
| 114 | char))) | ||
| 115 | (or (fboundp 'char-width) | ||
| 116 | (defun char-width (char) 1)) ; ascii | ||
| 117 | (or (fboundp 'chars-in-region) | ||
| 118 | (defun chars-in-region (beg end) | ||
| 119 | (- (max beg end) (min beg end)))) | ||
| 120 | (or (fboundp 'forward-point) | ||
| 121 | (defun forward-point (arg) | ||
| 122 | (save-excursion | ||
| 123 | (let ((count (abs arg)) | ||
| 124 | (step (if (zerop arg) | ||
| 125 | 0 | ||
| 126 | (/ arg arg)))) | ||
| 127 | (while (and (> count 0) | ||
| 128 | (< (point-min) (point)) (< (point) (point-max))) | ||
| 129 | (forward-char step) | ||
| 130 | (setq count (1- count))) | ||
| 131 | (+ (point) (* count step)))))) | ||
| 132 | (or (fboundp 'decompose-composite-char) | ||
| 133 | (defun decompose-composite-char (char &optional type | ||
| 134 | with-composition-rule) | ||
| 135 | nil)) | ||
| 136 | (or (fboundp 'encode-coding-string) | ||
| 137 | (defun encode-coding-string (string coding-system &optional nocopy) | ||
| 138 | (if nocopy | ||
| 139 | string | ||
| 140 | (copy-sequence string)))) | ||
| 141 | (or (fboundp 'coding-system-p) | ||
| 142 | (defun coding-system-p (obj) nil)) | ||
| 143 | (or (fboundp 'ccl-execute-on-string) | ||
| 144 | (defun ccl-execute-on-string (ccl-prog status str | ||
| 145 | &optional contin unibyte-p) | ||
| 146 | str)) | ||
| 147 | (or (fboundp 'define-ccl-program) | ||
| 148 | (defmacro define-ccl-program (name ccl-program &optional doc) | ||
| 149 | `(defconst ,name nil ,doc)))) | ||
| 94 | 150 | ||
| 95 | 151 | ||
| 96 | ;;;###autoload | 152 | ;;;###autoload |
| @@ -121,10 +177,10 @@ Valid values are: | |||
| 121 | and non-latin fonts. BDF (Bitmap Distribution | 177 | and non-latin fonts. BDF (Bitmap Distribution |
| 122 | Format) is a format used for distributing X's font | 178 | Format) is a format used for distributing X's font |
| 123 | source file. BDF fonts are included in | 179 | source file. BDF fonts are included in |
| 124 | `intlfonts-1.1' which is a collection of X11 fonts | 180 | `intlfonts-1.2' which is a collection of X11 fonts |
| 125 | for all characters supported by Emacs. In order to | 181 | for all characters supported by Emacs. In order to |
| 126 | use this value, be sure to have installed | 182 | use this value, be sure to have installed |
| 127 | `intlfonts-1.1' and set the variable | 183 | `intlfonts-1.2' and set the variable |
| 128 | `bdf-directory-list' appropriately (see ps-bdf.el for | 184 | `bdf-directory-list' appropriately (see ps-bdf.el for |
| 129 | documentation of this variable). | 185 | documentation of this variable). |
| 130 | 186 | ||
| @@ -141,15 +197,17 @@ Any other value is treated as nil." | |||
| 141 | :group 'ps-print-font) | 197 | :group 'ps-print-font) |
| 142 | 198 | ||
| 143 | 199 | ||
| 144 | ;; For Emacs 20.2 and the earlier version. | ||
| 145 | (eval-and-compile | 200 | (eval-and-compile |
| 146 | (if (and (boundp 'mule-version) ; only if mule package is loaded | 201 | ;; For Emacs 20.2 and the earlier version. |
| 147 | (not (string< mule-version "4.0"))) | 202 | (if (and (boundp 'mule-version) |
| 203 | (not (string< (symbol-value 'mule-version) "4.0"))) | ||
| 204 | ;; mule package is loaded | ||
| 148 | (progn | 205 | (progn |
| 149 | (defalias 'ps-mule-next-point '1+) | 206 | (defalias 'ps-mule-next-point '1+) |
| 150 | (defalias 'ps-mule-chars-in-string 'length) | 207 | (defalias 'ps-mule-chars-in-string 'length) |
| 151 | (defalias 'ps-mule-string-char 'aref) | 208 | (defalias 'ps-mule-string-char 'aref) |
| 152 | (defsubst ps-mule-next-index (str i) (1+ i))) | 209 | (defsubst ps-mule-next-index (str i) (1+ i))) |
| 210 | ;; mule package isn't loaded or mule version lesser than 4.0 | ||
| 153 | (defun ps-mule-next-point (arg) | 211 | (defun ps-mule-next-point (arg) |
| 154 | (save-excursion (goto-char arg) (forward-char 1) (point))) | 212 | (save-excursion (goto-char arg) (forward-char 1) (point))) |
| 155 | (defun ps-mule-chars-in-string (string) | 213 | (defun ps-mule-chars-in-string (string) |
| @@ -159,24 +217,32 @@ Any other value is treated as nil." | |||
| 159 | (string-to-char (substring string idx))) | 217 | (string-to-char (substring string idx))) |
| 160 | (defun ps-mule-next-index (string i) | 218 | (defun ps-mule-next-index (string i) |
| 161 | (+ i (charset-bytes (char-charset (string-to-char string))))) | 219 | (+ i (charset-bytes (char-charset (string-to-char string))))) |
| 220 | ) | ||
| 221 | ;; For Emacs 20.4 and the earlier version. | ||
| 222 | (if (and (boundp 'mule-version) | ||
| 223 | (string< (symbol-value 'mule-version) "5.0")) | ||
| 224 | ;; mule package is loaded and mule version is lesser than 5.0 | ||
| 225 | (progn | ||
| 226 | (defun encode-composition-rule (rule) | ||
| 227 | (if (= (car rule) 4) (setcar rule 10)) | ||
| 228 | (if (= (cdr rule) 4) (setcdr rule 10)) | ||
| 229 | (+ (* (car rule) 12) (cdr rule))) | ||
| 230 | (defun find-composition (pos &rest ignore) | ||
| 231 | (let ((ch (char-after pos))) | ||
| 232 | (if (eq (char-charset ch) 'composition) | ||
| 233 | (let ((components (decompose-composite-char ch 'vector t))) | ||
| 234 | (list pos (ps-mule-next-point pos) components | ||
| 235 | (integerp (aref components 1)) nil | ||
| 236 | (char-width ch))))))) | ||
| 237 | ;; mule package isn't loaded | ||
| 238 | (or (fboundp 'encode-composition-rule) | ||
| 239 | (defun encode-composition-rule (rule) | ||
| 240 | 130)) | ||
| 241 | (or (fboundp 'find-composition) | ||
| 242 | (defun find-composition (pos &rest ignore) | ||
| 243 | nil)) | ||
| 162 | )) | 244 | )) |
| 163 | 245 | ||
| 164 | ;; For Emacs 20.4 and the earlier version. | ||
| 165 | (eval-and-compile | ||
| 166 | (when (and (boundp 'mule-version) | ||
| 167 | (string< mule-version "5.0")) | ||
| 168 | (defun encode-composition-rule (rule) | ||
| 169 | (if (= (car rule) 4) (setcar rule 10)) | ||
| 170 | (if (= (cdr rule) 4) (setcdr rule 10)) | ||
| 171 | (+ (* (car rule) 12) (cdr rule))) | ||
| 172 | (defun find-composition (pos &rest ignore) | ||
| 173 | (let ((ch (char-after pos))) | ||
| 174 | (if (eq (char-charset ch) 'composition) | ||
| 175 | (let ((components (decompose-composite-char ch 'vector t))) | ||
| 176 | (list pos (ps-mule-next-point pos) components | ||
| 177 | (integerp (aref components 1)) nil | ||
| 178 | (char-width ch)))))))) | ||
| 179 | |||
| 180 | (defvar ps-mule-font-info-database | 246 | (defvar ps-mule-font-info-database |
| 181 | nil | 247 | nil |
| 182 | "Alist of charsets with the corresponding font information. | 248 | "Alist of charsets with the corresponding font information. |
| @@ -192,7 +258,7 @@ FONT-TYPE is a font type: normal, bold, italic, or bold-italic. | |||
| 192 | 258 | ||
| 193 | FONT-SRC is a font source: builtin, ps-bdf, vflib, or nil. | 259 | FONT-SRC is a font source: builtin, ps-bdf, vflib, or nil. |
| 194 | 260 | ||
| 195 | If FONT-SRC is builtin, FONT-NAME is a buitin PostScript font name. | 261 | If FONT-SRC is builtin, FONT-NAME is a built-in PostScript font name. |
| 196 | 262 | ||
| 197 | If FONT-SRC is bdf, FONT-NAME is a BDF font file name, or a list of | 263 | If FONT-SRC is bdf, FONT-NAME is a BDF font file name, or a list of |
| 198 | alternative font names. To use this font, the external library `ps-bdf' | 264 | alternative font names. To use this font, the external library `ps-bdf' |
| @@ -343,7 +409,7 @@ Currently, data for Japanese and Korean PostScript printers are listed.") | |||
| 343 | BDF (Bitmap Distribution Format) is a format used for distributing X's font | 409 | BDF (Bitmap Distribution Format) is a format used for distributing X's font |
| 344 | source file. | 410 | source file. |
| 345 | 411 | ||
| 346 | Current default value list for BDF fonts is included in `intlfonts-1.1' which is | 412 | Current default value list for BDF fonts is included in `intlfonts-1.2' which is |
| 347 | a collection of X11 fonts for all characters supported by Emacs. | 413 | a collection of X11 fonts for all characters supported by Emacs. |
| 348 | 414 | ||
| 349 | Using this list as default value to `ps-mule-font-info-database', all characters | 415 | Using this list as default value to `ps-mule-font-info-database', all characters |
| @@ -356,7 +422,7 @@ See also `ps-mule-font-info-database-ps-bdf'.") | |||
| 356 | (cdr (cdr ps-mule-font-info-database-bdf))) | 422 | (cdr (cdr ps-mule-font-info-database-bdf))) |
| 357 | "Sample setting of the `ps-mule-font-info-database' to use BDF fonts. | 423 | "Sample setting of the `ps-mule-font-info-database' to use BDF fonts. |
| 358 | 424 | ||
| 359 | Current default value list for BDF fonts is included in `intlfonts-1.1' which is | 425 | Current default value list for BDF fonts is included in `intlfonts-1.2' which is |
| 360 | a collection of X11 fonts for all characters supported by Emacs. | 426 | a collection of X11 fonts for all characters supported by Emacs. |
| 361 | 427 | ||
| 362 | Using this list as default value to `ps-mule-font-info-database', all characters | 428 | Using this list as default value to `ps-mule-font-info-database', all characters |
| @@ -506,30 +572,42 @@ See the documentation of `ps-mule-get-font-spec' for FONT-SPEC's meaning." | |||
| 506 | ;; cache CODE0 CODE1 ...) | 572 | ;; cache CODE0 CODE1 ...) |
| 507 | (defvar ps-mule-font-cache nil) | 573 | (defvar ps-mule-font-cache nil) |
| 508 | 574 | ||
| 509 | (defun ps-mule-generate-font (font-spec charset) | 575 | (defun ps-mule-generate-font (font-spec charset &optional header-p) |
| 510 | "Generate PostScript codes to define a new font in FONT-SPEC for CHARSET." | 576 | "Generate PostScript codes to define a new font in FONT-SPEC for CHARSET. |
| 577 | |||
| 578 | If optional 3rd arg HEADER-P is non-nil, generate codes to define a header | ||
| 579 | font." | ||
| 511 | (let* ((font-name (ps-mule-font-spec-name font-spec)) | 580 | (let* ((font-name (ps-mule-font-spec-name font-spec)) |
| 512 | (font-name (if (consp font-name) (car font-name) font-name)) | 581 | (font-name (if (consp font-name) (car font-name) font-name)) |
| 513 | (font-cache (assoc font-name ps-mule-font-cache)) | 582 | (font-cache (assoc font-name ps-mule-font-cache)) |
| 514 | (font-src (ps-mule-font-spec-src font-spec)) | 583 | (font-src (ps-mule-font-spec-src font-spec)) |
| 515 | (func (nth 4 (assq font-src ps-mule-external-libraries))) | 584 | (func (nth 4 (assq font-src ps-mule-external-libraries))) |
| 585 | (font-size (if header-p (if (eq ps-current-font 0) | ||
| 586 | ps-header-title-font-size-internal | ||
| 587 | ps-header-font-size-internal) | ||
| 588 | ps-font-size-internal)) | ||
| 589 | (current-font (+ ps-current-font (if header-p 10 0))) | ||
| 516 | (scaled-font-name | 590 | (scaled-font-name |
| 517 | (if (eq charset 'ascii) | 591 | (cond (header-p |
| 518 | (format "f%d" ps-current-font) | 592 | (format "h%d" ps-current-font)) |
| 519 | (format "f%02x-%d" | 593 | ((eq charset 'ascii) |
| 520 | (charset-id charset) ps-current-font)))) | 594 | (format "f%d" ps-current-font)) |
| 595 | (t | ||
| 596 | (format "f%02x-%d" (charset-id charset) ps-current-font))))) | ||
| 521 | (and func (not font-cache) | 597 | (and func (not font-cache) |
| 522 | (ps-output-prologue (funcall func charset font-spec))) | 598 | (ps-output-prologue (funcall func charset font-spec))) |
| 523 | (ps-output-prologue | 599 | (ps-output-prologue |
| 524 | (list (format "/%s %f /%s Def%sFontMule\n" | 600 | (list (format "/%s %f /%s Def%sFontMule\n" |
| 525 | scaled-font-name ps-font-size-internal font-name | 601 | scaled-font-name font-size font-name |
| 526 | (if (eq ps-mule-current-charset 'ascii) "Ascii" "")))) | 602 | (if (or header-p |
| 603 | (eq ps-mule-current-charset 'ascii)) | ||
| 604 | "Ascii" "")))) | ||
| 527 | (if font-cache | 605 | (if font-cache |
| 528 | (setcar (cdr font-cache) | 606 | (setcar (cdr font-cache) |
| 529 | (cons (cons ps-current-font scaled-font-name) | 607 | (cons (cons current-font scaled-font-name) |
| 530 | (nth 1 font-cache))) | 608 | (nth 1 font-cache))) |
| 531 | (setq font-cache (list font-name | 609 | (setq font-cache (list font-name |
| 532 | (list (cons ps-current-font scaled-font-name)) | 610 | (list (cons current-font scaled-font-name)) |
| 533 | 'cache) | 611 | 'cache) |
| 534 | ps-mule-font-cache (cons font-cache ps-mule-font-cache))) | 612 | ps-mule-font-cache (cons font-cache ps-mule-font-cache))) |
| 535 | font-cache)) | 613 | font-cache)) |
| @@ -543,21 +621,26 @@ See the documentation of `ps-mule-get-font-spec' for FONT-SPEC's meaning." | |||
| 543 | (funcall func font-spec code-list | 621 | (funcall func font-spec code-list |
| 544 | (ps-mule-font-spec-bytes font-spec)))))) | 622 | (ps-mule-font-spec-bytes font-spec)))))) |
| 545 | 623 | ||
| 546 | (defun ps-mule-prepare-font (font-spec string charset &optional no-setfont) | 624 | (defun ps-mule-prepare-font (font-spec string charset |
| 625 | &optional no-setfont header-p) | ||
| 547 | "Generate PostScript codes to print STRING of CHARSET by font FONT-SPEC. | 626 | "Generate PostScript codes to print STRING of CHARSET by font FONT-SPEC. |
| 548 | 627 | ||
| 549 | The generated code is inserted on prologue part except the code that sets the | 628 | The generated code is inserted on prologue part except the code that sets the |
| 550 | current font (using PostScript procedure `FM'). | 629 | current font (using PostScript procedure `FM'). |
| 551 | 630 | ||
| 552 | If optional arg NO-SETFONT is non-nil, don't generate the code for setting the | 631 | If optional 4th arg NO-SETFONT is non-nil, don't generate the code for setting |
| 553 | current font." | 632 | the current font. |
| 633 | |||
| 634 | If optional 5th arg HEADER-P is non-nil, generate a code for setting a header | ||
| 635 | font." | ||
| 554 | (let* ((font-name (ps-mule-font-spec-name font-spec)) | 636 | (let* ((font-name (ps-mule-font-spec-name font-spec)) |
| 555 | (font-name (if (consp font-name) (car font-name) font-name)) | 637 | (font-name (if (consp font-name) (car font-name) font-name)) |
| 638 | (current-font (+ ps-current-font (if header-p 10 0))) | ||
| 556 | (font-cache (assoc font-name ps-mule-font-cache))) | 639 | (font-cache (assoc font-name ps-mule-font-cache))) |
| 557 | (or (and font-cache (assq ps-current-font (nth 1 font-cache))) | 640 | (or (and font-cache (assq current-font (nth 1 font-cache))) |
| 558 | (setq font-cache (ps-mule-generate-font font-spec charset))) | 641 | (setq font-cache (ps-mule-generate-font font-spec charset header-p))) |
| 559 | (or no-setfont | 642 | (or no-setfont |
| 560 | (let ((new-font (cdr (assq ps-current-font (nth 1 font-cache))))) | 643 | (let ((new-font (cdr (assq current-font (nth 1 font-cache))))) |
| 561 | (or (equal new-font ps-last-font) | 644 | (or (equal new-font ps-last-font) |
| 562 | (progn | 645 | (progn |
| 563 | (ps-output (format "/%s FM\n" new-font)) | 646 | (ps-output (format "/%s FM\n" new-font)) |
| @@ -616,7 +699,7 @@ STRING should contain only ASCII characters." | |||
| 616 | dup length 2 add dict begin | 699 | dup length 2 add dict begin |
| 617 | { 1 index /FID ne { def } { pop pop } ifelse } forall | 700 | { 1 index /FID ne { def } { pop pop } ifelse } forall |
| 618 | currentdict /BaselineOffset known { | 701 | currentdict /BaselineOffset known { |
| 619 | BaselineOffset false eq { /BaselinfOffset 0 def } if | 702 | BaselineOffset false eq { /BaselineOffset 0 def } if |
| 620 | } { | 703 | } { |
| 621 | /BaselineOffset 0 def | 704 | /BaselineOffset 0 def |
| 622 | } ifelse | 705 | } ifelse |
| @@ -698,7 +781,7 @@ The search starts at FROM and goes until TO. | |||
| 698 | Optional 4th arg COMPOSITION, if non-nil, is information of | 781 | Optional 4th arg COMPOSITION, if non-nil, is information of |
| 699 | composition starting at FROM. | 782 | composition starting at FROM. |
| 700 | 783 | ||
| 701 | If COMPOSTION is nil, it is assumed that all characters between FROM | 784 | If COMPOSITION is nil, it is assumed that all characters between FROM |
| 702 | and TO belong to a charset in `ps-mule-current-charset'. Otherwise, | 785 | and TO belong to a charset in `ps-mule-current-charset'. Otherwise, |
| 703 | it is assumed that all characters between FROM and TO belong to the | 786 | it is assumed that all characters between FROM and TO belong to the |
| 704 | same composition. | 787 | same composition. |
| @@ -736,7 +819,7 @@ the sequence." | |||
| 736 | 819 | ||
| 737 | ;;;###autoload | 820 | ;;;###autoload |
| 738 | (defun ps-mule-plot-string (from to &optional bg-color) | 821 | (defun ps-mule-plot-string (from to &optional bg-color) |
| 739 | "Generate PostScript code for ploting characters in the region FROM and TO. | 822 | "Generate PostScript code for plotting characters in the region FROM and TO. |
| 740 | 823 | ||
| 741 | It is assumed that all characters in this region belong to the same charset. | 824 | It is assumed that all characters in this region belong to the same charset. |
| 742 | 825 | ||
| @@ -787,7 +870,7 @@ the sequence." | |||
| 787 | 870 | ||
| 788 | ;;;###autoload | 871 | ;;;###autoload |
| 789 | (defun ps-mule-plot-composition (from to &optional bg-color) | 872 | (defun ps-mule-plot-composition (from to &optional bg-color) |
| 790 | "Generate PostScript code for ploting composition in the region FROM and TO. | 873 | "Generate PostScript code for plotting composition in the region FROM and TO. |
| 791 | 874 | ||
| 792 | It is assumed that all characters in this region belong to the same | 875 | It is assumed that all characters in this region belong to the same |
| 793 | composition. | 876 | composition. |
| @@ -876,7 +959,7 @@ the sequence." | |||
| 876 | (defvar ps-mule-composition-prologue-generated nil) | 959 | (defvar ps-mule-composition-prologue-generated nil) |
| 877 | 960 | ||
| 878 | (defconst ps-mule-composition-prologue | 961 | (defconst ps-mule-composition-prologue |
| 879 | "%%%% Character compositition handler | 962 | "%%%% Character composition handler |
| 880 | /RelativeCompositionSkip 0.4 def | 963 | /RelativeCompositionSkip 0.4 def |
| 881 | 964 | ||
| 882 | %% Get a bounding box (relative to currentpoint) of STR. | 965 | %% Get a bounding box (relative to currentpoint) of STR. |
| @@ -919,8 +1002,8 @@ the sequence." | |||
| 919 | Effect 32 and 0 ne { true doOutline } { show } ifelse | 1002 | Effect 32 and 0 ne { true doOutline } { show } ifelse |
| 920 | } def | 1003 | } def |
| 921 | 1004 | ||
| 922 | %% Draw COMPONETS which have the form [ font0? [str0 xoff0 yoff0] ... ]. | 1005 | %% Draw COMPONENTS which have the form [ font0? [str0 xoff0 yoff0] ... ]. |
| 923 | /ShowComponents { % compoents |- - | 1006 | /ShowComponents { % components |- - |
| 924 | LEFT 0 lt { LEFT neg 0 rmoveto } if | 1007 | LEFT 0 lt { LEFT neg 0 rmoveto } if |
| 925 | { | 1008 | { |
| 926 | dup type /nametype eq { % font | 1009 | dup type /nametype eq { % font |
| @@ -1003,7 +1086,7 @@ the sequence." | |||
| 1003 | elt dup FM | 1086 | elt dup FM |
| 1004 | } { elt type /integertype eq { % rule | 1087 | } { elt type /integertype eq { % rule |
| 1005 | %% This RULE decoding should be compatible with macro | 1088 | %% This RULE decoding should be compatible with macro |
| 1006 | %% COMPOSITION_DECODE_RULE in emcas/src/composite.h. | 1089 | %% COMPOSITION_DECODE_RULE in emacs/src/composite.h. |
| 1007 | elt 12 idiv dup 3 mod /grefx exch def 3 idiv /grefy exch def | 1090 | elt 12 idiv dup 3 mod /grefx exch def 3 idiv /grefy exch def |
| 1008 | elt 12 mod dup 3 mod /nrefx exch def 3 idiv /nrefy exch def | 1091 | elt 12 mod dup 3 mod /nrefx exch def 3 idiv /nrefy exch def |
| 1009 | } { first { % first string | 1092 | } { first { % first string |
| @@ -1046,16 +1129,17 @@ the sequence." | |||
| 1046 | %%%% End of character composition handler | 1129 | %%%% End of character composition handler |
| 1047 | 1130 | ||
| 1048 | " | 1131 | " |
| 1049 | "PostScript code for printing character compositition.") | 1132 | "PostScript code for printing character composition.") |
| 1050 | 1133 | ||
| 1051 | (defun ps-mule-string-ascii (str) | 1134 | (defun ps-mule-string-ascii (str) |
| 1052 | (ps-set-font ps-current-font) | 1135 | (ps-set-font ps-current-font) |
| 1053 | (string-as-unibyte (encode-coding-string str 'iso-latin-1))) | 1136 | (string-as-unibyte (encode-coding-string str 'iso-latin-1))) |
| 1054 | 1137 | ||
| 1055 | ;; Encode STR for a font specified by FONT-SPEC and return the result. | 1138 | ;; Encode STR for a font specified by FONT-SPEC and return the result. |
| 1056 | ;; If necessary, Postscript codes for the font and glyphs to print | 1139 | ;; If necessary, it's generated the Postscript code for the font and glyphs to |
| 1057 | ;; STRING are generated. | 1140 | ;; print STR. If optional 4th arg HEADER-P is non-nil, it is assumed that STR |
| 1058 | (defun ps-mule-string-encoding (font-spec str &optional no-setfont) | 1141 | ;; is for headers. |
| 1142 | (defun ps-mule-string-encoding (font-spec str &optional no-setfont header-p) | ||
| 1059 | (let ((encoding (ps-mule-font-spec-encoding font-spec))) | 1143 | (let ((encoding (ps-mule-font-spec-encoding font-spec))) |
| 1060 | (setq str | 1144 | (setq str |
| 1061 | (string-as-unibyte | 1145 | (string-as-unibyte |
| @@ -1068,7 +1152,9 @@ the sequence." | |||
| 1068 | (t | 1152 | (t |
| 1069 | str)))) | 1153 | str)))) |
| 1070 | (if (ps-mule-font-spec-src font-spec) | 1154 | (if (ps-mule-font-spec-src font-spec) |
| 1071 | (ps-mule-prepare-font font-spec str ps-mule-current-charset no-setfont) | 1155 | (ps-mule-prepare-font font-spec str ps-mule-current-charset |
| 1156 | (or no-setfont header-p) | ||
| 1157 | header-p) | ||
| 1072 | (or no-setfont | 1158 | (or no-setfont |
| 1073 | (ps-set-font ps-current-font))) | 1159 | (ps-set-font ps-current-font))) |
| 1074 | str)) | 1160 | str)) |
| @@ -1166,7 +1252,7 @@ NewBitmapDict | |||
| 1166 | 1 index /BuildGlyph get exec | 1252 | 1 index /BuildGlyph get exec |
| 1167 | } bind def | 1253 | } bind def |
| 1168 | 1254 | ||
| 1169 | %% Bitmap font creater | 1255 | %% Bitmap font creator |
| 1170 | 1256 | ||
| 1171 | %% Common Encoding shared by all bitmap fonts. | 1257 | %% Common Encoding shared by all bitmap fonts. |
| 1172 | /EncodingCommon 256 array def | 1258 | /EncodingCommon 256 array def |
| @@ -1257,11 +1343,84 @@ NewBitmapDict | |||
| 1257 | (mapcar `(lambda (x) (setcar (nthcdr 2 x) nil)) | 1343 | (mapcar `(lambda (x) (setcar (nthcdr 2 x) nil)) |
| 1258 | ps-mule-external-libraries)) | 1344 | ps-mule-external-libraries)) |
| 1259 | 1345 | ||
| 1346 | (defvar ps-mule-header-charsets nil) | ||
| 1347 | |||
| 1348 | ;;;###autoload | ||
| 1349 | (defun ps-mule-encode-header-string (string fonttag) | ||
| 1350 | "Generate PostScript code for ploting STRING by font FONTTAG. | ||
| 1351 | FONTTAG should be a string \"/h0\" or \"/h1\"." | ||
| 1352 | (setq string (if (multibyte-string-p string) | ||
| 1353 | (copy-sequence string) | ||
| 1354 | (string-make-multibyte string))) | ||
| 1355 | (when ps-mule-header-charsets | ||
| 1356 | (if (eq (car ps-mule-header-charsets) 'latin-iso8859-1) | ||
| 1357 | ;; Latin1 characters can be printed by the standard PostScript | ||
| 1358 | ;; font. Converts the other non-ASCII characters to `?'. | ||
| 1359 | (let ((len (length string))) | ||
| 1360 | (dotimes (i len) | ||
| 1361 | (or (memq (char-charset (aref string i)) '(ascii latin-iso8859-1)) | ||
| 1362 | (aset string i ??))) | ||
| 1363 | (setq string (encode-coding-string string 'iso-latin-1))) | ||
| 1364 | ;; We must prepare a font for the first non-ASCII and non-Latin1 | ||
| 1365 | ;; character in STRING. | ||
| 1366 | (let* ((ps-current-font (if (string= fonttag "/h0") 0 1)) | ||
| 1367 | (ps-mule-current-charset (car ps-mule-header-charsets)) | ||
| 1368 | (font-type (car (nth ps-current-font | ||
| 1369 | (ps-font-alist 'ps-font-for-header)))) | ||
| 1370 | (font-spec (ps-mule-get-font-spec ps-mule-current-charset | ||
| 1371 | font-type))) | ||
| 1372 | (if (or (not font-spec) | ||
| 1373 | (/= (charset-dimension ps-mule-current-charset) 1)) | ||
| 1374 | ;; We don't have a proper font, or we can't print them on | ||
| 1375 | ;; header because this kind of charset is not ASCII | ||
| 1376 | ;; compatible. | ||
| 1377 | (let ((len (length string))) | ||
| 1378 | (dotimes (i len) | ||
| 1379 | (or (memq (char-charset (aref string i)) | ||
| 1380 | '(ascii latin-iso8859-1)) | ||
| 1381 | (aset string i ??))) | ||
| 1382 | (setq string (encode-coding-string string 'iso-latin-1))) | ||
| 1383 | (let ((charsets (list 'ascii (car ps-mule-header-charsets))) | ||
| 1384 | (len (length string))) | ||
| 1385 | (dotimes (i len) | ||
| 1386 | (or (memq (char-charset (aref string i)) charsets) | ||
| 1387 | (aset string i ??)))) | ||
| 1388 | (setq string (ps-mule-string-encoding font-spec string nil t)))))) | ||
| 1389 | string) | ||
| 1390 | |||
| 1391 | ;;;###autoload | ||
| 1392 | (defun ps-mule-header-string-charsets () | ||
| 1393 | "Return a list of character sets that appears in header strings." | ||
| 1394 | (let ((str "") | ||
| 1395 | len charset charset-list) | ||
| 1396 | (when ps-print-header | ||
| 1397 | (dolist (tail (list ps-left-header ps-right-header)) | ||
| 1398 | ;; Simulate what is done by ps-generate-header-line to get a | ||
| 1399 | ;; string to plot. | ||
| 1400 | (let ((count 0)) | ||
| 1401 | (dolist (elt tail) | ||
| 1402 | (if (< count ps-header-lines) | ||
| 1403 | (setq str (concat str (cond ((stringp elt) elt) | ||
| 1404 | ((and (symbolp elt) (fboundp elt)) | ||
| 1405 | (funcall elt)) | ||
| 1406 | ((and (symbolp elt) (boundp elt)) | ||
| 1407 | (symbol-value elt)) | ||
| 1408 | (t ""))) | ||
| 1409 | count (1+ count))))))) | ||
| 1410 | (setq len (length str)) | ||
| 1411 | (dotimes (i len) | ||
| 1412 | (setq charset (char-charset (aref str i))) | ||
| 1413 | (or (eq charset 'ascii) | ||
| 1414 | (memq charset charset-list) | ||
| 1415 | (setq charset-list (cons charset charset-list)))) | ||
| 1416 | charset-list)) | ||
| 1417 | |||
| 1260 | ;;;###autoload | 1418 | ;;;###autoload |
| 1261 | (defun ps-mule-begin-job (from to) | 1419 | (defun ps-mule-begin-job (from to) |
| 1262 | "Start printing job for multi-byte chars between FROM and TO. | 1420 | "Start printing job for multi-byte chars between FROM and TO. |
| 1263 | This checks if all multi-byte characters in the region are printable or not." | 1421 | This checks if all multi-byte characters in the region are printable or not." |
| 1264 | (setq ps-mule-charset-list nil | 1422 | (setq ps-mule-charset-list nil |
| 1423 | ps-mule-header-charsets nil | ||
| 1265 | ps-mule-font-info-database | 1424 | ps-mule-font-info-database |
| 1266 | (cond ((eq ps-multibyte-buffer 'non-latin-printer) | 1425 | (cond ((eq ps-multibyte-buffer 'non-latin-printer) |
| 1267 | ps-mule-font-info-database-ps) | 1426 | ps-mule-font-info-database-ps) |
| @@ -1283,6 +1442,15 @@ This checks if all multi-byte characters in the region are printable or not." | |||
| 1283 | (and (search-forward "\200" to t) | 1442 | (and (search-forward "\200" to t) |
| 1284 | (setq ps-mule-charset-list | 1443 | (setq ps-mule-charset-list |
| 1285 | (cons 'composition ps-mule-charset-list)))) | 1444 | (cons 'composition ps-mule-charset-list)))) |
| 1445 | ;; We also have to check non-ASCII charsets in the header strings. | ||
| 1446 | (let ((tail (ps-mule-header-string-charsets))) | ||
| 1447 | (while tail | ||
| 1448 | (unless (eq (car tail) 'ascii) | ||
| 1449 | (setq ps-mule-header-charsets | ||
| 1450 | (cons (car tail) ps-mule-header-charsets)) | ||
| 1451 | (or (memq (car tail) charsets) | ||
| 1452 | (setq charsets (cons (car tail) charsets)))) | ||
| 1453 | (setq tail (cdr tail)))) | ||
| 1286 | (while charsets | 1454 | (while charsets |
| 1287 | (setq charsets | 1455 | (setq charsets |
| 1288 | (cond | 1456 | (cond |
| @@ -1304,8 +1472,8 @@ This checks if all multi-byte characters in the region are printable or not." | |||
| 1304 | (ps-output-prologue ps-mule-composition-prologue) | 1472 | (ps-output-prologue ps-mule-composition-prologue) |
| 1305 | (setq ps-mule-composition-prologue-generated t))) | 1473 | (setq ps-mule-composition-prologue-generated t))) |
| 1306 | 1474 | ||
| 1307 | (if ps-mule-charset-list | 1475 | (if (or ps-mule-charset-list ps-mule-header-charsets) |
| 1308 | (let ((the-list ps-mule-charset-list) | 1476 | (let ((the-list (append ps-mule-header-charsets ps-mule-charset-list)) |
| 1309 | font-spec elt) | 1477 | font-spec elt) |
| 1310 | (ps-mule-prologue-generated) | 1478 | (ps-mule-prologue-generated) |
| 1311 | ;; If external functions are necessary, generate prologues for them. | 1479 | ;; If external functions are necessary, generate prologues for them. |
| @@ -1320,7 +1488,7 @@ This checks if all multi-byte characters in the region are printable or not." | |||
| 1320 | (ps-mule-init-external-library font-spec)))))) | 1488 | (ps-mule-init-external-library font-spec)))))) |
| 1321 | 1489 | ||
| 1322 | ;; If ASCII font is also specified in ps-mule-font-info-database, | 1490 | ;; If ASCII font is also specified in ps-mule-font-info-database, |
| 1323 | ;; use it istead of what specified in ps-font-info-database. | 1491 | ;; use it instead of what specified in ps-font-info-database. |
| 1324 | (let ((font-spec (ps-mule-get-font-spec 'ascii 'normal))) | 1492 | (let ((font-spec (ps-mule-get-font-spec 'ascii 'normal))) |
| 1325 | (if font-spec | 1493 | (if font-spec |
| 1326 | (progn | 1494 | (progn |
| @@ -1335,6 +1503,18 @@ This checks if all multi-byte characters in the region are printable or not." | |||
| 1335 | (setq font (cdr font) | 1503 | (setq font (cdr font) |
| 1336 | ps-current-font (1+ ps-current-font))))))) | 1504 | ps-current-font (1+ ps-current-font))))))) |
| 1337 | 1505 | ||
| 1506 | ;; If the header contains non-ASCII and non-Latin1 characters, prepare a font | ||
| 1507 | ;; and glyphs for the first occurance of such characters. | ||
| 1508 | (if (and ps-mule-header-charsets | ||
| 1509 | (not (eq (car ps-mule-header-charsets) 'latin-iso8859-1))) | ||
| 1510 | (let ((font-spec (ps-mule-get-font-spec (car ps-mule-header-charsets) | ||
| 1511 | 'normal))) | ||
| 1512 | (if font-spec | ||
| 1513 | ;; Be sure to download glyphs for "0123456789/" in advance for page | ||
| 1514 | ;; numbering. | ||
| 1515 | (let ((ps-current-font 0)) | ||
| 1516 | (ps-mule-prepare-font font-spec "0123456789/" 'ascii t t))))) | ||
| 1517 | |||
| 1338 | (if ps-mule-charset-list | 1518 | (if ps-mule-charset-list |
| 1339 | ;; We must change this regexp for multi-byte buffer. | 1519 | ;; We must change this regexp for multi-byte buffer. |
| 1340 | (setq ps-control-or-escape-regexp | 1520 | (setq ps-control-or-escape-regexp |