X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/0cf0138e2d3c5027ec8d95ad487c1e9a54f324aa..937640a621a4ce2e5e56eaecca37a2a28a584318:/lisp/ps-mule.el diff --git a/lisp/ps-mule.el b/lisp/ps-mule.el index 7bb9f6145a..ec7b3b22fc 100644 --- a/lisp/ps-mule.el +++ b/lisp/ps-mule.el @@ -1,13 +1,14 @@ ;;; ps-mule.el --- provide multi-byte character facility to ps-print -;; Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. +;; Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 +;; Free Software Foundation, Inc. ;; Author: Vinicius Jose Latorre ;; Kenichi Handa (multi-byte characters) ;; Maintainer: Kenichi Handa (multi-byte characters) ;; Vinicius Jose Latorre ;; Keywords: wp, print, PostScript, multibyte, mule -;; Time-stamp: <2001/08/15 15:34:11 vinicius> +;; Time-stamp: <2003/05/14 22:19:41 vinicius> ;; This file is part of GNU Emacs. @@ -212,53 +213,6 @@ Any other value is treated as nil." (const bdf-font-except-latin) (const :tag "nil" nil)) :group 'ps-print-font) - -(eval-and-compile - ;; For Emacs 20.2 and the earlier version. - (if (and (boundp 'mule-version) - (not (string< (symbol-value 'mule-version) "4.0"))) - ;; mule package is loaded - (progn - (defalias 'ps-mule-next-point '1+) - (defalias 'ps-mule-chars-in-string 'length) - (defalias 'ps-mule-string-char 'aref) - (defsubst ps-mule-next-index (str i) (1+ i))) - ;; mule package isn't loaded or mule version lesser than 4.0 - (defun ps-mule-next-point (arg) - (save-excursion (goto-char arg) (forward-char 1) (point))) - (defun ps-mule-chars-in-string (string) - (/ (length string) - (charset-bytes (char-charset (string-to-char string))))) - (defun ps-mule-string-char (string idx) - (string-to-char (substring string idx))) - (defun ps-mule-next-index (string i) - (+ i (charset-bytes (char-charset (string-to-char string))))) - ) - ;; For Emacs 20.4 and the earlier version. - (if (and (boundp 'mule-version) - (string< (symbol-value 'mule-version) "5.0")) - ;; mule package is loaded and mule version is lesser than 5.0 - (progn - (defun encode-composition-rule (rule) - (if (= (car rule) 4) (setcar rule 10)) - (if (= (cdr rule) 4) (setcdr rule 10)) - (+ (* (car rule) 12) (cdr rule))) - (defun find-composition (pos &rest ignore) - (let ((ch (char-after pos))) - (and ch (eq (char-charset ch) 'composition) - (let ((components (decompose-composite-char ch 'vector t))) - (list pos (ps-mule-next-point pos) components - (integerp (aref components 1)) nil - (char-width ch))))))) - ;; mule package isn't loaded - (or (fboundp 'encode-composition-rule) - (defun encode-composition-rule (rule) - 130)) - (or (fboundp 'find-composition) - (defun find-composition (pos &rest ignore) - nil)) - )) - (defvar ps-mule-font-info-database nil "Alist of charsets with the corresponding font information. @@ -272,7 +226,7 @@ CHARSET is a charset (symbol) for this font family, FONT-TYPE is a font type: normal, bold, italic, or bold-italic. -FONT-SRC is a font source: builtin, ps-bdf, vflib, or nil. +FONT-SRC is a font source: builtin, bdf, vflib, or nil. If FONT-SRC is builtin, FONT-NAME is a built-in PostScript font name. @@ -464,21 +418,21 @@ See also `ps-mule-font-info-database-bdf'.") (defun ps-mule-encode-bit (string delta) (let* ((dim (charset-dimension (char-charset (string-to-char string)))) - (len (* (ps-mule-chars-in-string string) dim)) + (len (* (length string) dim)) (str (make-string len 0)) (i 0) (j 0)) (if (= dim 1) (while (< j len) (aset str j - (+ (nth 1 (split-char (ps-mule-string-char string i))) delta)) - (setq i (ps-mule-next-index string i) + (+ (nth 1 (split-char (aref string i))) delta)) + (setq i (1+ i) j (1+ j))) (while (< j len) - (let ((split (split-char (ps-mule-string-char string i)))) + (let ((split (split-char (aref string i)))) (aset str j (+ (nth 1 split) delta)) (aset str (1+ j) (+ (nth 2 split) delta)) - (setq i (ps-mule-next-index string i) + (setq i (1+ i) j (+ j 2))))) str)) @@ -514,13 +468,13 @@ See also `ps-mule-font-info-database-bdf'.") ;; Special encoding for mule-unicode-* characters. (defun ps-mule-encode-ucs2 (string) - (let* ((len (ps-mule-chars-in-string string)) + (let* ((len (length string)) (str (make-string (* 2 len) 0)) (i 0) (j 0) ch hi lo) (while (< i len) - (setq ch (encode-char (ps-mule-string-char string i) 'ucs) + (setq ch (encode-char (aref string i) 'ucs) hi (lsh ch -8) lo (logand ch 255)) (aset str j hi) @@ -842,11 +796,11 @@ the sequence." (cons from ps-width-remaining) (cons (if composition (nth 1 composition) - (ps-mule-next-point from)) + (1+ from)) run-width))) ;; We assume that all characters in this range have the same width. (setq char-width (* char-width (charset-width ps-mule-current-charset))) - (let ((run-width (* (chars-in-region from to) char-width))) + (let ((run-width (* (abs (- from to)) char-width))) (if (> run-width ps-width-remaining) (cons (min to (save-excursion @@ -895,7 +849,7 @@ the sequence." ;; This case is obsolete for Emacs 21. ((eq ps-mule-current-charset 'composition) - (ps-mule-plot-composition from (ps-mule-next-point from) bg-color)) + (ps-mule-plot-composition from (1+ from) bg-color)) (t ;; No way to print this charset. Just show a vacant box of an @@ -1439,36 +1393,17 @@ FONTTAG should be a string \"/h0\" or \"/h1\"." ;;;###autoload (defun ps-mule-header-string-charsets () "Return a list of character sets that appears in header strings." - (let ((str "")) - (when ps-print-header - (let ((tail (list ps-left-header ps-right-header))) - (while tail - ;; Simulate what is done by ps-generate-header-line to get a - ;; string to plot. - (let ((count 0) - (tmp (car tail))) - (setq tail (cdr tail)) - (while (and tmp (< count ps-header-lines)) - (let ((elt (car tmp))) - (setq tmp (cdr tmp) - count (1+ count) - str (concat str - (cond ((stringp elt) elt) - ((and (symbolp elt) (fboundp elt)) - (funcall elt)) - ((and (symbolp elt) (boundp elt)) - (symbol-value elt)) - (t "")))))))))) - (let ((len (length str)) - (i 0) - charset-list) - (while (< i len) - (let ((charset (char-charset (aref str i)))) - (setq i (1+ i)) - (or (eq charset 'ascii) - (memq charset charset-list) - (setq charset-list (cons charset charset-list))))) - charset-list))) + (let* ((str (ps-header-footer-string)) + (len (length str)) + (i 0) + charset-list) + (while (< i len) + (let ((charset (char-charset (aref str i)))) + (setq i (1+ i)) + (or (eq charset 'ascii) + (memq charset charset-list) + (setq charset-list (cons charset charset-list))))) + charset-list)) ;;;###autoload (defun ps-mule-begin-job (from to) @@ -1588,4 +1523,5 @@ This checks if all multi-byte characters in the region are printable or not." (provide 'ps-mule) +;;; arch-tag: bca017b2-66a7-4e59-8584-103e749eadbe ;;; ps-mule.el ends here