1 ;;; ps-mule.el --- Provide multi-byte character facility to ps-print.
3 ;; Copyright (C) 1998, 1999 Free Software Foundation, Inc.
5 ;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br>
6 ;; Author: 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>
9 ;; Keywords: wp, print, PostScript, multibyte, mule
10 ;; Time-stamp: <99/06/24 23:07:11 vinicius>
12 ;; This file is part of GNU Emacs.
14 ;; GNU Emacs is free software; you can redistribute it and/or modify
15 ;; it under the terms of the GNU General Public License as published by
16 ;; the Free Software Foundation; either version 2, or (at your option)
19 ;; GNU Emacs is distributed in the hope that it will be useful,
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 ;; GNU General Public License for more details.
24 ;; You should have received a copy of the GNU General Public License
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27 ;; Boston, MA 02111-1307, USA.
31 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
36 ;; This package is used for ps-print to print multi-byte buffer.
38 ;; See also ps-print.el.
41 ;; Printing Multi-byte Buffer
42 ;; --------------------------
44 ;; The variable `ps-multibyte-buffer' specifies the ps-print multi-byte buffer
47 ;; Valid values for `ps-multibyte-buffer' are:
49 ;; nil This is the value to use the default settings which
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
58 ;; `non-latin-printer' This is the value to use when you have a japanese
59 ;; or korean PostScript printer and want to print
60 ;; buffer with ASCII, Latin-1, Japanese (JISX0208 and
61 ;; JISX0201-Kana) and Korean characters. At present,
62 ;; it was not tested the Korean characters printing.
63 ;; If you have a korean PostScript printer, please,
66 ;; `bdf-font' This is the value to use when you want to print
67 ;; buffer with BDF fonts. BDF fonts include both latin
68 ;; and non-latin fonts. BDF (Bitmap Distribution
69 ;; Format) is a format used for distributing X's font
70 ;; source file. BDF fonts are included in
71 ;; `intlfonts-1.1' which is a collection of X11 fonts
72 ;; for all characters supported by Emacs. In order to
73 ;; use this value, be sure to have installed
74 ;; `intlfonts-1.1' and set the variable
75 ;; `bdf-directory-list' appropriately (see ps-bdf.el
76 ;; for documentation of this variable).
78 ;; `bdf-font-except-latin' This is like `bdf-font' except that it is used
79 ;; PostScript default fonts to print ASCII and Latin-1
80 ;; characters. This is convenient when you want or
81 ;; need to use both latin and non-latin characters on
82 ;; the same buffer. See `ps-font-family',
83 ;; `ps-header-font-family' and `ps-font-info-database'.
85 ;; Any other value is treated as nil.
87 ;; The default is nil.
89 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
93 (eval-and-compile (require 'ps-print
))
96 (require 'ps-vars
) ; Common definitions
99 ;;;; `ps-multibyte-buffer' definition should be placed in `ps-mule' but due to
100 ;;;; compilation and customization gripes it was moved to `ps-print-def'.
102 ;;(defcustom ps-multibyte-buffer nil
103 ;; "*Specifies the multi-byte buffer handling.
107 ;; nil This is the value to use the default settings which
108 ;; is by default for printing buffer with only ASCII
109 ;; and Latin characters. The default setting can be
110 ;; changed by setting the variable
111 ;; `ps-mule-font-info-database-default' differently.
112 ;; The initial value of this variable is
113 ;; `ps-mule-font-info-database-latin' (see
116 ;; `non-latin-printer' This is the value to use when you have a Japanese
117 ;; or Korean PostScript printer and want to print
118 ;; buffer with ASCII, Latin-1, Japanese (JISX0208 and
119 ;; JISX0201-Kana) and Korean characters. At present,
120 ;; it was not tested the Korean characters printing.
121 ;; If you have a korean PostScript printer, please,
124 ;; `bdf-font' This is the value to use when you want to print
125 ;; buffer with BDF fonts. BDF fonts include both latin
126 ;; and non-latin fonts. BDF (Bitmap Distribution
127 ;; Format) is a format used for distributing X's font
128 ;; source file. BDF fonts are included in
129 ;; `intlfonts-1.1' which is a collection of X11 fonts
130 ;; for all characters supported by Emacs. In order to
131 ;; use this value, be sure to have installed
132 ;; `intlfonts-1.1' and set the variable
133 ;; `bdf-directory-list' appropriately (see ps-bdf.el for
134 ;; documentation of this variable).
136 ;; `bdf-font-except-latin' This is like `bdf-font' except that it is used
137 ;; PostScript default fonts to print ASCII and Latin-1
138 ;; characters. This is convenient when you want or
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'.
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)
149 ;; For Emacs 20.2 and the earlier version.
151 (if (and (boundp 'mule-version
) ; only if mule package is loaded
152 (not (string< mule-version
"4.0")))
154 (defalias 'ps-mule-next-point
'1+)
155 (defalias 'ps-mule-chars-in-string
'length
)
156 (defalias 'ps-mule-string-char
'aref
)
157 (defsubst ps-mule-next-index
(str i
) (1+ i
)))
158 (defun ps-mule-next-point (arg)
159 (save-excursion (goto-char arg
) (forward-char 1) (point)))
160 (defun ps-mule-chars-in-string (string)
162 (charset-bytes (char-charset (string-to-char string
)))))
163 (defun ps-mule-string-char (string idx
)
164 (string-to-char (substring string idx
)))
165 (defun ps-mule-next-index (string i
)
166 (+ i
(charset-bytes (char-charset (string-to-char string
)))))
169 ;; For Emacs 20.4 and the earlier version.
171 (when (and (boundp 'mule-version
)
172 (string< mule-version
"5.0"))
173 (defun encode-composition-rule (rule)
174 (if (= (car rule
) 4) (setcar rule
10))
175 (if (= (cdr rule
) 4) (setcdr rule
10))
176 (+ (* (car rule
) 12) (cdr rule
)))
177 (defun find-composition (pos &rest ignore
)
178 (let ((ch (char-after pos
)))
179 (if (eq (char-charset ch
) 'composition
)
180 (let ((components (decompose-composite-char ch
'vector t
)))
181 (list pos
(ps-mule-next-point pos
) components
182 (integerp (aref components
1)) nil
183 (char-width ch
))))))))
185 (defvar ps-mule-font-info-database
187 "Alist of charsets with the corresponding font information.
188 Each element has the form:
190 (CHARSET (FONT-TYPE FONT-SRC FONT-NAME ENCODING BYTES) ...)
194 CHARSET is a charset (symbol) for this font family,
196 FONT-TYPE is a font type: normal, bold, italic, or bold-italic.
198 FONT-SRC is a font source: builtin, ps-bdf, vflib, or nil.
200 If FONT-SRC is builtin, FONT-NAME is a buitin PostScript font name.
202 If FONT-SRC is bdf, FONT-NAME is a BDF font file name, or a list of
203 alternative font names. To use this font, the external library `ps-bdf'
206 If FONT-SRC is vflib, FONT-NAME is the name of a font that VFlib knows.
207 To use this font, the external library `vflib' is required.
209 If FONT-SRC is nil, a proper ASCII font in the variable
210 `ps-font-info-database' is used. This is useful for Latin-1 characters.
212 ENCODING is a coding system to encode a string of characters of CHARSET into a
213 proper string matching an encoding of the specified font. ENCODING may be a
214 function that does this encoding. In this case, the function is called with
215 one argument, the string to encode, and it should return an encoded string.
217 BYTES specifies how many bytes each character has in the encoded byte
218 sequence; it should be 1 or 2.
220 All multi-byte characters are printed by fonts specified in this database
221 regardless of a font family of ASCII characters. The exception is Latin-1
222 characters which are printed by the same font as ASCII characters, thus obey
225 See also the variable `ps-font-info-database'.")
227 (defconst ps-mule-font-info-database-latin
229 (normal nil nil iso-latin-1
)))
230 "Sample setting of `ps-mule-font-info-database' to use latin fonts.")
232 (defcustom ps-mule-font-info-database-default
233 ps-mule-font-info-database-latin
234 "*The default setting to use if `ps-multibyte-buffer' is nil."
235 :type
'(repeat :tag
"Multi-Byte Buffer Database Font Default"
236 (list (symbol :tag
"Charset")
238 (list (choice :tag
"Font Type"
239 (const normal
) (const bold
)
240 (const italic
) (const bold-italic
))
241 (choice :tag
"Font Source"
242 (const builtin
) (const ps-bdf
)
244 (other :tag
"nil" nil
))
245 (list (string :tag
"Font Name"))
246 (function :tag
"Encoding")
247 (integer :tag
"Bytes")))))
248 :group
'ps-print-font
)
250 (defconst ps-mule-font-info-database-ps
252 (normal builtin
"Ryumin-Light.Katakana" ps-mule-encode-7bit
1)
253 (bold builtin
"GothicBBB-Medium.Katakana" ps-mule-encode-7bit
1)
254 (bold-italic builtin
"GothicBBB-Medium.Katakana" ps-mule-encode-7bit
1))
256 (normal builtin
"Ryumin-Light.Hankaku" ps-mule-encode-7bit
1)
257 (bold builtin
"GothicBBB-Medium.Hankaku" ps-mule-encode-7bit
1))
259 (normal builtin
"Ryumin-Light-H" ps-mule-encode-7bit
2)
260 (bold builtin
"GothicBBB-Medium-H" ps-mule-encode-7bit
2))
262 (normal builtin
"Munhwa-Regular-KSC-EUC-H" ps-mule-encode-7bit
2)
263 (bold builtin
"Munhwa-Bold-KSC-EUC-H" ps-mule-encode-7bit
2))
265 "Sample setting of the `ps-mule-font-info-database' to use builtin PS font.
267 Currently, data for Japanese and Korean PostScript printers are listed.")
269 (defconst ps-mule-font-info-database-bdf
271 (normal bdf
("lt1-24-etl.bdf" "etl24-latin1.bdf") nil
1)
272 (bold bdf
("lt1-16b-etl.bdf" "etl16b-latin1.bdf") nil
1)
273 (italic bdf
("lt1-16i-etl.bdf" "etl16i-latin1.bdf") nil
1)
274 (bold-italic bdf
("lt1-16bi-etl.bdf" "etl16bi-latin1.bdf") nil
1))
276 (normal bdf
("lt1-24-etl.bdf" "etl24-latin1.bdf") iso-latin-1
1)
277 (bold bdf
("lt1-16b-etl.bdf" "etl16b-latin1.bdf") iso-latin-1
1)
278 (italic bdf
("lt1-16i-etl.bdf" "etl16i-latin1.bdf") iso-latin-1
1)
279 (bold-italic bdf
("lt1-16bi-etl.bdf" "etl16bi-latin1.bdf") iso-latin-1
1))
281 (normal bdf
("lt2-24-etl.bdf" "etl24-latin2.bdf") iso-latin-2
1))
283 (normal bdf
("lt3-24-etl.bdf" "etl24-latin3.bdf") iso-latin-3
1))
285 (normal bdf
("lt4-24-etl.bdf" "etl24-latin4.bdf") iso-latin-4
1))
287 (normal bdf
("thai24.bdf" "thai-24.bdf") thai-tis620
1))
289 (normal bdf
("grk24-etl.bdf" "etl24-greek.bdf") greek-iso-8bit
1))
290 ;; (arabic-iso8859-6 nil) ; not yet available
292 (normal bdf
("heb24-etl.bdf" "etl24-hebrew.bdf") hebrew-iso-8bit
1))
294 (normal bdf
"12x24rk.bdf" ps-mule-encode-8bit
1))
296 (normal bdf
"12x24rk.bdf" ps-mule-encode-7bit
1))
298 (normal bdf
("cyr24-etl.bdf" "etl24-cyrillic.bdf") cyrillic-iso-8bit
1))
300 (normal bdf
("lt5-24-etl.bdf" "etl24-latin5.bdf") iso-latin-5
1))
301 (japanese-jisx0208-1978
302 (normal bdf
"jiskan24.bdf" ps-mule-encode-7bit
2))
304 (normal bdf
"gb24st.bdf" ps-mule-encode-7bit
2))
306 (normal bdf
"jiskan24.bdf" ps-mule-encode-7bit
2))
308 (normal bdf
"hanglm24.bdf" ps-mule-encode-7bit
2))
310 (normal bdf
("jksp40.bdf" "jisksp40.bdf") ps-mule-encode-7bit
2))
312 (normal bdf
("cns1-40.bdf" "cns-1-40.bdf") ps-mule-encode-7bit
2))
314 (normal bdf
("cns2-40.bdf" "cns-2-40.bdf") ps-mule-encode-7bit
2))
316 (normal bdf
"taipei24.bdf" chinese-big5
2))
318 (normal bdf
"taipei24.bdf" chinese-big5
2))
320 (normal bdf
("sish24-etl.bdf" "etl24-sisheng.bdf") ps-mule-encode-7bit
1))
322 (normal bdf
("ipa24-etl.bdf" "etl24-ipa.bdf") ps-mule-encode-8bit
1))
323 (vietnamese-viscii-lower
324 (normal bdf
("visc24-etl.bdf" "etl24-viscii.bdf") vietnamese-viscii
1))
325 (vietnamese-viscii-upper
326 (normal bdf
("visc24-etl.bdf" "etl24-viscii.bdf") vietnamese-viscii
1))
328 (normal bdf
("arab24-0-etl.bdf" "etl24-arabic0.bdf") ps-mule-encode-7bit
1))
330 (normal bdf
("arab24-1-etl.bdf" "etl24-arabic1.bdf") ps-mule-encode-7bit
1))
331 ;; (ascii-right-to-left nil) ; not yet available
333 (normal bdf
("lao24-mule.bdf" "mule-lao-24.bdf") lao
1))
335 (normal bdf
("arab24-2-etl.bdf" "etl24-arabic2.bdf") ps-mule-encode-7bit
1))
337 (normal bdf
("isci24-etl.bdf" "mule-iscii-24.bdf") ps-mule-encode-7bit
1))
339 (normal bdf
("ind1c24-mule.bdf" "mule-indian-1col-24.bdf") ps-mule-encode-7bit
2))
341 (normal bdf
("tib1c24-mule.bdf" "mule-tibmdx-1col-24.bdf") ps-mule-encode-7bit
2))
343 (normal bdf
("ethio24f-uni.bdf" "ethiomx24f-uni.bdf") ps-mule-encode-ethiopic
2))
345 (normal bdf
("cns3-40.bdf" "cns-3-40.bdf") ps-mule-encode-7bit
2))
347 (normal bdf
("cns4-40.bdf" "cns-4-40.bdf") ps-mule-encode-7bit
2))
349 (normal bdf
("cns5-40.bdf" "cns-5-40.bdf") ps-mule-encode-7bit
2))
351 (normal bdf
("cns6-40.bdf" "cns-6-40.bdf") ps-mule-encode-7bit
2))
353 (normal bdf
("cns7-40.bdf" "cns-7-40.bdf") ps-mule-encode-7bit
2))
355 (normal bdf
("ind24-mule.bdf" "mule-indian-24.bdf") ps-mule-encode-7bit
2))
357 (normal bdf
("tib24-mule.bdf" "mule-tibmdx-24.bdf") ps-mule-encode-7bit
2)))
358 "Sample setting of the `ps-mule-font-info-database' to use BDF fonts.
359 BDF (Bitmap Distribution Format) is a format used for distributing X's font
362 Current default value list for BDF fonts is included in `intlfonts-1.1' which is
363 a collection of X11 fonts for all characters supported by Emacs.
365 Using this list as default value to `ps-mule-font-info-database', all characters
366 including ASCII and Latin-1 are printed by BDF fonts.
368 See also `ps-mule-font-info-database-ps-bdf'.")
370 (defconst ps-mule-font-info-database-ps-bdf
371 (cons (car ps-mule-font-info-database-latin
)
372 (cdr (cdr ps-mule-font-info-database-bdf
)))
373 "Sample setting of the `ps-mule-font-info-database' to use BDF fonts.
375 Current default value list for BDF fonts is included in `intlfonts-1.1' which is
376 a collection of X11 fonts for all characters supported by Emacs.
378 Using this list as default value to `ps-mule-font-info-database', all characters
379 except ASCII and Latin-1 characters are printed by BDF fonts. ASCII and Latin-1
380 characters are printed by PostScript font specified by `ps-font-family' and
381 `ps-header-font-family'.
383 See also `ps-mule-font-info-database-bdf'.")
385 ;; Two typical encoding functions for PostScript fonts.
387 (defun ps-mule-encode-7bit (string)
388 (ps-mule-encode-bit string
0))
390 (defun ps-mule-encode-8bit (string)
391 (ps-mule-encode-bit string
128))
393 (defun ps-mule-encode-bit (string delta
)
394 (let* ((dim (charset-dimension (char-charset (string-to-char string
))))
395 (len (* (ps-mule-chars-in-string string
) dim
))
396 (str (make-string len
0))
402 (+ (nth 1 (split-char (ps-mule-string-char string i
))) delta
))
403 (setq i
(ps-mule-next-index string i
)
406 (let ((split (split-char (ps-mule-string-char string i
))))
407 (aset str j
(+ (nth 1 split
) delta
))
408 (aset str
(1+ j
) (+ (nth 2 split
) delta
))
409 (setq i
(ps-mule-next-index string i
)
413 ;; Special encoding function for Ethiopic.
414 (if (boundp 'mule-version
) ; only if mule package is loaded
415 (define-ccl-program ccl-encode-ethio-unicode
419 (if (r2 == ,leading-code-private-22
)
421 (if (r0 == ,(charset-id 'ethiopic
))
423 (r1 &= 127) (r2 &= 127)
424 (call ccl-encode-ethio-font
)
426 (write-read-repeat r2
))
429 (write-read-repeat r2
))))))
430 ;; to avoid compilation gripes
431 (defvar ccl-encode-ethio-unicode nil
))
433 (if (boundp 'mule-version
)
434 ;; bound mule-version
435 (defun ps-mule-encode-ethiopic (string)
436 (ccl-execute-on-string (symbol-value 'ccl-encode-ethio-unicode
)
439 ;; unbound mule-version
440 (defun ps-mule-encode-ethiopic (string)
443 ;; A charset which we are now processing.
444 (defvar ps-mule-current-charset nil
)
446 (defun ps-mule-get-font-spec (charset font-type
)
447 "Return FONT-SPEC for printing characters CHARSET with FONT-TYPE.
448 FONT-SPEC is a list that has the form:
450 (FONT-SRC FONT-NAME ENCODING BYTES)
452 FONT-SPEC is extracted from `ps-mule-font-info-database'.
454 See the documentation of `ps-mule-font-info-database' for the meaning of each
455 element of the list."
456 (let ((slot (cdr (assq charset ps-mule-font-info-database
))))
458 (cdr (or (assq font-type slot
)
459 (and (eq font-type
'bold-italic
)
460 (or (assq 'bold slot
) (assq 'italic slot
)))
461 (assq 'normal slot
))))))
463 ;; Functions to access each element of FONT-SPEC.
464 (defsubst ps-mule-font-spec-src
(font-spec) (car font-spec
))
465 (defsubst ps-mule-font-spec-name
(font-spec) (nth 1 font-spec
))
466 (defsubst ps-mule-font-spec-encoding
(font-spec) (nth 2 font-spec
))
467 (defsubst ps-mule-font-spec-bytes
(font-spec) (nth 3 font-spec
))
469 (defsubst ps-mule-printable-p
(charset)
470 "Non-nil if characters in CHARSET is printable."
471 (ps-mule-get-font-spec charset
'normal
))
473 (defconst ps-mule-external-libraries
477 bdf-generate-prologue bdf-generate-font bdf-generate-glyphs
)
479 pcf-generate-prologue pcf-generate-font pcf-generate-glyphs
)
481 vflib-generate-prologue vflib-generate-font vflib-generate-glyphs
))
482 "Alist of information of external libraries to support PostScript printing.
483 Each element has the form:
485 (FONT-SRC FEATURE INITIALIZED-P PROLOGUE-FUNC FONT-FUNC GLYPHS-FUNC)
487 FONT-SRC is the font source: builtin, bdf, pcf, or vflib.
489 FEATURE is the feature that provide a facility to handle FONT-SRC. Except for
490 `builtin' FONT-SRC, this feature is automatically `require'd before handling
491 FONT-SRC. Currently, we only have the feature `ps-bdf'.
493 INITIALIZED-P indicates if this library is initialized or not.
495 PROLOGUE-FUNC is a function to generate PostScript code which define several
496 PostScript procedures that will be called by FONT-FUNC and GLYPHS-FUNC. It is
497 called with no argument, and should return a list of strings.
499 FONT-FUNC is a function to generate PostScript code which define a new font. It
500 is called with one argument FONT-SPEC, and should return a list of strings.
502 GLYPHS-FUNC is a function to generate PostScript code which define glyphs of
503 characters. It is called with three arguments FONT-SPEC, CODE-LIST, and BYTES,
504 and should return a list of strings.")
506 (defun ps-mule-init-external-library (font-spec)
507 "Initialize external library specified by FONT-SPEC for PostScript printing.
508 See the documentation of `ps-mule-get-font-spec' for FONT-SPEC's meaning."
509 (let* ((font-src (ps-mule-font-spec-src font-spec
))
510 (slot (assq font-src ps-mule-external-libraries
)))
513 (let ((func (nth 3 slot
)))
516 (require (nth 1 slot
))
517 (ps-output-prologue (funcall func
))))
518 (setcar (nthcdr 2 slot
) t
)))))
520 ;; Cached glyph information of fonts, alist of:
521 ;; (FONT-NAME ((FONT-TYPE-NUMBER . SCALED-FONT-NAME) ...)
522 ;; cache CODE0 CODE1 ...)
523 (defvar ps-mule-font-cache nil
)
525 (defun ps-mule-generate-font (font-spec charset
)
526 "Generate PostScript codes to define a new font in FONT-SPEC for CHARSET."
527 (let* ((font-name (ps-mule-font-spec-name font-spec
))
528 (font-name (if (consp font-name
) (car font-name
) font-name
))
529 (font-cache (assoc font-name ps-mule-font-cache
))
530 (font-src (ps-mule-font-spec-src font-spec
))
531 (func (nth 4 (assq font-src ps-mule-external-libraries
)))
533 (if (eq charset
'ascii
)
534 (format "f%d" ps-current-font
)
536 (charset-id charset
) ps-current-font
))))
537 (and func
(not font-cache
)
538 (ps-output-prologue (funcall func charset font-spec
)))
540 (list (format "/%s %f /%s Def%sFontMule\n"
541 scaled-font-name ps-font-size-internal font-name
542 (if (eq ps-mule-current-charset
'ascii
) "Ascii" ""))))
544 (setcar (cdr font-cache
)
545 (cons (cons ps-current-font scaled-font-name
)
547 (setq font-cache
(list font-name
548 (list (cons ps-current-font scaled-font-name
))
550 ps-mule-font-cache
(cons font-cache ps-mule-font-cache
)))
553 (defun ps-mule-generate-glyphs (font-spec code-list
)
554 "Generate PostScript codes which generate glyphs for CODE-LIST of FONT-SPEC."
555 (let* ((font-src (ps-mule-font-spec-src font-spec
))
556 (func (nth 5 (assq font-src ps-mule-external-libraries
))))
559 (funcall func font-spec code-list
560 (ps-mule-font-spec-bytes font-spec
))))))
562 (defun ps-mule-prepare-font (font-spec string charset
&optional no-setfont
)
563 "Generate PostScript codes to print STRING of CHARSET by font FONT-SPEC.
565 The generated code is inserted on prologue part except the code that sets the
566 current font (using PostScript procedure `FM').
568 If optional arg NO-SETFONT is non-nil, don't generate the code for setting the
570 (let* ((font-name (ps-mule-font-spec-name font-spec
))
571 (font-name (if (consp font-name
) (car font-name
) font-name
))
572 (font-cache (assoc font-name ps-mule-font-cache
)))
573 (or (and font-cache
(assq ps-current-font
(nth 1 font-cache
)))
574 (setq font-cache
(ps-mule-generate-font font-spec charset
)))
576 (let ((new-font (cdr (assq ps-current-font
(nth 1 font-cache
)))))
577 (or (equal new-font ps-last-font
)
579 (ps-output (format "/%s FM\n" new-font
))
580 (setq ps-last-font new-font
)))))
581 (if (nth 5 (assq (ps-mule-font-spec-src font-spec
)
582 ps-mule-external-libraries
))
583 ;; We have to generate PostScript codes which define glyphs.
584 (let* ((cached-codes (nthcdr 2 font-cache
))
585 (bytes (ps-mule-font-spec-bytes font-spec
))
586 (len (length string
))
590 (setq code
(if (= bytes
1)
592 (+ (* (aref string i
) 256) (aref string
(1+ i
)))))
593 (or (memq code cached-codes
)
595 (setq newcodes
(cons code newcodes
))
596 (setcdr cached-codes
(cons code
(cdr cached-codes
)))))
597 (setq i
(+ i bytes
)))
599 (ps-mule-generate-glyphs font-spec newcodes
))))))
602 (defun ps-mule-prepare-ascii-font (string)
603 "Setup special ASCII font for STRING.
604 STRING should contain only ASCII characters."
606 (ps-mule-get-font-spec
608 (car (nth ps-current-font
(ps-font-alist 'ps-font-for-text
))))))
610 (ps-mule-prepare-font font-spec string
'ascii
))))
613 (defun ps-mule-set-ascii-font ()
614 (unless (eq ps-mule-current-charset
'ascii
)
615 (ps-set-font ps-current-font
)
616 (setq ps-mule-current-charset
'ascii
)))
618 ;; List of charsets of multi-byte characters in a text being printed.
619 ;; If the text doesn't contain any multi-byte characters (i.e. only ASCII),
621 (defvar ps-mule-charset-list nil
)
623 ;; This is a PostScript code inserted in the header of generated PostScript.
624 (defconst ps-mule-prologue
625 "%%%% Start of Mule Section
627 %% Working dictionary for general use.
628 /MuleDict 10 dict def
630 %% Adjust /RelativeCompose properly by checking /BaselineOffset.
631 /AdjustRelativeCompose { % fontdict |- fontdict
632 dup length 2 add dict begin
633 { 1 index /FID ne { def } { pop pop } ifelse } forall
634 currentdict /BaselineOffset known {
635 BaselineOffset false eq { /BaselinfOffset 0 def } if
637 /BaselineOffset 0 def
639 currentdict /RelativeCompose known not {
640 /RelativeCompose [ 0 0.1 ] def
642 RelativeCompose false ne {
643 [ BaselineOffset RelativeCompose BaselineOffset add
644 [ FontMatrix { FontSize div } forall ] transform ]
645 /RelativeCompose exch def
652 %% Define already scaled font for non-ASCII character sets.
653 /DefFontMule { % fontname size basefont |- --
654 findfont exch scalefont AdjustRelativeCompose definefont pop
657 %% Define already scaled font for ASCII character sets.
658 /DefAsciiFontMule { % fontname size basefont |-
660 findfont dup /Encoding get /ISOLatin1Encoding exch def
661 exch scalefont AdjustRelativeCompose reencodeFontISO
665 /CurrentFont false def
667 %% Set the specified font to use.
668 %% For non-ASCII font, don't install Ascent, etc.
669 /FM { % fontname |- --
671 font /f0 eq font /f1 eq font /f2 eq font /f3 eq or or or {
674 font findfont setfont
678 %% Show vacant box for characters which don't have appropriate font.
679 /SB { % count column |- --
680 SpaceWidth mul /w exch def
685 0 Descent rmoveto w 0 rlineto
686 0 LineHeight rlineto w neg 0 rlineto closepath stroke
692 %% Flag to tell if we are now handling a composition. This is
693 %% defined here because both composition handler and bitmap font
694 %% handler require it.
697 %%%% End of Mule Section
700 "PostScript code for printing multi-byte characters.")
702 (defvar ps-mule-prologue-generated nil
)
704 (defun ps-mule-prologue-generated ()
705 (unless ps-mule-prologue-generated
706 (ps-output-prologue ps-mule-prologue
)
707 (setq ps-mule-prologue-generated t
)))
709 (defun ps-mule-find-wrappoint (from to char-width
&optional composition
)
710 "Find the longest sequence which is printable in the current line.
712 The search starts at FROM and goes until TO.
714 Optional 4th arg COMPOSITION, if non-nil, is information of
715 composition starting at FROM.
717 If COMPOSTION is nil, it is assumed that all characters between FROM
718 and TO belong to a charset in `ps-mule-current-charset'. Otherwise,
719 it is assumed that all characters between FROM and TO belong to the
722 CHAR-WIDTH is the average width of ASCII characters in the current font.
728 Where ENDPOS is the end position of the sequence and RUN-WIDTH is the width of
730 (if (or composition
(eq ps-mule-current-charset
'composition
))
731 ;; We must draw one char by one.
732 (let ((run-width (if composition
734 (* (char-width (char-after from
)) char-width
))))
735 (if (> run-width ps-width-remaining
)
736 (cons from ps-width-remaining
)
737 (cons (if composition
739 (ps-mule-next-point from
))
741 ;; We assume that all characters in this range have the same width.
742 (setq char-width
(* char-width
(charset-width ps-mule-current-charset
)))
743 (let ((run-width (* (chars-in-region from to
) char-width
)))
744 (if (> run-width ps-width-remaining
)
749 (truncate (/ ps-width-remaining char-width
)))))
751 (cons to run-width
)))))
754 (defun ps-mule-plot-string (from to
&optional bg-color
)
755 "Generate PostScript code for ploting characters in the region FROM and TO.
757 It is assumed that all characters in this region belong to the same charset.
759 Optional argument BG-COLOR specifies background color.
765 Where ENDPOS is the end position of the sequence and RUN-WIDTH is the width of
767 (setq ps-mule-current-charset
(charset-after from
))
768 (let* ((wrappoint (ps-mule-find-wrappoint
769 from to
(ps-avg-char-width 'ps-font-for-text
)))
771 (font-type (car (nth ps-current-font
772 (ps-font-alist 'ps-font-for-text
))))
773 (font-spec (ps-mule-get-font-spec ps-mule-current-charset font-type
))
774 (string (buffer-substring-no-properties from to
)))
777 ;; We can't print any more characters in the current line.
781 ;; We surely have a font for printing this character set.
782 (ps-output-string (ps-mule-string-encoding font-spec string
))
785 ((eq ps-mule-current-charset
'latin-iso8859-1
)
786 ;; Latin-1 can be printed by a normal ASCII font.
787 (ps-output-string (ps-mule-string-ascii string
))
790 ;; This case is obsolete for Emacs 21.
791 ((eq ps-mule-current-charset
'composition
)
792 (ps-mule-plot-composition from
(ps-mule-next-point from
) bg-color
))
795 ;; No way to print this charset. Just show a vacant box of an
796 ;; appropriate width.
797 (ps-output (format "%d %d SB\n"
799 (if (eq ps-mule-current-charset
'composition
)
800 (char-width (char-after from
))
801 (charset-width ps-mule-current-charset
))))))
805 (defun ps-mule-plot-composition (from to
&optional bg-color
)
806 "Generate PostScript code for ploting composition in the region FROM and TO.
808 It is assumed that all characters in this region belong to the same
811 Optional argument BG-COLOR specifies background color.
817 Where ENDPOS is the end position of the sequence and RUN-WIDTH is the width of
819 (let* ((composition (find-composition from nil nil t
))
820 (wrappoint (ps-mule-find-wrappoint
821 from to
(ps-avg-char-width 'ps-font-for-text
)
824 (font-type (car (nth ps-current-font
825 (ps-font-alist 'ps-font-for-text
)))))
827 ;; We can print this composition in the current line.
828 (let ((components (nth 2 composition
)))
829 (ps-mule-plot-components
830 (ps-mule-prepare-font-for-components components font-type
)
831 (if (nth 3 composition
) "RLC" "RBC"))))
834 ;; Prepare font of FONT-TYPE for printing COMPONENTS. By side effect,
835 ;; change character elements in COMPONENTS to the form:
836 ;; ENCODED-STRING or (FONTNAME . ENCODED-STRING)
837 ;; and change rule elements to the encoded value (integer).
838 ;; The latter form is used if we much change font for the character.
840 (defun ps-mule-prepare-font-for-components (components font-type
)
841 (let ((len (length components
))
845 (setq elt
(aref components i
))
847 ;; ELT is a composition rule.
848 (setq elt
(encode-composition-rule elt
))
849 ;; ELT is a glyph character.
850 (let* ((charset (char-charset elt
))
851 (font (or (eq charset ps-mule-current-charset
)
852 (if (eq charset
'ascii
)
853 (format "/f%d" ps-current-font
)
855 (charset-id charset
) ps-current-font
))))
857 (setq ps-mule-current-charset charset
858 str
(ps-mule-string-encoding
859 (ps-mule-get-font-spec charset font-type
)
863 (setq elt
(cons font str
) ps-last-font font
)
865 (aset components i elt
)
869 (defun ps-mule-plot-components (components tail
)
870 (let ((elt (aref components
0))
871 (len (length components
))
875 (ps-output-string elt
)
876 (ps-output (car elt
) " ")
877 (ps-output-string (cdr elt
)))
879 (setq elt
(aref components i
) i
(1+ i
))
882 (ps-output-string elt
))
884 (ps-output (car elt
) " ")
885 (ps-output-string (cdr elt
)))
886 (t ; i.e. (integerp elt)
887 (ps-output (format "%d" elt
)))))
888 (ps-output " ] " tail
"\n")))
890 ;; Composite font support
892 (defvar ps-mule-composition-prologue-generated nil
)
894 (defconst ps-mule-composition-prologue
895 "%%%% Character compositition handler
896 /RelativeCompositionSkip 0.4 def
898 %% Get a bounding box (relative to currentpoint) of STR.
899 /GetPathBox { % str |- --
901 currentfont /FontType get 3 eq { %ifelse
904 currentpoint /y exch def /x exch def
905 false charpath flattenpath pathbbox
906 y sub /URY exch def x sub /URX exch def
907 y sub /LLY exch def x sub /LLX exch def
912 %% Apply effects (underline, strikeout, overline, box) to the
913 %% rectangle specified by TOP BOTTOM LEFT RIGHT.
914 /SpecialEffect { % -- |- --
915 currentpoint dup TOP add /yy exch def BOTTOM add /YY exch def
916 dup LEFT add /xx exch def RIGHT add /XX exch def
917 %% Adjust positions for future shadowing.
919 /yy yy Yshadow add def
920 /XX XX Xshadow add def
922 Effect 1 and 0 ne { UnderlinePosition Hline } if % underline
923 Effect 2 and 0 ne { StrikeoutPosition Hline } if % strikeout
924 Effect 4 and 0 ne { OverlinePosition Hline } if % overline
927 Effect 16 and 0 ne {SpaceBackground doBox} { xx yy XX YY doRect} ifelse
929 Effect 16 and 0 ne { false 0 doBox } if % box
932 %% Show STR with effects (shadow, outline).
933 /ShowWithEffect { % str |- --
934 Effect 8 and 0 ne { dup doShadow } if
935 Effect 32 and 0 ne { true doOutline } { show } ifelse
938 %% Draw COMPONETS which have the form [ font0? [str0 xoff0 yoff0] ... ].
939 /ShowComponents { % compoents |- -
940 LEFT 0 lt { LEFT neg 0 rmoveto } if
942 dup type /nametype eq { % font
944 } { % [ str xoff yoff ]
946 aload pop rmoveto ShowWithEffect
953 %% Show relative composition.
954 /RLC { % [ font0? str0 font1? str1 ... fontN? strN ] |- --
961 elt type /nametype eq { % font
963 } { first { % first string
966 %% Bounding box of overall glyphs.
971 currentfont /RelativeCompose known {
972 /relative currentfont /RelativeCompose get def
974 %% Disable relative composition by setting sufficiently low
975 %% and high positions.
976 /relative [ -100000 100000 ] def
982 LLX 0 lt { RIGHT } { 0 } ifelse % xoff
983 LLY relative 1 get ge { % compose on TOP
984 TOP LLY sub RelativeCompositionSkip add % yoff
985 /TOP TOP URY LLY sub add RelativeCompositionSkip add def
986 } { URY relative 0 get le { % compose under BOTTOM
987 BOTTOM URY sub RelativeCompositionSkip sub % yoff
988 /BOTTOM BOTTOM URY LLY sub sub
989 RelativeCompositionSkip sub def
992 URY TOP gt { /TOP URY def } if
993 LLY BOTTOM lt { /BOTTOM LLY def } if
996 URX RIGHT gt { /RIGHT URX def } if
998 } forall ] /components exch def
1001 %% Reflect special effects.
1004 %% Draw components while ignoring effects other than shadow and outline.
1005 components ShowComponents
1006 /Composing false def
1010 %% Show rule-base composition.
1011 /RBC { % [ font0? str0 rule1 font1? str1 rule2 ... strN ] |- --
1012 /components exch def
1018 elt type /nametype eq { % font
1020 } { elt type /integertype eq { % rule
1021 %% This RULE decoding should be compatible with macro
1022 %% COMPOSITION_DECODE_RULE in emcas/src/composite.h.
1023 elt 12 idiv dup 3 mod /grefx exch def 3 idiv /grefy exch def
1024 elt 12 mod dup 3 mod /nrefx exch def 3 idiv /nrefy exch def
1025 } { first { % first string
1028 %% Bounding box of overall glyphs.
1033 /WIDTH RIGHT LEFT sub def
1037 /width URX LLX sub def
1038 /height URY LLY sub def
1039 /left LEFT [ 0 WIDTH 2 div WIDTH ] grefx get add
1040 [ 0 width 2 div width ] nrefx get sub def
1041 /bottom [ TOP 0 BOTTOM TOP BOTTOM add 2 div ] grefy get
1042 [ height LLY neg 0 height 2 div ] nrefy get sub def
1043 %% Update bounding box
1044 left LEFT lt { /LEFT left def } if
1045 left width add RIGHT gt { /RIGHT left width add def } if
1046 /WIDTH RIGHT LEFT sub def
1047 bottom BOTTOM lt { /BOTTOM bottom def } if
1048 bottom height add TOP gt { /TOP bottom height add def } if
1049 [ elt left LLX sub bottom LLY sub ]
1050 } ifelse } ifelse } ifelse
1051 } forall ] /components exch def
1054 %% Reflect special effects.
1057 %% Draw components while ignoring effects other than shadow and outline.
1058 components ShowComponents
1060 /Composing false def
1062 %%%% End of character composition handler
1065 "PostScript code for printing character compositition.")
1067 (defun ps-mule-string-ascii (str)
1068 (ps-set-font ps-current-font
)
1069 (string-as-unibyte (encode-coding-string str
'iso-latin-1
)))
1071 ;; Encode STR for a font specified by FONT-SPEC and return the result.
1072 ;; If necessary, Postscript codes for the font and glyphs to print
1073 ;; STRING are generated.
1074 (defun ps-mule-string-encoding (font-spec str
&optional no-setfont
)
1075 (let ((encoding (ps-mule-font-spec-encoding font-spec
)))
1078 (cond ((coding-system-p encoding
)
1079 (encode-coding-string str encoding
))
1080 ((functionp encoding
)
1081 (funcall encoding str
))
1083 (error "Invalid coding system or function: %s" encoding
))
1086 (if (ps-mule-font-spec-src font-spec
)
1087 (ps-mule-prepare-font font-spec str ps-mule-current-charset no-setfont
)
1089 (ps-set-font ps-current-font
)))
1092 ;; Bitmap font support
1094 (defvar ps-mule-bitmap-prologue-generated nil
)
1096 (defconst ps-mule-bitmap-prologue
1097 "%%%% Bitmap font handler
1099 /str7 7 string def % working area
1101 %% We grow the dictionary one bunch (1024 entries) by one.
1102 /BitmapDictArray 256 array def
1103 /BitmapDictLength 1024 def
1104 /BitmapDictIndex -1 def
1106 /NewBitmapDict { % -- |- --
1107 /BitmapDictIndex BitmapDictIndex 1 add def
1108 BitmapDictArray BitmapDictIndex BitmapDictLength dict put
1111 %% Make at least one dictionary.
1114 /AddBitmap { % gloval-charname bitmap-data |- --
1115 BitmapDictArray BitmapDictIndex get
1116 dup length BitmapDictLength ge {
1119 BitmapDictArray BitmapDictIndex get
1124 /GetBitmap { % gloval-charname |- bitmap-data
1125 0 1 BitmapDictIndex { BitmapDictArray exch get begin } for
1127 0 1 BitmapDictIndex { pop end } for
1130 %% Return a global character name which can be used as a key in the
1131 %% bitmap dictionary.
1132 /GlobalCharName { % fontidx code1 code2 |- gloval-charname
1133 exch 256 mul add exch 65536 mul add 16777216 add 16 str7 cvrs 0 66 put
1137 %% Character code holder for a 2-byte character.
1140 %% Glyph rendering procedure
1141 /BuildGlyphCommon { % fontdict charname |- --
1142 1 index /FontDimension get 1 eq { /FirstCode 0 store } if
1143 NameIndexDict exch get % STACK: fontdict charcode
1144 FirstCode 0 lt { %ifelse
1145 %% This is the first byte of a 2-byte character. Just
1146 %% remember it for the moment.
1147 /FirstCode exch store
1151 1 index /FontSize get /size exch def
1152 1 index /FontSpaceWidthRatio get /ratio exch def
1153 1 index /FontIndex get exch FirstCode exch
1154 GlobalCharName GetBitmap /bmp exch def
1155 %% bmp == [ DWIDTH BBX-WIDTH BBX-HEIGHT BBX-XOFF BBX-YOFF BITMAP ]
1157 /FontMatrix get [ exch { size div } forall ] /mtrx exch def
1158 bmp 3 get bmp 4 get mtrx transform
1159 /LLY exch def /LLX exch def
1160 bmp 1 get bmp 3 get add bmp 2 get bmp 4 get add mtrx transform
1161 /URY exch def /URX exch def
1167 bmp 0 get SpaceWidthRatio ratio div mul size div 0 % wx wy
1168 setcharwidth % We can't use setcachedevice here.
1170 bmp 1 get 0 gt bmp 2 get 0 gt and {
1171 bmp 1 get bmp 2 get % width height
1173 [ size 0 0 size neg bmp 3 get neg bmp 2 get bmp 4 get add ] % matrix
1174 bmp 5 1 getinterval cvx % datasrc
1181 1 index /Encoding get exch get
1182 1 index /BuildGlyph get exec
1185 %% Bitmap font creater
1187 %% Common Encoding shared by all bitmap fonts.
1188 /EncodingCommon 256 array def
1189 %% Mapping table from character name to character code.
1190 /NameIndexDict 256 dict def
1193 /idxname idx 256 add 16 (XXX) cvrs dup 0 67 put cvn def % `C' == 67
1194 EncodingCommon idx idxname put
1195 NameIndexDict idxname idx put
1198 /GlobalFontIndex 0 def
1200 %% fontname dim col fontsize relative-compose baseline-offset fbbx |- --
1204 /BaselineOffset exch def
1205 /RelativeCompose exch def
1207 /FontBBox [ FontBBox { FontSize div } forall ] def
1208 FontBBox 2 get FontBBox 0 get sub exch div
1209 /FontSpaceWidthRatio exch def
1210 /FontDimension exch def
1211 /FontIndex GlobalFontIndex def
1213 /FontMatrix matrix def
1214 /Encoding EncodingCommon def
1215 /BuildGlyph { BuildGlyphCommon } def
1216 /BuildChar { BuildCharCommon } def
1219 /GlobalFontIndex GlobalFontIndex 1 add def
1222 %% Define a new bitmap font.
1223 %% fontname dim col fontsize relative-compose baseline-offset fbbx |- --
1226 %% Convert BDF's FontBoundingBox to PostScript's FontBBox
1227 [ fbbx 2 get fbbx 3 get
1228 fbbx 2 get fbbx 0 get add fbbx 3 get fbbx 1 get add ]
1232 %% Define a glyph for the specified font and character.
1233 /NG { % fontname charcode bitmap-data |- --
1235 exch findfont dup /BaselineOffset get bmp 4 get add bmp exch 4 exch put
1237 dup 256 idiv exch 256 mod GlobalCharName
1240 %%%% End of bitmap font handler
1244 ;; External library support.
1246 ;; The following three functions are to be called from external
1247 ;; libraries which support bitmap fonts (e.g. `bdf') to get
1248 ;; appropriate PostScript code.
1250 (defun ps-mule-generate-bitmap-prologue ()
1251 (unless ps-mule-bitmap-prologue-generated
1252 (setq ps-mule-bitmap-prologue-generated t
)
1253 (list ps-mule-bitmap-prologue
)))
1255 (defun ps-mule-generate-bitmap-font (&rest args
)
1256 (list (apply 'format
"/%s %d %d %f %S %d %S NF\n" args
)))
1258 (defun ps-mule-generate-bitmap-glyph (font-name code dwidth bbx bitmap
)
1259 (format "/%s %d [ %d %d %d %d %d <%s> ] NG\n"
1261 dwidth
(aref bbx
0) (aref bbx
1) (aref bbx
2) (aref bbx
3)
1264 ;; Mule specific initializers.
1267 (defun ps-mule-initialize ()
1268 "Initialize global data for printing multi-byte characters."
1269 (setq ps-mule-font-cache nil
1270 ps-mule-prologue-generated nil
1271 ps-mule-composition-prologue-generated nil
1272 ps-mule-bitmap-prologue-generated nil
)
1273 (mapcar `(lambda (x) (setcar (nthcdr 2 x
) nil
))
1274 ps-mule-external-libraries
))
1277 (defun ps-mule-begin-job (from to
)
1278 "Start printing job for multi-byte chars between FROM and TO.
1279 This checks if all multi-byte characters in the region are printable or not."
1280 (setq ps-mule-charset-list nil
1281 ps-mule-font-info-database
1282 (cond ((eq ps-multibyte-buffer
'non-latin-printer
)
1283 ps-mule-font-info-database-ps
)
1284 ((eq ps-multibyte-buffer
'bdf-font
)
1285 ps-mule-font-info-database-bdf
)
1286 ((eq ps-multibyte-buffer
'bdf-font-except-latin
)
1287 ps-mule-font-info-database-ps-bdf
)
1289 ps-mule-font-info-database-default
)))
1290 (and (boundp 'enable-multibyte-characters
)
1291 enable-multibyte-characters
1292 ;; Initialize `ps-mule-charset-list'. If some characters aren't
1293 ;; printable, warn it.
1294 (let ((charsets (find-charset-region from to
)))
1295 (setq charsets
(delq 'ascii
(delq 'unknown
(delq nil charsets
)))
1296 ps-mule-charset-list charsets
)
1299 (and (search-forward "\200" to t
)
1300 (setq ps-mule-charset-list
1301 (cons 'composition ps-mule-charset-list
))))
1305 ((or (eq (car charsets
) 'composition
)
1306 (ps-mule-printable-p (car charsets
)))
1309 "Font for some characters not found, continue anyway? ")
1312 (error "Printing cancelled")))))))
1314 (setq ps-mule-current-charset
'ascii
)
1316 (if (and (nth 2 (find-composition from to
))
1317 (not ps-mule-composition-prologue-generated
))
1319 (ps-mule-prologue-generated)
1320 (ps-output-prologue ps-mule-composition-prologue
)
1321 (setq ps-mule-composition-prologue-generated t
)))
1323 (if ps-mule-charset-list
1324 (let ((the-list ps-mule-charset-list
)
1326 (ps-mule-prologue-generated)
1327 ;; If external functions are necessary, generate prologues for them.
1329 (setq elt
(car the-list
)
1330 the-list
(cdr the-list
))
1331 (cond ((and (eq elt
'composition
)
1332 (not ps-mule-composition-prologue-generated
))
1333 (ps-output-prologue ps-mule-composition-prologue
)
1334 (setq ps-mule-composition-prologue-generated t
))
1335 ((setq font-spec
(ps-mule-get-font-spec elt
'normal
))
1336 (ps-mule-init-external-library font-spec
))))))
1338 ;; If ASCII font is also specified in ps-mule-font-info-database,
1339 ;; use it istead of what specified in ps-font-info-database.
1340 (let ((font-spec (ps-mule-get-font-spec 'ascii
'normal
)))
1343 (ps-mule-prologue-generated)
1344 (ps-mule-init-external-library font-spec
)
1345 (let ((font (ps-font-alist 'ps-font-for-text
))
1346 (ps-current-font 0))
1348 ;; Be sure to download a glyph for SPACE in advance.
1349 (ps-mule-prepare-font (ps-mule-get-font-spec 'ascii
(car font
))
1350 " " 'ascii
'no-setfont
)
1351 (setq font
(cdr font
)
1352 ps-current-font
(1+ ps-current-font
)))))))
1354 (if ps-mule-charset-list
1355 ;; We must change this regexp for multi-byte buffer.
1356 (setq ps-control-or-escape-regexp
1357 (cond ((eq ps-print-control-characters
'8-bit
)
1359 ((eq ps-print-control-characters
'control-8-bit
)
1360 (string-as-multibyte "[^\040-\176\240-\377]"))
1361 ((eq ps-print-control-characters
'control
)
1362 (string-as-multibyte "[^\040-\176\200-\377]"))
1363 (t (string-as-multibyte "[^\000-\011\013\015-\377]"))))))
1366 (defun ps-mule-begin-page ()
1367 (setq ps-mule-current-charset
'ascii
))
1372 ;;; ps-mule.el ends here