(chise-xetex-encode-region-for-utf-8-jis): New function.
authorMORIOKA Tomohiko <tomo.git@chise.org>
Wed, 1 Sep 2010 22:19:14 +0000 (22:19 +0000)
committerMORIOKA Tomohiko <tomo.git@chise.org>
Wed, 1 Sep 2010 22:19:14 +0000 (22:19 +0000)
(utf-8-jp-tex): Fix DOC.
(utf-8-jp-xetex): New coding-system.

elisp/chise-tex.el

index 834a6f3..5a31d0c 100644 (file)
@@ -1,6 +1,6 @@
 ;;; chise-tex.el --- Coding-system based chise2otf like tool
 
-;; Copyright (C) 2004,2005,2006,2007,2008,2009 MORIOKA Tomohiko
+;; Copyright (C) 2004,2005,2006,2007,2008,2009,2010 MORIOKA Tomohiko
 
 ;; Author: MORIOKA Tomohiko <tomo@kanji.zinbun.kyoto-u.ac.jp>
 ;; Keywords: OTF package, pTeX, CHISE, Multiscript, Multilingual
                   (t
                   (forward-char))))))))))
 
+(defun chise-xetex-encode-region-for-utf-8-jis (start end)
+  (interactive "r")
+  (save-excursion
+    (save-restriction
+      (narrow-to-region start end)
+      (goto-char start)
+      (let (chr ret)
+       (while (and (skip-chars-forward "\x00-\x7F")
+                   (not (eobp)))
+         (setq chr (char-after))
+         (cond ((encode-char chr '=jis-x0208@1983)
+                (forward-char))
+               ((encode-char chr '=jis-x0208@1990)
+                (forward-char))
+                ;; ((encode-char chr '=jis-x0212)
+                ;;  (forward-char))
+               ((and (setq ret (encode-char chr '=ucs@JP))
+                     (>= ret #x20000))
+                (insert "\\SIPChars{")
+                (forward-char)
+                (insert "}"))
+               ((encode-char chr '=jis-x0213-1@2000)
+                (forward-char))
+               ((encode-char chr '=jis-x0213-1@2004)
+                (forward-char))
+               ((encode-char chr '=jis-x0213-2)
+                (forward-char))
+               ((setq ret (encode-char chr 'thai-tis620))
+                (delete-char)
+                (insert (format "\\ThaiTIS{%X}" (logior ret #x80)))
+                )
+               ((or (encode-char chr '=ks-x1001)
+                    (encode-char chr '=ucs-hangul))
+                (insert "\\KoreanChars{")
+                (forward-char)
+                (insert "}"))
+               ((encode-char chr '=ucs@gb)
+                (insert "\\GBChars{")
+                (forward-char)
+                (insert "}"))
+               ((encode-char chr '=ucs@cns)
+                (insert "\\CNSChars{")
+                (forward-char)
+                (insert "}"))
+               ((and (encode-char chr '=ucs@JP)
+                     (setq ret (char-representative-of-domain chr 'gb))
+                     (setq ret (encode-char ret '=ucs@gb)))
+                (insert "\\GBChars{")
+                (forward-char)
+                (insert "}"))
+               ((setq ret (char-feature chr '=decomposition))
+                (delete-char)
+                (dolist (c ret)
+                  (insert c)))
+               ((catch 'tag
+                  (setq rest chise-tex-coded-charset-expression-alist)
+                  (while (setq spec (car rest))
+                    (if (setq ret (encode-char chr (car spec)))
+                        (throw 'tag ret))
+                    (setq rest (cdr rest))))
+                (delete-char)
+                (insert (format (format "\\%s{%%0%d%s}"
+                                        (nth 1 spec)
+                                        (nth 2 spec)
+                                        (nth 3 spec))
+                                ret))
+                )
+               (t
+                (forward-char))))))))
+
 (defun chise-tex-decode-region (start end)
   (interactive "r")
   (save-excursion
 
 (make-coding-system
  'utf-8-jp-tex 'utf-8
- "Coding-system of UTF-8 for common glyphs used in Japan."
+ "Coding-system of UTF-8 for upLaTeX with common glyphs used in Japan."
  '(pre-write-conversion chise-tex-encode-region-for-utf-8-jis
    post-read-conversion chise-tex-decode-region
    charset-g0 =ucs@jp
    charset-g2 =>ucs
    mnemonic "upTeX(JP)/UTF8"))
 
+(make-coding-system
+ 'utf-8-jp-xetex 'utf-8
+ "Coding-system of UTF-8 for XeLaTeX with common glyphs used in Japan."
+ '(pre-write-conversion chise-xetex-encode-region-for-utf-8-jis
+   post-read-conversion chise-tex-decode-region
+   charset-g0 =ucs@jp
+   charset-g1 =>ucs-jis
+   charset-g2 =>ucs
+   mnemonic "XeTeX(JP)/UTF8"))
+
 
 ;;; @ End.
 ;;;