aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa1998-08-24 10:19:29 +0000
committerKenichi Handa1998-08-24 10:19:29 +0000
commite65df0a1cf785cba4a92096bdec42d945f14bb51 (patch)
tree654f0f084eaa2d9bf52b1828c971b14ba18b460e
parenta8b136653338f9a779563bbb166bd9bed975e461 (diff)
downloademacs-e65df0a1cf785cba4a92096bdec42d945f14bb51.tar.gz
emacs-e65df0a1cf785cba4a92096bdec42d945f14bb51.zip
Multi-byte buffer handling.
(ps-print-version): New version number (4.0) and doc fix. (ps-color-device, ps-face-bold-p, ps-face-italic-p): Conditional compilation for GNU Emacs and emacsens. (ps-generate-postscript-with-faces): Force invisible text to be visible. (dos-ps-printer): New var to avoid compilation gripes. (ps-mule-plot-string): Pay attention to the case that no more characters can't be printed in the current line. (ps-mule-find-wrappoint): ENDPOS should not be greater than TO. Add codes to make ps-print.el work also on Emacs 20.2 and the earlier version. (ps-mule-encode-7bit, ps-mule-encode-8bit): Modified for 20.2. (ccl-encode-ethio-unicode, ps-mule-encode-ethiopic): Likewise. (ps-mule-find-wrappoint): Likewise. (ps-mule-generate-font): Change `X' to `x' in format control-string. (ps-generate): Call ps-mule-begin before calling ps-begin-job. (ps-mule-cmpchar-prologue): Delete unnecessary `gsave' and `restore' form procedures `BC' and `EC'. (ps-print-prologue-1): Handle the case that FontBBox is an executable procedure. Make LineThickness, Xshadow, and Yshadow relative to FontHeight. Set SpaceWidth in BeginDoc. (ps-mule-font-info-database, ps-mule-font-info-database-ps, ps-mule-font-info-database-bdf): New vars. (ps-mule-encode-7bit, ps-mule-encode-8bit): New funs. (ccl-encode-ethio-unicode): New CCL program. (ps-mule-encode-ethiopic): New fun. (ps-mule-current-charset): New var. (ps-mule-get-font-spec, ps-mule-font-spec-src, ps-mule-font-spec-name, ps-mule-font-spec-encoding, ps-mule-font-spec-bytes, ps-mule-printable-p): New funs. (ps-mule-external-libraries): New var. (ps-mule-init-external-library): New fun. (ps-mule-font-cache): New var. (ps-mule-generate-font, ps-mule-generate-glyphs): New funs. (ps-last-font): New var. (ps-mule-prepare-font): New fun. (ps-mule-charset-list): New var. (ps-mule-prologue-generated, ps-mule-prologue): New vars. (ps-mule-skip-same-charset, ps-mule-find-wrappoint, ps-mule-plot-string): New funs. (ps-mule-cmpchar-prologue-generated, ps-mule-cmpchar-prologue): New vars. (ps-mule-plot-rule-cmpchar, ps-mule-plot-cmpchar, ps-mule-prepare-cmpchar-font): New funs. (ps-mule-bitmap-prologue-generated, ps-mule-bitmap-prologue): New vars. (ps-mule-generate-bitmap-prologue, ps-mule-generate-bitmap-font, ps-mule-generate-bitmap-glyph): New funs. (ps-mule-initialize, ps-mule-begin): New funs. (ps-output-string-prim): Insert string as unibyte. (ps-output-prologue): New fun. (ps-flush-output): Handle the case of 'prologue. (ps-begin-file): Call ps-mule-initialize. (ps-begin-job): Set ps-control-or-escape-regexp differently if printing multibyte characters. (ps-begin-page): Set ps-mule-current-charset to 'ascii. (ps-basic-plot-string): Handle the case of printing ASCII characters by external libraries (e.g. BDF). (ps-set-font): Set ps-last-font. (ps-plot-region): Handle multibyte characters, use ps-mule-plot-string for them. (ps-generate): Set the spool buffer unibyte. Call ps-mule-begin.
-rw-r--r--lisp/ps-print.el1242
1 files changed, 1166 insertions, 76 deletions
diff --git a/lisp/ps-print.el b/lisp/ps-print.el
index 6f18fd6857e..0ded650e1ea 100644
--- a/lisp/ps-print.el
+++ b/lisp/ps-print.el
@@ -2,16 +2,18 @@
2 2
3;; Copyright (C) 1993, 94, 95, 96, 97, 1998 Free Software Foundation, Inc. 3;; Copyright (C) 1993, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
4 4
5;; Author: Jim Thompson (was <thompson@wg2.waii.com>) 5;; Author: Jim Thompson (was <thompson@wg2.waii.com>)
6;; Author: Jacques Duthen <duthen@cegelec-red.fr> 6;; Author: Jacques Duthen <duthen@cegelec-red.fr>
7;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br> 7;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br>
8;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br> 8;; Author: Kenichi Handa <handa@etl.go.jp> (multibyte characters)
9;; Keywords: print, PostScript 9;; Maintainer: Kenichi Handa <handa@etl.go.jp> (multibyte characters)
10;; Time-stamp: <98/06/04 15:23:12 vinicius> 10;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br>
11;; Version: 3.06.3 11;; Keywords: print, PostScript
12 12;; Time-stamp: <98/08/19 11:10:03 vinicius>
13(defconst ps-print-version "3.06.3" 13;; Version: 4.0
14 "ps-print.el, v 3.06.3 <98/06/04 vinicius> 14
15(defconst ps-print-version "4.0"
16 "ps-print.el, v 4.0 <98/08/19 vinicius>
15 17
16Vinicius's last change version -- this file may have been edited as part of 18Vinicius's last change version -- this file may have been edited as part of
17Emacs without changes to the version number. When reporting bugs, 19Emacs without changes to the version number. When reporting bugs,
@@ -399,6 +401,32 @@ Please send all bug fixes and enhancements to
399;; Characters TAB, NEWLINE and FORMFEED are always treated by ps-print engine. 401;; Characters TAB, NEWLINE and FORMFEED are always treated by ps-print engine.
400;; 402;;
401;; 403;;
404;; Printing Multi-Byte Buffer
405;; --------------------------
406;;
407;; ps-print can print multi-byte buffer.
408;;
409;; If you are using only Latin-1 characters, you don't need to do anything else.
410;;
411;; If you have a japanese or korean PostScript printer, you can print ASCII,
412;; Latin-1, Japanese (JISX0208, and JISX0201-Kana) and Korean characters by
413;; setting:
414;;
415;; (setq ps-mule-font-info-database ps-mule-font-info-database-ps)
416;;
417;; At present, it was not tested the korean characters printing. If you have
418;; a korean PostScript printer, please verify it.
419;;
420;; If you use any other kind of character, you need to install intlfonts-1.1.
421;; So you can print using BDF fonts contained in intlfonts-1.1. To print using
422;; BDF fonts, do the following settings:
423;;
424;; (1) Set the variable `bdf-directory-list' appropriately (see bdf.el for
425;; documentation of this variable).
426;;
427;; (2) (setq ps-mule-font-info-database-ps ps-mule-font-info-database-bdf)
428;;
429;;
402;; Line Number 430;; Line Number
403;; ----------- 431;; -----------
404;; 432;;
@@ -744,9 +772,13 @@ Please send all bug fixes and enhancements to
744;; New since version 2.8 772;; New since version 2.8
745;; --------------------- 773;; ---------------------
746;; 774;;
775;; [keinichi] 980819 Kein'ichi Handa <handa@etl.go.jp>
776;;
777;; Multi-byte buffer handling.
778;;
747;; [vinicius] 980306 Vinicius Jose Latorre <vinicius@cpqd.com.br> 779;; [vinicius] 980306 Vinicius Jose Latorre <vinicius@cpqd.com.br>
748;; 780;;
749;; Skip invisible text 781;; Skip invisible text.
750;; 782;;
751;; [vinicius] 971130 Vinicius Jose Latorre <vinicius@cpqd.com.br> 783;; [vinicius] 971130 Vinicius Jose Latorre <vinicius@cpqd.com.br>
752;; 784;;
@@ -823,6 +855,8 @@ Please send all bug fixes and enhancements to
823;; Thanks to Roland Ducournau <ducour@lirmm.fr> for 855;; Thanks to Roland Ducournau <ducour@lirmm.fr> for
824;; `ps-print-control-characters' variable documentation. 856;; `ps-print-control-characters' variable documentation.
825;; 857;;
858;; Thanks to Kein'ichi Handa <handa@etl.go.jp> for multi-byte buffer handling.
859;;
826;; Thanks to Marcus G Daniels <marcus@cathcart.sysc.pdx.edu> for a better 860;; Thanks to Marcus G Daniels <marcus@cathcart.sysc.pdx.edu> for a better
827;; database font management. 861;; database font management.
828;; 862;;
@@ -1776,11 +1810,17 @@ The table depends on the current ps-print setup."
1776;; Return t if the device (which can be changed during an emacs session) 1810;; Return t if the device (which can be changed during an emacs session)
1777;; can handle colors. 1811;; can handle colors.
1778;; This is function is not yet implemented for GNU emacs. 1812;; This is function is not yet implemented for GNU emacs.
1779(defun ps-color-device () 1813(cond ((and (eq ps-print-emacs-type 'xemacs)
1780 (if (and (eq ps-print-emacs-type 'xemacs) 1814 (>= emacs-minor-version 12)) ; xemacs
1781 (>= emacs-minor-version 12)) 1815 (defun ps-color-device ()
1782 (eq (device-class) 'color) 1816 (eq (device-class) 'color))
1783 t)) 1817 )
1818
1819 (t ; emacs
1820 (defun ps-color-device ()
1821 t)
1822 ))
1823
1784 1824
1785(require 'time-stamp) 1825(require 'time-stamp)
1786 1826
@@ -1867,7 +1907,7 @@ StandardEncoding 46 82 getinterval aload pop
1867% (x1 y1) --> +----+ - - 1907% (x1 y1) --> +----+ - -
1868 1908
1869 currentdict /FontType get 0 ne { 1909 currentdict /FontType get 0 ne {
1870 FontBBox % -- x1 y1 x2 y2 1910 /FontBBox load aload pop % -- x1 y1 x2 y2
1871 FontMatrix transform /Ascent exch def pop 1911 FontMatrix transform /Ascent exch def pop
1872 FontMatrix transform /Descent exch def pop 1912 FontMatrix transform /Descent exch def pop
1873 } { 1913 } {
@@ -1884,9 +1924,9 @@ StandardEncoding 46 82 getinterval aload pop
1884 /UnderlinePosition Descent 0.70 mul def 1924 /UnderlinePosition Descent 0.70 mul def
1885 /OverlinePosition Descent UnderlinePosition sub Ascent add def 1925 /OverlinePosition Descent UnderlinePosition sub Ascent add def
1886 /StrikeoutPosition Ascent 0.30 mul def 1926 /StrikeoutPosition Ascent 0.30 mul def
1887 /LineThickness 0 50 FontMatrix transform exch pop def 1927 /LineThickness FontHeight 0.05 mul def
1888 /Xshadow 0 80 FontMatrix transform exch pop def 1928 /Xshadow FontHeight 0.08 mul def
1889 /Yshadow 0 -90 FontMatrix transform exch pop def 1929 /Yshadow FontHeight -0.09 mul def
1890 /SpaceBackground Descent neg UnderlinePosition add def 1930 /SpaceBackground Descent neg UnderlinePosition add def
1891 /XBox Descent neg def 1931 /XBox Descent neg def
1892 /YBox LineThickness 0.7 mul def 1932 /YBox LineThickness 0.7 mul def
@@ -2171,6 +2211,8 @@ StandardEncoding 46 82 getinterval aload pop
2171} def 2211} def
2172 2212
2173/BeginDoc { 2213/BeginDoc {
2214 % ---- Remember space width of the normal text font `f0'.
2215 /SpaceWidth /f0 findfont setfont ( ) stringwidth pop def
2174 % ---- save the state of the document (useful for ghostscript!) 2216 % ---- save the state of the document (useful for ghostscript!)
2175 /docState save def 2217 /docState save def
2176 % ---- [jack] Kludge: my ghostscript window is 21x27.7 instead of 21x29.7 2218 % ---- [jack] Kludge: my ghostscript window is 21x27.7 instead of 21x29.7
@@ -2741,6 +2783,982 @@ x-dimension, of the text it has printed, and thus affects the point at
2741which long lines wrap around." 2783which long lines wrap around."
2742 (get font-sym 'avg-char-width)) 2784 (get font-sym 'avg-char-width))
2743 2785
2786
2787;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2788;; For handling multibyte characters.
2789;;
2790;; The following comments apply only to this part (through the next ^L).
2791;; Author: Kenichi Handa <handa@etl.go.jp>
2792;; Maintainer: Kenichi Handa <handa@etl.go.jp>
2793
2794(eval-and-compile
2795 (if (fboundp 'set-buffer-multibyte)
2796 (progn
2797 (defalias 'ps-mule-next-point '1+)
2798 (defalias 'ps-mule-chars-in-string 'length)
2799 (defalias 'ps-mule-string-char 'aref)
2800 (defsubst ps-mule-next-index (str i) (1+ i)))
2801 (defun set-buffer-multibyte (arg)
2802 (setq enable-multibyte-characters arg))
2803 (defun string-as-unibyte (arg) arg)
2804 (defun string-as-multibyte (arg) arg)
2805 (defun charset-after (&optional arg)
2806 (char-charset (char-after arg)))
2807 (defun ps-mule-next-point (arg)
2808 (save-excursion (goto-char arg) (forward-char 1) (point)))
2809 (defun ps-mule-chars-in-string (string)
2810 (/ (length string) (char-bytes (sref string 0))))
2811 (defalias 'ps-mule-string-char 'sref)
2812 (defun ps-mule-next-index (str i)
2813 (+ i (char-bytes (sref str i)))))
2814 )
2815
2816(defvar ps-mule-font-info-database
2817 '((latin-iso8859-1
2818 (normal nil nil iso-latin-1)))
2819 "Alist of charsets vs the corresponding font information.
2820Each element has the form:
2821 (CHARSET (FONT-TYPE FONT-SRC FONT-NAME ENCODING BYTES) ...)
2822where
2823
2824CHARSET is a charset (symbol) for this font family,
2825
2826FONT-TYPE is a type of font: normal, bold, italic, or bold-italic.
2827
2828FONT-SRC is a source of font: builtin, bdf, vflib, or nil.
2829
2830 If FONT-SRC is builtin, FONT-NAME is a buitin PostScript font name.
2831
2832 If FONT-SRC is bdf, FONT-NAME is a BDF font file name. To use this
2833 font, the external library `bdf' is required.
2834
2835 If FONT-SRC is vflib, FONT-NAME is name of font VFlib knows. To use
2836 this font, the external library `vflib' is required.
2837
2838 If FONT-SRC is nil, a proper ASCII font in the variable
2839 `ps-font-info-database' is used. This is useful for Latin-1
2840 characters.
2841
2842ENCODING is a coding system to encode a string of characters of
2843CHARSET into a proper string matching an encoding of the specified
2844font. ENCODING may be a function to call to do this encoding. In
2845this case, the function is called with one arguemnt, the string to
2846encode, and it should return an encoded string.
2847
2848BYTES specifies how many bytes in encoded byte sequence construct esch
2849character, it should be 1 or 2.
2850
2851All multibyte characters are printed by fonts specified in this
2852database regardless of a font family of ASCII characters. The
2853exception is Latin-1 characters which are printed by the same font as
2854ASCII characters, thus obey font family.
2855
2856See also the variable `ps-font-info-database'.")
2857
2858(defconst ps-mule-font-info-database-ps
2859 '((katakana-jisx0201
2860 (normal builtin "Ryumin-Light.Katakana" ps-mule-encode-7bit 1)
2861 (bold builtin "GothicBBB-Medium.Katakana" ps-mule-encode-7bit 1)
2862 (bold-italic builtin "GothicBBB-Medium.Katakana" ps-mule-encode-7bit 1))
2863 (latin-jisx0201
2864 (normat builtin "Ryumin-Light.Hankaku" ps-mule-encode-7bit 1)
2865 (bold builtin "GothicBBB-Medium.Hankaku" ps-mule-encode-7bit 1))
2866 (japanese-jisx0208
2867 (normal builtin "Ryumin-Light-H" ps-mule-encode-7bit 2)
2868 (bold builtin "GothicBBB-Medium-H" ps-mule-encode-7bit 2))
2869 (korean-ksc5601
2870 (normal builtin "Batang-Medium-KSC-H" ps-mule-encode-7bit 2)
2871 (bold builtin " Gulim-Medium-KSC-H" ps-mule-encode-7bit 2))
2872 )
2873 "Sample setting of the `ps-mule-font-info-database' to use builtin PS font.
2874
2875Currently, data for Japanese and Korean PostScript printers are listed.")
2876
2877(defconst ps-mule-font-info-database-bdf
2878 '(;;(ascii
2879 ;; (normal bdf "etl24-latin1.bdf" nil 1)
2880 ;; (bold bdf "etl16b-latin1.bdf" iso-latin-1 1)
2881 ;; (italic bdf "etl16i-latin1.bdf" iso-latin-1 1)
2882 ;; (bold-italic bdf "etl16bi-latin1.bdf" iso-latin-1 1))
2883 ;;(latin-iso8859-1
2884 ;; (normal bdf "etl24-latin1.bdf" iso-latin-1 1)
2885 ;; (bold bdf "etl16b-latin1.bdf" iso-latin-1 1)
2886 ;; (italic bdf "etl16i-latin1.bdf" iso-latin-1 1)
2887 ;; (bold-italic bdf "etl16bi-latin1.bdf" iso-latin-1 1))
2888 (latin-iso8859-1
2889 (normal nil nil iso-latin-1))
2890 (latin-iso8859-2
2891 (normal bdf "etl24-latin2.bdf" iso-latin-2 1))
2892 (latin-iso8859-3
2893 (normal bdf "etl24-latin3.bdf" iso-latin-3 1))
2894 (latin-iso8859-4
2895 (normal bdf "etl24-latin4.bdf" iso-latin-4 1))
2896 (thai-tis620
2897 (normal bdf "thai-24.bdf" thai-tis620 1))
2898 (greek-iso8859-7
2899 (normal bdf "etl24-greek.bdf" greek-iso-8bit 1))
2900 ;; (arabic-iso8859-6 nil) ; not yet available
2901 (hebrew-iso8859-8
2902 (normal bdf "etl24-hebrew.bdf" hebrew-iso-8bit 1))
2903 (katakana-jisx0201
2904 (normal bdf "12x24rk.bdf" ps-mule-encode-8bit 1))
2905 (latin-jisx0201
2906 (normal bdf "12x24rk.bdf" ps-mule-encode-7bit 1))
2907 (cyrillic-iso8859-5
2908 (normal bdf "etl24-cyrillic.bdf" cyrillic-iso-8bit 1))
2909 (latin-iso8859-9
2910 (normal bdf "etl24-latin5.bdf" iso-latin-5 1))
2911 (japanese-jisx0208-1978
2912 (normal bdf "jiskan24.bdf" ps-mule-encode-7bit 2))
2913 (chinese-gb2312
2914 (normal bdf "gb24st.bdf" ps-mule-encode-7bit 2))
2915 (japanese-jisx0208
2916 (normal bdf "jiskan24.bdf" ps-mule-encode-7bit 2))
2917 (korean-ksc5601
2918 (normal bdf "hanglm24.bdf" ps-mule-encode-7bit 2))
2919 (japanese-jisx0212
2920 (normal bdf "jisksp40.bdf" ps-mule-encode-7bit 2))
2921 (chinese-cns11643-1
2922 (normal bdf "cns-1-40.bdf" ps-mule-encode-7bit 2))
2923 (chinese-cns11643-2
2924 (normal bdf "cns-2-40.bdf" ps-mule-encode-7bit 2))
2925 (chinese-big5-1
2926 (normal bdf "taipei24.bdf" chinese-big5 2))
2927 (chinese-big5-2
2928 (normal bdf "taipei24.bdf" chinese-big5 2))
2929 (chinese-sisheng
2930 (normal bdf "etl24-sisheng.bdf" ps-mule-encode-8bit 1))
2931 (ipa
2932 (normal bdf "etl24-ipa.bdf" ps-mule-encode-8bit 1))
2933 (vietnamese-viscii-lower
2934 (normal bdf "etl24-viscii.bdf" vietnamese-viscii 1))
2935 (vietnamese-viscii-upper
2936 (normal bdf "etl24-viscii.bdf" vietnamese-viscii 1))
2937 (arabic-digit
2938 (normal bdf "etl24-arabic0.bdf" ps-mule-encode-7bit 1))
2939 (arabic-1-column
2940 (normal bdf "etl24-arabic1.bdf" ps-mule-encode-7bit 1))
2941 ;; (ascii-right-to-left nil) ; not yet available
2942 (lao
2943 (normal bdf "mule-lao-24.bdf" lao 1))
2944 (arabic-2-column
2945 (normal bdf "etl24-arabic2.bdf" ps-mule-encode-7bit 1))
2946 (indian-is13194
2947 (normal bdf "mule-iscii-24.bdf" ps-mule-encode-7bit 1))
2948 (indian-1-column
2949 (normal bdf "mule-indian-1col-24.bdf" ps-mule-encode-7bit 2))
2950 (tibetan-1-column
2951 (normal bdf "mule-tibmdx-1col-24.bdf" ps-mule-encode-7bit 2))
2952 (ethiopic
2953 (normal bdf "ethiomx24f-uni.bdf" ps-mule-encode-ethiopic 2))
2954 (chinese-cns11643-3
2955 (normal bdf "cns-3-40.bdf" ps-mule-encode-7bit 2))
2956 (chinese-cns11643-4
2957 (normal bdf "cns-4-40.bdf" ps-mule-encode-7bit 2))
2958 (chinese-cns11643-5
2959 (normal bdf "cns-5-40.bdf" ps-mule-encode-7bit 2))
2960 (chinese-cns11643-6
2961 (normal bdf "cns-6-40.bdf" ps-mule-encode-7bit 2))
2962 (chinese-cns11643-7
2963 (normal bdf "cns-7-40.bdf" ps-mule-encode-7bit 2))
2964 (indian-2-column
2965 (normal bdf "mule-indian-24.bdf" ps-mule-encode-7bit 2))
2966 (tibetan
2967 (normal bdf "mule-tibmdx-24.bdf" ps-mule-encode-7bit 2)))
2968 "Sample setting of the `ps-mule-font-info-database' to use BDF fonts.
2969
2970Current default value lists BDF fonts included in `intlfonts-1.1'
2971which is a collection of X11 fonts for all characters supported by
2972Emacs.")
2973
2974;; Two typical encoding functions for PostScript fonts.
2975
2976(defun ps-mule-encode-7bit (string)
2977 (let* ((dim (charset-dimension
2978 (char-charset (ps-mule-string-char string 0))))
2979 (len (* (ps-mule-chars-in-string string) dim))
2980 (str (make-string len 0))
2981 (i 0) (j 0))
2982 (if (= dim 1)
2983 (while (< j len)
2984 (aset str j (nth 1 (split-char (ps-mule-string-char string i))))
2985 (setq i (ps-mule-next-index string i)
2986 j (1+ j)))
2987 (while (< j len)
2988 (let ((split (split-char (ps-mule-string-char string i))))
2989 (aset str j (nth 1 split))
2990 (aset str (1+ j) (nth 2 split))
2991 (setq i (ps-mule-next-index string i)
2992 j (+ j 2)))))
2993 str))
2994
2995(defun ps-mule-encode-8bit (string)
2996 (let* ((dim (charset-dimension
2997 (char-charset (ps-mule-string-char string 0))))
2998 (len (* (ps-mule-chars-in-string string) dim))
2999 (str (make-string len 0))
3000 (i 0) (j 0))
3001 (if (= dim 1)
3002 (while (< j len)
3003 (aset str j
3004 (+ (nth 1 (split-char (ps-mule-string-char string i))) 128))
3005 (setq i (ps-mule-next-index string i)
3006 j (1+ j)))
3007 (while (< j len)
3008 (let ((split (split-char (ps-mule-string-char string i))))
3009 (aset str j (+ (nth 1 split) 128))
3010 (aset str (1+ j) (+ (nth 2 split) 128))
3011 (setq i (ps-mule-next-index string i)
3012 j (+ j 2)))))
3013 str))
3014
3015;; Special encoding function for Ethiopic.
3016(define-ccl-program ccl-encode-ethio-unicode
3017 `(1
3018 (read r2)
3019 (loop
3020 (if (r2 == ,leading-code-private-22)
3021 ((read r0)
3022 (if (r0 == ,(charset-id 'ethiopic))
3023 ((read r1 r2)
3024 (r1 &= 127) (r2 &= 127)
3025 (call ccl-encode-ethio-font)
3026 (write r1)
3027 (write-read-repeat r2))
3028 ((write r2 r0)
3029 (repeat))))
3030 (write-read-repeat r2)))))
3031
3032(defun ps-mule-encode-ethiopic (string)
3033 (ccl-execute-on-string (symbol-value 'ccl-encode-ethio-unicode)
3034 (make-vector 9 nil)
3035 string))
3036
3037;; A charset which we are now processing.
3038(defvar ps-mule-current-charset nil)
3039
3040(defun ps-mule-get-font-spec (charset font-type)
3041 "Return FONT-SPEC for printing characters CHARSET with FONT-TYPE.
3042FONT-SPEC is a list of FONT-SRC, FONT-NAME, ENCODING, and BYTES,
3043this information is extracted from `ps-mule-font-info-database'
3044See the documentation of `ps-mule-font-info-database' for the meaning
3045of each element of the list."
3046 (let ((slot (cdr (assq charset ps-mule-font-info-database))))
3047 (if slot
3048 (cdr (or (assq font-type slot)
3049 (and (eq font-type 'bold-italic)
3050 (or (assq 'bold slot) (assq 'italic slot)))
3051 (assq 'normal slot))))))
3052
3053;; Functions to access each element of FONT-SPEC.
3054(defsubst ps-mule-font-spec-src (font-spec) (car font-spec))
3055(defsubst ps-mule-font-spec-name (font-spec) (nth 1 font-spec))
3056(defsubst ps-mule-font-spec-encoding (font-spec) (nth 2 font-spec))
3057(defsubst ps-mule-font-spec-bytes (font-spec) (nth 3 font-spec))
3058
3059(defsubst ps-mule-printable-p (charset)
3060 "Non-nil if characters in CHARSET is printable."
3061 (ps-mule-get-font-spec charset 'normal))
3062
3063(defconst ps-mule-external-libraries
3064 '((builtin nil
3065 nil nil nil)
3066 (bdf nil
3067 bdf-generate-prologue bdf-generate-font bdf-generate-glyphs)
3068 (pcf nil
3069 pcf-generate-prologue pcf-generate-font pcf-generate-glyphs)
3070 (vflib nil
3071 vflib-generate-prologue vflib-generate-font vflib-generate-glyphs))
3072 "Alist of information of external libraries to support PostScript printing.
3073Each element has the form:
3074 (FONT-SRC INITIALIZED-P PROLOGUE-FUNC FONT-FUNC GLYPHS-FUNC)
3075
3076FONT-SRC is a source of font: builtin, bdf, pcf, or vflib. Except for
3077builtin, libraries of the same names are necessary, but currently, we
3078only have the library `bdf'.
3079
3080INITIALIZED-P is a flag to tell this library is initialized or not.
3081
3082PROLOGUE-FUNC is a function to call to get a PostScript codes which
3083define procedures to use this library. It is called with no argument,
3084and should return a list of strings.
3085
3086FONT-FUNC is a function to call to get a PostScript codes which define
3087a new font. It is called with one argument FONT-SPEC, and should
3088return a list of strings.
3089
3090GLYPHS-FUNC is a function to call to get a PostScript codes which
3091define glyphs of characters. It is called with three arguments
3092FONT-SPEC, CODE-LIST, and BYTES, and should return a list of strings.")
3093
3094(defun ps-mule-init-external-library (font-spec)
3095 "Initialize external librarie specified in FONT-SPEC for PostScript printing.
3096See the documentation of `ps-mule-get-font-spec' for the meaning of
3097each element of the list."
3098 (let* ((font-src (ps-mule-font-spec-src font-spec))
3099 (slot (assq font-src ps-mule-external-libraries)))
3100 (or (not font-src)
3101 (nth 1 slot)
3102 (let ((func (nth 2 slot)))
3103 (if func
3104 (progn
3105 (or (featurep font-src) (require font-src))
3106 (ps-output-prologue (funcall func))))
3107 (setcar (cdr slot) t)))))
3108
3109;; Cached glyph information of fonts, alist of:
3110;; (FONT-NAME ((FONT-TYPE-NUMBER . SCALED-FONT-NAME) ...)
3111;; cache CODE0 CODE1 ...)
3112(defvar ps-mule-font-cache nil)
3113
3114(defun ps-mule-generate-font (font-spec charset)
3115 "Generate PostScript codes to define a new font in FONT-SPEC for CHARSET."
3116 (let* ((font-cache (assoc (ps-mule-font-spec-name font-spec)
3117 ps-mule-font-cache))
3118 (font-src (ps-mule-font-spec-src font-spec))
3119 (font-name (ps-mule-font-spec-name font-spec))
3120 (func (nth 3 (assq font-src ps-mule-external-libraries)))
3121 (scaled-font-name
3122 (if (eq charset 'ascii)
3123 (format "f%d" ps-current-font)
3124 (format "f%02x-%d"
3125 (charset-id charset) ps-current-font))))
3126 (if (and func (not font-cache))
3127 (ps-output-prologue (funcall func font-spec)))
3128 (ps-output-prologue
3129 (list (format "/%s %f /%s Def%sFontMule\n"
3130 scaled-font-name ps-font-size font-name
3131 (if (eq ps-mule-current-charset 'ascii) "Ascii" ""))))
3132 (if font-cache
3133 (setcar (cdr font-cache)
3134 (cons (cons ps-current-font scaled-font-name)
3135 (nth 1 font-cache)))
3136 (setq font-cache (list font-name
3137 (list (cons ps-current-font scaled-font-name))
3138 'cache))
3139 (setq ps-mule-font-cache (cons font-cache ps-mule-font-cache)))
3140 font-cache))
3141
3142(defun ps-mule-generate-glyphs (font-spec code-list)
3143 "Generate PostScript codes which generate glyphs for CODE-LIST of FONT-SPEC."
3144 (let* ((font-src (ps-mule-font-spec-src font-spec))
3145 (func (nth 4 (assq font-src ps-mule-external-libraries))))
3146 (if func
3147 (ps-output-prologue
3148 (funcall func font-spec code-list
3149 (ps-mule-font-spec-bytes font-spec))))))
3150
3151(defvar ps-last-font nil)
3152
3153(defun ps-mule-prepare-font (font-spec string charset &optional no-setfont)
3154 "Generate PostScript codes to print STRING of CHARSET by font in FONT-SPEC.
3155The generated codes goes to prologue part except for a code for
3156setting the current font (using PostScript procedure `FM').
3157If optional arg NO-SETFONT is non-nil, don't generate the code for
3158setting the current font."
3159 (let ((font-cache (assoc (ps-mule-font-spec-name font-spec)
3160 ps-mule-font-cache)))
3161 (or (and font-cache (assq ps-current-font (nth 1 font-cache)))
3162 (setq font-cache (ps-mule-generate-font font-spec charset)))
3163 (or no-setfont
3164 (let ((new-font (cdr (assq ps-current-font (nth 1 font-cache)))))
3165 (or (equal new-font ps-last-font)
3166 (progn
3167 (ps-output (format "/%s FM\n" new-font))
3168 (setq ps-last-font new-font)))))
3169 (if (nth 4 (assq (ps-mule-font-spec-src font-spec)
3170 ps-mule-external-libraries))
3171 ;; We have to generate PostScript codes which define glyphs.
3172 (let* ((cached-codes (nthcdr 2 font-cache))
3173 (newcodes nil)
3174 (bytes (ps-mule-font-spec-bytes font-spec))
3175 (len (length string))
3176 (i 0)
3177 code)
3178 (while (< i len)
3179 (setq code
3180 (if (= bytes 1) (aref string i)
3181 (+ (* (aref string i) 256) (aref string (1+ i)))))
3182 (or (memq code cached-codes)
3183 (progn
3184 (setq newcodes (cons code newcodes))
3185 (setcdr cached-codes (cons code (cdr cached-codes)))))
3186 (setq i (+ i bytes)))
3187 (if newcodes
3188 (ps-mule-generate-glyphs font-spec newcodes))))))
3189
3190;; List of charsets of multibyte characters in a text being printed.
3191;; If the text doesn't contain any multibyte characters (i.e. only
3192;; ASCII), the value is nil.
3193(defvar ps-mule-charset-list nil)
3194
3195;; This constant string is a PostScript code embeded as is in the
3196;; header of generated PostScript.
3197
3198(defvar ps-mule-prologue-generated nil)
3199
3200(defconst ps-mule-prologue
3201 "%%%% Start of Mule Section
3202
3203%% Working dictionaly for general use.
3204/MuleDict 10 dict def
3205
3206%% Define already scaled font for non-ASCII character sets.
3207/DefFontMule { % fontname size basefont |- --
3208 findfont exch scalefont definefont pop
3209} bind def
3210
3211%% Define already scaled font for ASCII character sets.
3212/DefAsciiFontMule { % fontname size basefont |-
3213 MuleDict begin
3214 findfont dup /Encoding get /ISOLatin1Encoding exch def
3215 exch scalefont reencodeFontISO
3216 end
3217} def
3218
3219%% Set the specified non-ASCII font to use. It doesn't install
3220%% Ascent, etc.
3221/FM { % fontname |- --
3222 findfont setfont
3223} bind def
3224
3225%% Show vacant box for characters which don't have appropriate font.
3226/SB { % count column |- --
3227 SpaceWidth mul /w exch def
3228 1 exch 1 exch { %for
3229 pop
3230 gsave
3231 0 setlinewidth
3232 0 Descent rmoveto w 0 rlineto
3233 0 LineHeight rlineto w neg 0 rlineto closepath stroke
3234 grestore
3235 w 0 rmoveto
3236 } for
3237} bind def
3238
3239%% Flag to tell if we are now handling a composite character. This is
3240%% defined here because both composite character handler and bitmap font
3241%% handler require it.
3242/Cmpchar false def
3243
3244%%%% End of Mule Section
3245
3246"
3247 "PostScript code for printing multibyte characters.")
3248
3249(defun ps-mule-skip-same-charset (charset)
3250 "Skip characters of CHARSET following the current point."
3251 (while (eq (charset-after) charset) (forward-char 1)))
3252
3253(defun ps-mule-find-wrappoint (from to char-width)
3254 "Find a longest sequence at FROM which is printable in the current line.
3255
3256TO limits the sequence. It is assumed that all characters between
3257FROM and TO belong to a charset set in `ps-mule-current-charset'.
3258
3259CHAR-WIDTH is an average width of ASCII characters in the current font.
3260
3261The return value is a cons of ENDPOS and RUN-WIDTH, where
3262ENDPOS is an end position of the sequence,
3263RUN-WIDTH is the width of the sequence."
3264 (let (run-width)
3265 (if (eq ps-mule-current-charset 'composition)
3266 ;; We must draw one char by one.
3267 (let ((ch (char-after from)))
3268 (setq run-width (* (char-width ch) char-width))
3269 (if (> run-width ps-width-remaining)
3270 (setq run-width ps-width-remaining)
3271 (setq from (ps-mule-next-point from))))
3272 ;; We assume that all characters in this range have the same width.
3273 (let ((width (charset-width ps-mule-current-charset)))
3274 (setq run-width (* (- to from) char-width width))
3275 (if (> run-width ps-width-remaining)
3276 (setq from (min
3277 (+ from (truncate (/ ps-width-remaining char-width)))
3278 to)
3279 run-width ps-width-remaining)
3280 (setq from to))))
3281 (cons from run-width)))
3282
3283(defun ps-mule-plot-string (from to &optional bg-color)
3284 "Generate PostScript code for ploting characters in the region FROM and TO.
3285It is assumed that all characters in this region belong to the
3286charset `ps-mule-current-charset'.
3287Optional arg BG-COLOR specifies background color.
3288The return value is a cons of ENDPOS and WIDTH of the sequence
3289actually plotted by this function."
3290 (let* ((wrappoint (ps-mule-find-wrappoint
3291 from to (ps-avg-char-width 'ps-font-for-text)))
3292 (to (car wrappoint))
3293 (font-type (car (nth ps-current-font
3294 (ps-font-alist 'ps-font-for-text))))
3295 (font-spec (ps-mule-get-font-spec ps-mule-current-charset font-type))
3296 (encoding (ps-mule-font-spec-encoding font-spec))
3297 (string (buffer-substring-no-properties from to)))
3298 (cond
3299 ((= from to)
3300 ;; We can't print any more characters in the current line.
3301 nil)
3302
3303 (font-spec
3304 ;; We surely have a font for printing this character set.
3305 (if (coding-system-p encoding)
3306 (setq string (encode-coding-string string encoding))
3307 (if (functionp encoding)
3308 (setq string (funcall encoding string))
3309 (if encoding
3310 (error "Invalid coding system or function: %s" encoding))))
3311 (setq string (string-as-unibyte string))
3312 (if (ps-mule-font-spec-src font-spec)
3313 (ps-mule-prepare-font font-spec string ps-mule-current-charset)
3314 (ps-set-font ps-current-font))
3315 (ps-output-string string)
3316 (ps-output " S\n"))
3317
3318 ((eq ps-mule-current-charset 'latin-iso8859-1)
3319 ;; Latin-1 can be printed by a normal ASCII font.
3320 (ps-set-font ps-current-font)
3321 (ps-output-string
3322 (string-as-unibyte (encode-coding-string string 'iso-latin-1)))
3323 (ps-output " S\n"))
3324
3325 ((eq ps-mule-current-charset 'composition)
3326 (let* ((ch (char-after from))
3327 (width (char-width ch))
3328 (ch-list (decompose-composite-char ch 'list t)))
3329 (if (consp (nth 1 ch-list))
3330 (ps-mule-plot-rule-cmpchar ch-list width font-type)
3331 (ps-mule-plot-cmpchar ch-list width t font-type))))
3332
3333 (t
3334 ;; No way to print this charset. Just show a vacant box of an
3335 ;; appropriate width.
3336 (ps-output (format "%d %d SB\n"
3337 (length string)
3338 (if (eq ps-mule-current-charset 'composition)
3339 (char-width (char-after from))
3340 (charset-width ps-mule-current-charset))))))
3341 wrappoint))
3342
3343;; Composite font support
3344
3345(defvar ps-mule-cmpchar-prologue-generated nil)
3346
3347(defconst ps-mule-cmpchar-prologue
3348 "%%%% Composite character handler
3349/CmpcharWidth 0 def
3350/CmpcharRelativeCompose 0 def
3351/CmpcharRelativeSkip 0.4 def
3352
3353%% Get a bounding box (relative to currentpoint) of STR.
3354/GetPathBox { % str |- --
3355 gsave
3356 currentfont /FontType get 3 eq { %ifelse
3357 stringwidth pop pop
3358 } {
3359 currentpoint /y exch def pop
3360 false charpath flattenpath pathbbox
3361 y sub /URY exch def pop
3362 y sub /LLY exch def pop
3363 } ifelse
3364 grestore
3365} bind def
3366
3367%% Beginning of composite char.
3368/BC { % str xoff width |- --
3369 /Cmpchar true def
3370 /CmpcharWidth exch def
3371 currentfont /RelativeCompose known {
3372 /CmpcharRelativeCompose currentfont /RelativeCompose get def
3373 } {
3374 /CmpcharRelativeCompose false def
3375 } ifelse
3376 /bgsave bg def /bgcolorsave bgcolor def
3377 /Effectsave Effect def
3378 gsave % Reflect effect only at first
3379 /Effect Effect 1 2 add 4 add 16 add and def
3380 /f0 findfont setfont ( ) 0 CmpcharWidth getinterval S
3381 grestore
3382 /Effect Effectsave 8 32 add and def % enable only shadow and outline
3383 false BG
3384 gsave SpaceWidth mul 0 rmoveto dup GetPathBox S grestore
3385 /y currentpoint exch pop def
3386 /HIGH URY y add def /LOW LLY y add def
3387} bind def
3388
3389%% End of composite char.
3390/EC { % -- |- --
3391 /bg bgsave def /bgcolor bgcolorsave def
3392 /Effect Effectsave def
3393 /Cmpchar false def
3394 CmpcharWidth SpaceWidth mul 0 rmoveto
3395} bind def
3396
3397%% Rule base composition
3398/RBC { % str xoff gref nref |- --
3399 /nref exch def /gref exch def
3400 gsave
3401 SpaceWidth mul 0 rmoveto
3402 dup
3403 GetPathBox
3404 [ HIGH currentpoint exch pop LOW HIGH LOW add 2 div ] gref get
3405 [ URY LLY sub LLY neg 0 URY LLY sub 2 div ] nref get
3406 sub /btm exch def
3407 /top btm URY LLY sub add def
3408 top HIGH gt { /HIGH top def } if
3409 btm LOW lt { /LOW btm def } if
3410 currentpoint pop btm LLY sub moveto
3411 S
3412 grestore
3413} bind def
3414
3415%% Relative composition
3416/RLC { % str |- --
3417 gsave
3418 dup GetPathBox
3419 CmpcharRelativeCompose type /integertype eq {
3420 LLY CmpcharRelativeCompose gt { % compose on top
3421 currentpoint pop HIGH LLY sub CmpcharRelativeSkip add moveto
3422 /HIGH HIGH URY LLY sub add CmpcharRelativeSkip add def
3423 } { URY 0 le { % compose under bottom
3424 currentpoint pop LOW LLY add CmpcharRelativeSkip sub moveto
3425 /LOW LOW URY LLY sub sub CmpcharRelativeSkip sub def
3426 } if } ifelse } if
3427 S
3428 grestore
3429} bind def
3430%%%% End of composite character handler
3431
3432"
3433 "PostScript code for printing composite characters.")
3434
3435(defun ps-mule-plot-rule-cmpchar (ch-rule-list total-width font-type)
3436 (let* ((leftmost 0.0)
3437 (rightmost (float (char-width (car ch-rule-list))))
3438 (l (cons '(3 . 3) ch-rule-list))
3439 (cmpchar-elements nil))
3440 (while l
3441 (let* ((this (car l))
3442 (gref (car this))
3443 (nref (cdr this))
3444 ;; X-axis info (0:left, 1:center, 2:right)
3445 (gref-x (% gref 3))
3446 (nref-x (% nref 3))
3447 ;; Y-axis info (0:top, 1:base, 2:bottom, 3:center)
3448 (gref-y (if (= gref 4) 3 (/ gref 3)))
3449 (nref-y (if (= nref 4) 3 (/ nref 3)))
3450 (width (float (char-width (car (cdr l)))))
3451 left)
3452 (setq left (+ leftmost
3453 (/ (* (- rightmost leftmost) gref-x) 2.0)
3454 (- (/ (* nref-x width) 2.0))))
3455 (setq cmpchar-elements
3456 (cons (list (car (cdr l)) left gref-y nref-y) cmpchar-elements))
3457 (if (< left leftmost)
3458 (setq leftmost left))
3459 (if (> (+ left width) rightmost)
3460 (setq rightmost (+ left width)))
3461 (setq l (nthcdr 2 l))))
3462 (if (< leftmost 0)
3463 (let ((l cmpchar-elements))
3464 (while l
3465 (setcar (cdr (car l))
3466 (- (nth 1 (car l)) leftmost))
3467 (setq l (cdr l)))))
3468 (ps-mule-plot-cmpchar (nreverse cmpchar-elements)
3469 total-width nil font-type)))
3470
3471(defun ps-mule-plot-cmpchar (elements total-width relativep font-type)
3472 (let* ((ch (if relativep (car elements) (car (car elements))))
3473 (str (ps-mule-prepare-cmpchar-font ch font-type)))
3474 (ps-output-string str)
3475 (ps-output (format " %d %d BC "
3476 (if relativep 0 (nth 1 (car elements)))
3477 total-width)))
3478 (setq elements (cdr elements))
3479 (while elements
3480 (let* ((elt (car elements))
3481 (ch (if relativep elt (car elt)))
3482 (str (ps-mule-prepare-cmpchar-font ch font-type)))
3483 (if relativep
3484 (progn
3485 (ps-output-string str)
3486 (ps-output " RLC "))
3487 (ps-output-string str)
3488 (ps-output (format " %d %d %d RBC "
3489 (nth 1 elt) (nth 2 elt) (nth 3 elt)))))
3490 (setq elements (cdr elements)))
3491 (ps-output "EC\n"))
3492
3493(defun ps-mule-prepare-cmpchar-font (char font-type)
3494 (let* ((ps-mule-current-charset (char-charset char))
3495 (font-spec (ps-mule-get-font-spec ps-mule-current-charset font-type))
3496 (encoding (ps-mule-font-spec-encoding font-spec))
3497 (str (char-to-string char)))
3498 (cond (font-spec
3499 (if (coding-system-p encoding)
3500 (setq str (encode-coding-string str encoding))
3501 (if (functionp encoding)
3502 (setq str (funcall encoding str))
3503 (if encoding
3504 (error "Invalid coding system or function: %s" encoding))))
3505 (setq str (string-as-unibyte str))
3506 (if (ps-mule-font-spec-src font-spec)
3507 (ps-mule-prepare-font font-spec str ps-mule-current-charset)
3508 (ps-set-font ps-current-font)))
3509
3510 ((eq ps-mule-current-charset 'latin-iso8859-1)
3511 (ps-set-font ps-current-font)
3512 (setq str
3513 (string-as-unibyte (encode-coding-string str 'iso-latin-1))))
3514
3515 (t
3516 ;; No font for CHAR.
3517 (ps-set-font ps-current-font)
3518 (setq str " ")))
3519 str))
3520
3521;; Bitmap font support
3522
3523(defvar ps-mule-bitmap-prologue-generated nil)
3524
3525(defconst ps-mule-bitmap-prologue
3526 "%%%% Bitmap font handler
3527
3528/str7 7 string def % working area
3529
3530%% We grow the dictionary one bunch (1024 entries) by one.
3531/BitmapDictArray 256 array def
3532/BitmapDictLength 1024 def
3533/BitmapDictIndex -1 def
3534
3535/NewBitmapDict { % -- |- --
3536 /BitmapDictIndex BitmapDictIndex 1 add def
3537 BitmapDictArray BitmapDictIndex BitmapDictLength dict put
3538} bind def
3539
3540%% Make at least one dictionary.
3541NewBitmapDict
3542
3543/AddBitmap { % gloval-charname bitmap-data |- --
3544 BitmapDictArray BitmapDictIndex get
3545 dup length BitmapDictLength ge {
3546 pop
3547 NewBitmapDict
3548 BitmapDictArray BitmapDictIndex get
3549 } if
3550 3 1 roll put
3551} bind def
3552
3553/GetBitmap { % gloval-charname |- bitmap-data
3554 0 1 BitmapDictIndex { BitmapDictArray exch get begin } for
3555 load
3556 0 1 BitmapDictIndex { pop end } for
3557} bind def
3558
3559%% Return a global character name which can be used as a key in the
3560%% bitmap dictionary.
3561/GlobalCharName { % fontidx code1 code2 |- gloval-charname
3562 exch 256 mul add exch 65536 mul add 16777216 add 16 str7 cvrs 0 66 put
3563 str7 cvn
3564} bind def
3565
3566%% Character code holder for a 2-byte character.
3567/FirstCode -1 def
3568
3569%% Glyph rendering procedure
3570/BuildGlyphCommon { % fontdict charname |- --
3571 1 index /FontDimension get 1 eq { /FirstCode 0 store } if
3572 NameIndexDict exch get % STACK: fontdict charcode
3573 FirstCode 0 lt { %ifelse
3574 %% This is the first byte of a 2-byte character. Just
3575 %% remember it for the moment.
3576 /FirstCode exch store
3577 pop
3578 0 0 setcharwidth
3579 } {
3580 1 index /FontSize get /size exch def
3581 1 index /FontIndex get exch FirstCode exch
3582 GlobalCharName GetBitmap /bmp exch def
3583 %% bmp == [ DWIDTH BBX-WIDTH BBX-HEIGHT BBX-XOFF BBX-YOFF BITMAP ]
3584 Cmpchar { %ifelse
3585 /FontMatrix get [ exch { size div } forall ] /mtrx exch def
3586 bmp 3 get bmp 4 get mtrx transform
3587 /LLY exch def pop
3588 bmp 1 get bmp 3 get add bmp 2 get bmp 4 get add mtrx transform
3589 /URY exch def pop
3590 } {
3591 pop
3592 } ifelse
3593 /FirstCode -1 store
3594
3595 bmp 0 get size div 0 % wx wy
3596 setcharwidth % We can't use setcachedevice here.
3597
3598 bmp 1 get 0 gt bmp 2 get 0 gt and {
3599 bmp 1 get bmp 2 get % width height
3600 true % polarity
3601 [ size 0 0 size neg bmp 3 get neg bmp 2 get bmp 4 get add ] % matrix
3602 bmp 5 1 getinterval cvx % datasrc
3603 imagemask
3604 } if
3605 } ifelse
3606} bind def
3607
3608/BuildCharCommon {
3609 1 index /Encoding get exch get
3610 1 index /BuildGlyph get exec
3611} bind def
3612
3613%% Bitmap font creater
3614
3615%% Common Encoding shared by all bitmap fonts.
3616/EncodingCommon 256 array def
3617%% Mapping table from character name to character code.
3618/NameIndexDict 256 dict def
36190 1 255 { %for
3620 /idx exch def
3621 /idxname idx 256 add 16 (XXX) cvrs dup 0 67 put cvn def % `C' == 67
3622 EncodingCommon idx idxname put
3623 NameIndexDict idxname idx put
3624} for
3625
3626/GlobalFontIndex 0 def
3627
3628%% fontname dimension fontsize relative-compose baseline-offset fbbx |- --
3629/BitmapFont {
3630 14 dict begin
3631 /FontBBox exch def
3632 /BaselineOffset exch def
3633 /RelativeCompose exch def
3634 /FontSize exch def
3635 /FontBBox [ FontBBox { FontSize div } forall ] def
3636 /FontDimension exch def
3637 /FontIndex GlobalFontIndex def
3638 /FontType 3 def
3639 /FontMatrix matrix def
3640 /Encoding EncodingCommon def
3641 /BuildGlyph { BuildGlyphCommon } def
3642 /BuildChar { BuildCharCommon } def
3643 currentdict end
3644 definefont pop
3645 /GlobalFontIndex GlobalFontIndex 1 add def
3646} bind def
3647
3648%% Define a new bitmap font.
3649%% fontname dimension fontsize relative-compose baseline-offset fbbx |- --
3650/NF {
3651 /fbbx exch def
3652 %% Convert BDF's FontBoundingBox to PostScript's FontBBox
3653 [ fbbx 2 get fbbx 3 get
3654 fbbx 2 get fbbx 0 get add fbbx 3 get fbbx 1 get add ]
3655 BitmapFont
3656} bind def
3657
3658%% Define a glyph for the specified font and character.
3659/NG { % fontname charcode bitmap-data |- --
3660 /bmp exch def
3661 exch findfont dup /BaselineOffset get bmp 4 get add bmp exch 4 exch put
3662 /FontIndex get exch
3663 dup 256 idiv exch 256 mod GlobalCharName
3664 bmp AddBitmap
3665} bind def
3666%%%% End of bitmap font handler
3667
3668")
3669
3670;; External library support.
3671
3672;; The following three functions are to be called from external
3673;; libraries which support bitmap fonts (e.g. `bdf') to get
3674;; appropriate PostScript code.
3675
3676(defun ps-mule-generate-bitmap-prologue ()
3677 (unless ps-mule-bitmap-prologue-generated
3678 (setq ps-mule-bitmap-prologue-generated t)
3679 (list ps-mule-bitmap-prologue)))
3680
3681(defun ps-mule-generate-bitmap-font (&rest args)
3682 (list (apply 'format "/%s %d %f %S %d %S NF\n" args)))
3683
3684(defun ps-mule-generate-bitmap-glyph (font-name code dwidth bbx bitmap)
3685 (format "/%s %d [ %d %d %d %d %d <%s> ] NG\n"
3686 font-name code
3687 dwidth (aref bbx 0) (aref bbx 1) (aref bbx 2) (aref bbx 3)
3688 bitmap))
3689
3690;; Mule specific initializers.
3691
3692(defun ps-mule-initialize ()
3693 "Produce Poscript code in the prologue part for multibyte characters."
3694 (setq ps-mule-current-charset 'ascii
3695 ps-mule-font-cache nil
3696 ps-mule-prologue-generated nil
3697 ps-mule-cmpchar-prologue-generated nil
3698 ps-mule-bitmap-prologue-generated nil)
3699 (mapcar (function (lambda (x) (setcar (cdr x) nil)))
3700 ps-mule-external-libraries))
3701
3702(defun ps-mule-begin (from to)
3703 (if (and (boundp 'enable-multibyte-characters)
3704 enable-multibyte-characters)
3705 ;; Initialize `ps-mule-charset-list'. If some characters aren't
3706 ;; printable, warn it.
3707 (let ((charsets (delete 'ascii (find-charset-region from to))))
3708 (setq ps-mule-charset-list charsets)
3709 (save-excursion
3710 (goto-char from)
3711 (if (search-forward "\200" to t)
3712 (setq ps-mule-charset-list
3713 (cons 'composition ps-mule-charset-list))))
3714 (if (and (catch 'tag
3715 (while charsets
3716 (if (or (eq (car charsets) 'composition)
3717 (ps-mule-printable-p (car charsets)))
3718 (setq charsets (cdr charsets))
3719 (throw 'tag t))))
3720 (not (y-or-n-p "Font for some characters not found, continue anyway? ")))
3721 (error "Printing cancelled"))))
3722
3723 (if ps-mule-charset-list
3724 (let ((l ps-mule-charset-list)
3725 font-spec)
3726 (unless ps-mule-prologue-generated
3727 (ps-output-prologue ps-mule-prologue)
3728 (setq ps-mule-prologue-generated t))
3729 ;; If external functions are necessary, generate prologues for them.
3730 (while l
3731 (if (and (eq (car l) 'composition)
3732 (not ps-mule-cmpchar-prologue-generated))
3733 (progn
3734 (ps-output-prologue ps-mule-cmpchar-prologue)
3735 (setq ps-mule-cmpchar-prologue-generated t))
3736 (if (setq font-spec (ps-mule-get-font-spec (car l) 'normal))
3737 (ps-mule-init-external-library font-spec)))
3738 (setq l (cdr l)))))
3739
3740 ;; If ASCII font is also specified in ps-mule-font-info-database,
3741 ;; use it istead of what specified in ps-font-info-database.
3742 (let ((font-spec (ps-mule-get-font-spec 'ascii 'normal)))
3743 (if font-spec
3744 (progn
3745 (unless ps-mule-prologue-generated
3746 (ps-output-prologue ps-mule-prologue)
3747 (setq ps-mule-prologue-generated t))
3748 (ps-mule-init-external-library font-spec)
3749 (let ((font (ps-font-alist 'ps-font-for-text))
3750 (i 0))
3751 (while font
3752 (let ((ps-current-font i))
3753 ;; Be sure to download a glyph for SPACE in advance.
3754 (ps-mule-prepare-font
3755 (ps-mule-get-font-spec 'ascii (car font))
3756 " " 'ascii 'no-setfont))
3757 (setq font (cdr font) i (1+ i))))))))
3758
3759
3760;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
3761
2744(defun ps-line-lengths-internal () 3762(defun ps-line-lengths-internal ()
2745 "Display the correspondence between a line length and a font size, 3763 "Display the correspondence between a line length and a font size,
2746using the current ps-print setup. 3764using the current ps-print setup.
@@ -2984,16 +4002,14 @@ page-height == bm + print-height + tm - ho - hh
2984(defun ps-output-string-prim (string) 4002(defun ps-output-string-prim (string)
2985 (insert "(") ;insert start-string delimiter 4003 (insert "(") ;insert start-string delimiter
2986 (save-excursion ;insert string 4004 (save-excursion ;insert string
2987 (insert string)) 4005 (insert (string-as-unibyte string)))
2988 ;; Find and quote special characters as necessary for PS 4006 ;; Find and quote special characters as necessary for PS
2989 ;; This skips everything except control chars, nonascii chars, 4007 ;; This skips everything except control chars, nonascii chars,
2990 ;; (, ) and \. 4008 ;; (, ) and \.
2991 (while (progn (skip-chars-forward " -'*-[]-~") (not (eobp))) 4009 (while (progn (skip-chars-forward " -'*-[]-~") (not (eobp)))
2992 (let ((special (following-char))) 4010 (let ((special (following-char)))
2993 (if (> (char-bytes special) 1) 4011 (delete-char 1)
2994 (forward-char) 4012 (insert (aref ps-string-escape-codes special))))
2995 (delete-char 1)
2996 (insert (aref ps-string-escape-codes special)))))
2997 (goto-char (point-max)) 4013 (goto-char (point-max))
2998 (insert ")")) ;insert end-string delimiter 4014 (insert ")")) ;insert end-string delimiter
2999 4015
@@ -3012,16 +4028,28 @@ page-height == bm + print-height + tm - ho - hh
3012(defun ps-output-list (the-list) 4028(defun ps-output-list (the-list)
3013 (mapcar 'ps-output the-list)) 4029 (mapcar 'ps-output the-list))
3014 4030
4031;; Output strings in the list ARGS in the PostScript prologue part.
4032(defun ps-output-prologue (args)
4033 (ps-output 'prologue (if (stringp args) (list args) args)))
4034
3015(defun ps-flush-output () 4035(defun ps-flush-output ()
3016 (save-excursion 4036 (save-excursion
3017 (set-buffer ps-spool-buffer) 4037 (set-buffer ps-spool-buffer)
3018 (goto-char (point-max)) 4038 (goto-char (point-max))
3019 (while ps-output-head 4039 (while ps-output-head
3020 (let ((it (car ps-output-head))) 4040 (let ((it (car ps-output-head)))
3021 (if (not (eq t it)) 4041 (cond
3022 (insert it) 4042 ((eq t it)
4043 (setq ps-output-head (cdr ps-output-head))
4044 (ps-output-string-prim (car ps-output-head)))
4045 ((eq 'prologue it)
3023 (setq ps-output-head (cdr ps-output-head)) 4046 (setq ps-output-head (cdr ps-output-head))
3024 (ps-output-string-prim (car ps-output-head)))) 4047 (save-excursion
4048 (search-backward "\nBeginDoc")
4049 (forward-char 1)
4050 (apply 'insert (car ps-output-head))))
4051 (t
4052 (insert it))))
3025 (setq ps-output-head (cdr ps-output-head)))) 4053 (setq ps-output-head (cdr ps-output-head))))
3026 (ps-init-output-queue)) 4054 (ps-init-output-queue))
3027 4055
@@ -3322,6 +4350,8 @@ page-height == bm + print-height + tm - ho - hh
3322 (setq font (cdr font) 4350 (setq font (cdr font)
3323 i (1+ i)))) 4351 i (1+ i))))
3324 4352
4353 (ps-mule-initialize)
4354
3325 (ps-output "\nBeginDoc\n\n" 4355 (ps-output "\nBeginDoc\n\n"
3326 "%%EndPrologue\n")) 4356 "%%EndPrologue\n"))
3327 4357
@@ -3355,13 +4385,21 @@ page-height == bm + print-height + tm - ho - hh
3355 (setq ps-showline-count (if ps-printing-region (car ps-printing-region) 1) 4385 (setq ps-showline-count (if ps-printing-region (car ps-printing-region) 1)
3356 ps-page-count 0 4386 ps-page-count 0
3357 ps-control-or-escape-regexp 4387 ps-control-or-escape-regexp
3358 (cond ((eq ps-print-control-characters '8-bit) 4388 (if ps-mule-charset-list
3359 "[\000-\037\177-\377]") 4389 (cond ((eq ps-print-control-characters '8-bit)
3360 ((eq ps-print-control-characters 'control-8-bit) 4390 "[^\040-\176]")
3361 "[\000-\037\177-\237]") 4391 ((eq ps-print-control-characters 'control-8-bit)
3362 ((eq ps-print-control-characters 'control) 4392 (string-as-multibyte "[^\040-\176\240-\377]"))
3363 "[\000-\037\177]") 4393 ((eq ps-print-control-characters 'control)
3364 (t "[\t\n\f]")))) 4394 (string-as-multibyte "[^\040-\176\200-\377]"))
4395 (t (string-as-multibyte "[^\000-\011\013\015-\377")))
4396 (cond ((eq ps-print-control-characters '8-bit)
4397 (string-as-unibyte "[\000-\037\177-\377]"))
4398 ((eq ps-print-control-characters 'control-8-bit)
4399 (string-as-unibyte "[\000-\037\177-\237]"))
4400 ((eq ps-print-control-characters 'control)
4401 "[\000-\037\177]")
4402 (t "[\t\n\f]")))))
3365 4403
3366(defmacro ps-page-number () 4404(defmacro ps-page-number ()
3367 `(1+ (/ (1- ps-page-count) ps-number-of-columns))) 4405 `(1+ (/ (1- ps-page-count) ps-number-of-columns)))
@@ -3398,7 +4436,8 @@ page-height == bm + print-height + tm - ho - hh
3398(defun ps-begin-page () 4436(defun ps-begin-page ()
3399 (ps-get-page-dimensions) 4437 (ps-get-page-dimensions)
3400 (setq ps-width-remaining ps-print-width 4438 (setq ps-width-remaining ps-print-width
3401 ps-height-remaining ps-print-height) 4439 ps-height-remaining ps-print-height
4440 ps-mule-current-charset 'ascii)
3402 4441
3403 (ps-header-page) 4442 (ps-header-page)
3404 4443
@@ -3455,7 +4494,13 @@ EndDSCPage\n"))
3455 (let* ((wrappoint (ps-find-wrappoint from to 4494 (let* ((wrappoint (ps-find-wrappoint from to
3456 (ps-avg-char-width 'ps-font-for-text))) 4495 (ps-avg-char-width 'ps-font-for-text)))
3457 (to (car wrappoint)) 4496 (to (car wrappoint))
3458 (string (buffer-substring-no-properties from to))) 4497 (string (buffer-substring-no-properties from to))
4498 (font-spec
4499 (ps-mule-get-font-spec
4500 'ascii
4501 (car (nth ps-current-font (ps-font-alist 'ps-font-for-text))))))
4502 (and font-spec
4503 (ps-mule-prepare-font font-spec string 'ascii))
3459 (ps-output-string string) 4504 (ps-output-string string)
3460 (ps-output " S\n") 4505 (ps-output " S\n")
3461 wrappoint)) 4506 wrappoint))
@@ -3491,7 +4536,8 @@ EndDSCPage\n"))
3491 )))))) 4536 ))))))
3492 4537
3493(defun ps-set-font (font) 4538(defun ps-set-font (font)
3494 (ps-output (format "/f%d F\n" (setq ps-current-font font)))) 4539 (setq ps-last-font (format "f%d" (setq ps-current-font font)))
4540 (ps-output (format "/%s F\n" ps-last-font)))
3495 4541
3496(defun ps-set-bg (color) 4542(defun ps-set-bg (color)
3497 (if (setq ps-current-bg color) 4543 (if (setq ps-current-bg color)
@@ -3532,6 +4578,8 @@ EndDSCPage\n"))
3532 (ps-output (number-to-string effects) " EF\n") 4578 (ps-output (number-to-string effects) " EF\n")
3533 (setq ps-current-effect effects))) 4579 (setq ps-current-effect effects)))
3534 4580
4581 (setq ps-mule-current-charset 'ascii)
4582
3535 ;; Starting at the beginning of the specified region... 4583 ;; Starting at the beginning of the specified region...
3536 (save-excursion 4584 (save-excursion
3537 (goto-char from) 4585 (goto-char from)
@@ -3540,19 +4588,26 @@ EndDSCPage\n"))
3540 ;; pagefeeds, control characters, and plot each chunk. 4588 ;; pagefeeds, control characters, and plot each chunk.
3541 (while (< from to) 4589 (while (< from to)
3542 (if (re-search-forward ps-control-or-escape-regexp to t) 4590 (if (re-search-forward ps-control-or-escape-regexp to t)
3543 ;; region with some control characters 4591 ;; region with some control characters or some multibyte characters
3544 (let* ((match-point (match-beginning 0)) 4592 (let* ((match-point (match-beginning 0))
3545 (match (char-after match-point))) 4593 (match (char-after match-point)))
3546 (ps-plot 'ps-basic-plot-string from (1- (point)) bg-color) 4594 (when (< from match-point)
4595 (unless (eq ps-mule-current-charset 'ascii)
4596 (ps-set-font ps-current-font)
4597 (setq ps-mule-current-charset 'ascii))
4598 (ps-plot 'ps-basic-plot-string from match-point bg-color))
3547 (cond 4599 (cond
3548 ((= match ?\t) ; tab 4600 ((= match ?\t) ; tab
3549 (let ((linestart (save-excursion (beginning-of-line) (point)))) 4601 (let ((linestart (save-excursion (beginning-of-line) (point))))
3550 (forward-char -1) 4602 (forward-char -1)
3551 (setq from (+ linestart (current-column))) 4603 (setq from (+ linestart (current-column)))
3552 (if (re-search-forward "[ \t]+" to t) 4604 (when (re-search-forward "[ \t]+" to t)
3553 (ps-plot 'ps-basic-plot-whitespace 4605 (unless (eq ps-mule-current-charset 'ascii)
3554 from (+ linestart (current-column)) 4606 (ps-set-font ps-current-font)
3555 bg-color)))) 4607 (setq ps-mule-current-charset 'ascii))
4608 (ps-plot 'ps-basic-plot-whitespace
4609 from (+ linestart (current-column))
4610 bg-color))))
3556 4611
3557 ((= match ?\n) ; newline 4612 ((= match ?\n) ; newline
3558 (ps-next-line)) 4613 (ps-next-line))
@@ -3563,11 +4618,21 @@ EndDSCPage\n"))
3563 (or (and (= (char-after (1- match-point)) ?\n) 4618 (or (and (= (char-after (1- match-point)) ?\n)
3564 (= ps-height-remaining ps-print-height)) 4619 (= ps-height-remaining ps-print-height))
3565 (ps-next-page))) 4620 (ps-next-page)))
4621
4622 ((> match 255) ; a multibyte character
4623 (let ((charset (char-charset match)))
4624 (or (eq charset 'composition)
4625 (ps-mule-skip-same-charset charset))
4626 (setq ps-mule-current-charset charset)
4627 (ps-plot 'ps-mule-plot-string match-point (point) bg-color)))
3566 ; characters from ^@ to ^_ and 4628 ; characters from ^@ to ^_ and
3567 (t ; characters from 127 to 255 4629 (t ; characters from 127 to 255
3568 (ps-control-character match))) 4630 (ps-control-character match)))
3569 (setq from (point))) 4631 (setq from (point)))
3570 ;; region without control characters 4632 ;; region without control characters nor multibyte characters
4633 (when (not (eq ps-mule-current-charset 'ascii))
4634 (ps-set-font ps-current-font)
4635 (setq ps-mule-current-charset 'ascii))
3571 (ps-plot 'ps-basic-plot-string from to bg-color) 4636 (ps-plot 'ps-basic-plot-string from to bg-color)
3572 (setq from to))))) 4637 (setq from to)))))
3573 4638
@@ -3696,18 +4761,29 @@ If FACE is not a valid face name, it is used default face."
3696 ;; Kludge-compatible: 4761 ;; Kludge-compatible:
3697 (memq face kind-list)))) 4762 (memq face kind-list))))
3698 4763
3699(defun ps-face-bold-p (face)
3700 (if (eq ps-print-emacs-type 'emacs)
3701 (or (face-bold-p face)
3702 (memq face ps-bold-faces))
3703 (ps-xemacs-face-kind-p face 'WEIGHT_NAME "bold\\|demibold" ps-bold-faces)))
3704 4764
3705(defun ps-face-italic-p (face) 4765(cond ((eq ps-print-emacs-type 'emacs) ; emacs
3706 (if (eq ps-print-emacs-type 'emacs) 4766
3707 (or (face-italic-p face) 4767 (defun ps-face-bold-p (face)
3708 (memq face ps-italic-faces)) 4768 (or (face-bold-p face)
3709 (or (ps-xemacs-face-kind-p face 'ANGLE_NAME "i\\|o" ps-italic-faces) 4769 (memq face ps-bold-faces)))
3710 (ps-xemacs-face-kind-p face 'SLANT "i\\|o" ps-italic-faces)))) 4770
4771 (defun ps-face-italic-p (face)
4772 (or (face-italic-p face)
4773 (memq face ps-italic-faces)))
4774 )
4775 ; xemacs
4776 ; lucid
4777 ; epoch
4778 (t ; epoch
4779 (defun ps-face-bold-p (face)
4780 (ps-xemacs-face-kind-p face 'WEIGHT_NAME "bold\\|demibold" ps-bold-faces))
4781
4782 (defun ps-face-italic-p (face)
4783 (or (ps-xemacs-face-kind-p face 'ANGLE_NAME "i\\|o" ps-italic-faces)
4784 (ps-xemacs-face-kind-p face 'SLANT "i\\|o" ps-italic-faces)))
4785 ))
4786
3711 4787
3712(defun ps-face-underlined-p (face) 4788(defun ps-face-underlined-p (face)
3713 (or (face-underline-p face) 4789 (or (face-underline-p face)
@@ -3859,7 +4935,19 @@ If FACE is not a valid face name, it is used default face."
3859 4935
3860 ((eq ps-print-emacs-type 'emacs) 4936 ((eq ps-print-emacs-type 'emacs)
3861 (let ((property-change from) 4937 (let ((property-change from)
3862 (overlay-change from)) 4938 (overlay-change from)
4939 (save-buffer-invisibility-spec buffer-invisibility-spec)
4940 (buffer-invisibility-spec
4941 (and (listp buffer-invisibility-spec)
4942 (let ((seq buffer-invisibility-spec)
4943 elt res)
4944 (while seq
4945 (setq elt (car seq)
4946 seq (cdr seq))
4947 (or (eq elt 'invisible)
4948 (and (listp elt) (eq (car elt) 'invisible))
4949 (setq res (cons elt res))))
4950 (nreverse seq)))))
3863 (while (< from to) 4951 (while (< from to)
3864 (if (< property-change to) ; Don't search for property change 4952 (if (< property-change to) ; Don't search for property change
3865 ; unless previous search succeeded. 4953 ; unless previous search succeeded.
@@ -3880,10 +4968,10 @@ If FACE is not a valid face name, it is used default face."
3880 (cond ((let ((prop (get-text-property from 'invisible))) 4968 (cond ((let ((prop (get-text-property from 'invisible)))
3881 ;; Decide whether this invisible property 4969 ;; Decide whether this invisible property
3882 ;; really makes the text invisible. 4970 ;; really makes the text invisible.
3883 (if (eq buffer-invisibility-spec t) 4971 (if (eq save-buffer-invisibility-spec t)
3884 (not (null prop)) 4972 (not (null prop))
3885 (or (memq prop buffer-invisibility-spec) 4973 (or (memq prop save-buffer-invisibility-spec)
3886 (assq prop buffer-invisibility-spec)))) 4974 (assq prop save-buffer-invisibility-spec))))
3887 'emacs--invisible--face) 4975 'emacs--invisible--face)
3888 ((get-text-property from 'face)) 4976 ((get-text-property from 'face))
3889 (t 'default))) 4977 (t 'default)))
@@ -3898,14 +4986,15 @@ If FACE is not a valid face name, it is used default face."
3898 0))) 4986 0)))
3899 (and (or overlay-invisible overlay-face) 4987 (and (or overlay-invisible overlay-face)
3900 (> overlay-priority face-priority) 4988 (> overlay-priority face-priority)
3901 (setq face (cond ((if (eq buffer-invisibility-spec t) 4989 (setq face
3902 (not (null overlay-invisible)) 4990 (cond ((if (eq save-buffer-invisibility-spec t)
3903 (or (memq overlay-invisible 4991 (not (null overlay-invisible))
3904 buffer-invisibility-spec) 4992 (or (memq overlay-invisible
3905 (assq overlay-invisible 4993 save-buffer-invisibility-spec)
3906 buffer-invisibility-spec))) 4994 (assq overlay-invisible
3907 nil) 4995 save-buffer-invisibility-spec)))
3908 ((and face overlay-face))) 4996 nil)
4997 ((and face overlay-face)))
3909 face-priority overlay-priority))) 4998 face-priority overlay-priority)))
3910 (setq overlays (cdr overlays)))) 4999 (setq overlays (cdr overlays))))
3911 ;; Plot up to this record. 5000 ;; Plot up to this record.
@@ -3927,7 +5016,6 @@ If FACE is not a valid face name, it is used default face."
3927 (narrow-to-region from to) 5016 (narrow-to-region from to)
3928 (and ps-razzle-dazzle 5017 (and ps-razzle-dazzle
3929 (message "Formatting...%3d%%" (setq ps-razchunk 0))) 5018 (message "Formatting...%3d%%" (setq ps-razchunk 0)))
3930 (set-buffer buffer)
3931 (setq ps-source-buffer buffer 5019 (setq ps-source-buffer buffer
3932 ps-spool-buffer (get-buffer-create ps-spool-buffer-name)) 5020 ps-spool-buffer (get-buffer-create ps-spool-buffer-name))
3933 (ps-init-output-queue) 5021 (ps-init-output-queue)
@@ -3948,6 +5036,7 @@ If FACE is not a valid face name, it is used default face."
3948 (save-excursion 5036 (save-excursion
3949 (set-buffer ps-source-buffer) 5037 (set-buffer ps-source-buffer)
3950 (if needs-begin-file (ps-begin-file)) 5038 (if needs-begin-file (ps-begin-file))
5039 (ps-mule-begin from to)
3951 (ps-begin-job) 5040 (ps-begin-job)
3952 (ps-begin-page)) 5041 (ps-begin-page))
3953 (set-buffer ps-source-buffer) 5042 (set-buffer ps-source-buffer)
@@ -3988,6 +5077,9 @@ If FACE is not a valid face name, it is used default face."
3988 5077
3989 (and ps-razzle-dazzle (message "Formatting...done")))))) 5078 (and ps-razzle-dazzle (message "Formatting...done"))))))
3990 5079
5080;; To avoid compilation gripes
5081(defvar dos-ps-printer nil)
5082
3991;; Permit dynamic evaluation at print time of `ps-lpr-switches'. 5083;; Permit dynamic evaluation at print time of `ps-lpr-switches'.
3992(defun ps-do-despool (filename) 5084(defun ps-do-despool (filename)
3993 (if (or (not (boundp 'ps-spool-buffer)) 5085 (if (or (not (boundp 'ps-spool-buffer))
@@ -4013,14 +5105,12 @@ If FACE is not a valid face name, it is used default face."
4013 (list (concat "-P" ps-printer-name))) 5105 (list (concat "-P" ps-printer-name)))
4014 ps-lpr-switches))) 5106 ps-lpr-switches)))
4015 (if (and (memq system-type '(ms-dos windows-nt)) 5107 (if (and (memq system-type '(ms-dos windows-nt))
4016 (or (and (boundp 'dos-ps-printer) 5108 (or (stringp dos-ps-printer)
4017 (stringp (symbol-value 'dos-ps-printer))) 5109 (stringp ps-printer-name)))
4018 (stringp (symbol-value 'ps-printer-name))))
4019 (write-region (point-min) (point-max) 5110 (write-region (point-min) (point-max)
4020 (or (and (boundp 'dos-ps-printer) 5111 (if (stringp dos-ps-printer)
4021 (stringp (symbol-value 'dos-ps-printer)) 5112 dos-ps-printer
4022 (symbol-value 'dos-ps-printer)) 5113 ps-printer-name)
4023 (symbol-value 'ps-printer-name))
4024 t 0) 5114 t 0)
4025 (apply 'call-process-region 5115 (apply 'call-process-region
4026 (point-min) (point-max) ps-lpr-command nil 5116 (point-min) (point-max) ps-lpr-command nil