changeset 47711:d99378556333

(ucs-mule-to-mule-unicode): Define this translation table name here. (ucs-mule-cjk-to-unicode): New translation table name. (ccl-encode-unicode-font): Merge the code in ucs-tables.el. (font-ccl-encoder-alist): Change the font registry pattern to "ISO10646.*-*".
author Kenichi Handa <handa@m17n.org>
date Mon, 30 Sep 2002 06:41:01 +0000
parents 6025c7c2fa78
children 9505d3b154c9
files lisp/international/fontset.el
diffstat 1 files changed, 60 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/international/fontset.el	Mon Sep 30 06:40:31 2002 +0000
+++ b/lisp/international/fontset.el	Mon Sep 30 06:41:01 2002 +0000
@@ -142,35 +142,70 @@
 (set-font-encoding "ISO8859-1" 'ascii 0)
 (set-font-encoding "JISX0201" 'latin-jisx0201 0)
 
+;; Allow display of arbitrary characters with an iso-10646-encoded
+;; (`Unicode') font.
+(define-translation-table 'ucs-mule-to-mule-unicode
+  ucs-mule-to-mule-unicode)
+(define-translation-hash-table 'ucs-mule-cjk-to-unicode
+  ucs-mule-cjk-to-unicode)
+
 (define-ccl-program ccl-encode-unicode-font
   `(0
-    (if (r0 == ,(charset-id 'ascii))
-	((r2 = r1)
-	 (r1 = 0))
-      (if (r0 == ,(charset-id 'latin-iso8859-1))
-	  ((r2 = (r1 + 128))
-	   (r1 = 0))
-	(if (r0 == ,(charset-id 'mule-unicode-0100-24ff))
-	    ((r1 *= 96)
-	     (r1 += r2)
-	     (r1 += ,(- #x100 (* 32 96) 32))
-	     (r1 >8= 0)
-	     (r2 = r7))
-	  (if (r0 == ,(charset-id 'mule-unicode-2500-33ff))
-	      ((r1 *= 96)
-	       (r1 += r2)
-	       (r1 += ,(- #x2500 (* 32 96) 32))
-	       (r1 >8= 0)
-	       (r2 = r7))
-	    (if (r0 == ,(charset-id 'mule-unicode-e000-ffff))
-		((r1 *= 96)
-		 (r1 += r2)
-		 (r1 += ,(- #xe000 (* 32 96) 32))
-		 (r1 >8= 0)
-		 (r2 = r7)))))))))
+    ;; r0: charset-id
+    ;; r1: 1st position code
+    ;; r2: 2nd position code (if r0 is 2D charset)
+    ((if (r0 == ,(charset-id 'ascii))
+	 ((r2 = r1)
+	  (r1 = 0))
+       ;; At first, try to get a Unicode code point directly.
+       ((if (r2 >= 0)
+	    ;; This is a 2D charset.
+	    (r1 = ((r1 << 7) | r2)))
+	(lookup-character ucs-mule-cjk-to-unicode r0 r1)
+	(if r7
+	    ;; We got it!
+	    ((r1 = (r0 >> 8))
+	     (r2 = (r0 & #xFF)))
+	  ;; Look for a translation for non-ASCII chars.
+	  ((translate-character ucs-mule-to-mule-unicode r0 r1)
+	   (if (r0 == ,(charset-id 'latin-iso8859-1))
+	       ((r2 = (r1 + 128))
+		(r1 = 0))
+	     ((r2 = (r1 & #x7F))
+	      (r1 >>= 7)
+	      (if (r0 == ,(charset-id 'mule-unicode-0100-24ff))
+		  ((r1 *= 96)
+		   (r1 += r2)
+		   (r1 += ,(- #x100 (* 32 96) 32))
+		   (r1 >8= 0)
+		   (r2 = r7))
+		(if (r0 == ,(charset-id 'mule-unicode-2500-33ff))
+		    ((r1 *= 96)
+		     (r1 += r2)
+		     (r1 += ,(- #x2500 (* 32 96) 32))
+		     (r1 >8= 0)
+		     (r2 = r7))
+		  (if (r0 == ,(charset-id 'mule-unicode-e000-ffff))
+		      ((r1 *= 96)
+		       (r1 += r2)
+		       (r1 += ,(- #xe000 (* 32 96) 32))
+		       (r1 >8= 0)
+		       (r2 = r7))
+		    ;; No way, use the glyph for U+FFFD.
+		    ((r1 = #xFF)
+		     (r2 = #xFD)))))))))))))
+  "Encode characters for display with iso10646 font.
+Translate through the translation-hash-table named
+`ucs-mule-cjk-to-unicode' and the translation-table named
+`ucs-mule-to-mule-unicode' initially.")
 
+;; Use the above CCL encoder for Unicode fonts.  Please note that the
+;; regexp is not simply "ISO10646-1" because there exists, for
+;; instance, the following Devanagari Unicode fonts:
+;;	-misc-fixed-medium-r-normal--24-240-72-72-c-120-iso10646.indian-1
+;;	-sibal-devanagari-medium-r-normal--24-240-75-75-P--iso10646-dev
 (setq font-ccl-encoder-alist
-      (cons '("ISO10646-1" . ccl-encode-unicode-font)
+      (cons '("ISO10646.*-*" . ccl-encode-unicode-font)
 	    font-ccl-encoder-alist))
 
 ;; Setting for suppressing XLoadQueryFont on big fonts.