(chise-tex-coded-charset-expression-alist): Add setting for
authortomo <tomo>
Wed, 21 Jan 2009 22:56:41 +0000 (22:56 +0000)
committertomo <tomo>
Wed, 21 Jan 2009 22:56:41 +0000 (22:56 +0000)
`thai-tis620' to decode \ThaiTIS{XX}.
(chise-tex-encode-ucs-char-at-point): New function.
(chise-tex-encode-region-for-jis): Use
`chise-tex-encode-ucs-char-at-point'.
(chise-tex-encode-region-for-utf-8-jis): Likewise.

chise2otf/elisp/chise-tex.el

index cd6ea49..3760ef7 100644 (file)
@@ -53,6 +53,7 @@
     (=hanziku-11       "HanzikuK"      4 X)
     (=hanziku-12       "HanzikuL"      4 X)
     (=ucs-bmp@cns      "UCScns"        4 X)
+    (thai-tis620       "ThaiTIS"       2 X)
     ))
 
 (defvar chise-tex-accent-macro-alist
                (t
                 (forward-char))))))))
 
+(defun chise-tex-encode-ucs-char-at-point (&optional chr)
+  (unless chr
+    (setq chr (char-after)))
+  (let (ret rest spec)
+    (cond
+     ((and (encode-char chr '=ks-x1001)
+          (setq ret (or (encode-char chr '=ucs@ks)
+                        (char-ucs chr))))
+      (delete-char)
+      ;; (if (eq (char-before) ?\e$B!T\e(B)
+      ;;     (insert " "))
+      (insert (format "\\UCSks{%04X}" ret))
+      t)
+     ((setq ret (encode-char chr '=ucs-hangul))
+      (delete-char)
+      ;; (if (eq (char-before) ?\e$B!T\e(B)
+      ;;     (insert " "))
+      (insert (format "\\UCSks{%04X}" ret))
+      t)
+     ((eq chr ?\u00B2)
+      (delete-char)
+      (insert "$^2$")
+      t)
+     ((eq chr ?\u00B3)
+      (delete-char)
+      (insert "$^3$")
+      t)
+     ((eq chr ?\u0111)
+      (delete-char)
+      (insert "{\\usefont{T1}{pxr}{m}{n}\\dj}")
+      t)
+     ((eq chr ?\u014B)
+      (delete-char)
+      (insert "{\\usefont{T1}{pxr}{m}{n}\\ng}")
+      t)
+     ((eq chr ?\u0282)
+      (delete-char)
+      (insert "{\\usefont{T1}{pxr}{m}{n}\\k{s}}")
+      t)
+     ((eq chr ?\u0294)
+      (delete-char)
+      (insert "\\UCSjis{0294}")
+      t)
+     ((eq chr ?\u2022)
+      (delete-char)
+      (insert "\\textbullet{}")
+      t)
+     ((eq chr ?\u2080)
+      (delete-char)
+      (insert "$_0$")
+      t)
+     ((eq chr ?\u2081)
+      (delete-char)
+      (insert "$_1$")
+      t)
+     ((eq chr ?\u2082)
+      (delete-char)
+      (insert "$_2$")
+      t)
+     ((eq chr ?\u2083)
+      (delete-char)
+      (insert "$_3$")
+      t)
+     ((eq chr ?\u2084)
+      (delete-char)
+      (insert "$_4$")
+      t)
+     ((eq chr ?\u2085)
+      (delete-char)
+      (insert "$_5$")
+      t)
+     ((eq chr ?\u2086)
+      (delete-char)
+      (insert "$_6$")
+      t)
+     ((eq chr ?\u2087)
+      (delete-char)
+      (insert "$_7$")
+      t)
+     ((eq chr ?\u2088)
+      (delete-char)
+      (insert "$_8$")
+      t)
+     ((eq chr ?\u2089)
+      (delete-char)
+      (insert "$_9$")
+      t)
+     ((eq chr ?\u208A)
+      (delete-char)
+      (insert "$_+$")
+      t)
+     ((eq chr ?\u208B)
+      (delete-char)
+      (insert "$_-$")
+      t)
+     ((eq chr ?\u208C)
+      (delete-char)
+      (insert "$_=$")
+      t)
+     ((eq chr ?\u208D)
+      (delete-char)
+      (insert "$_($")
+      t)
+     ((eq chr ?\u208E)
+      (delete-char)
+      (insert "$_)$")
+      t)
+     ((eq chr ?\u2637)
+      (delete-char)
+      (insert "\\UCSgb{2637}")
+      t)
+     ((eq (encode-char chr '=ucs@jis) #x8DBC)
+      (delete-char)
+      (insert "\\GTpjG{4933}")
+      t)
+     ((and (encode-char chr '=ucs@jp)
+          (setq ret (char-representative-of-domain chr 'gb))
+          (setq ret (encode-char ret '=ucs@gb))
+          (<= ret #xFFFF))
+      (delete-char)
+      ;; (if (eq (char-before) ?\e$B!T\e(B)
+      ;;     (insert " "))
+      (insert (format "\\UCSgb{%04X}" ret))
+      t)
+     ((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)
+      ;; (if (eq (char-before) ?\e$B!T\e(B)
+      ;;     (insert " "))
+      (insert (format (format "\\%s{%%0%d%s}"
+                             (nth 1 spec)
+                             (nth 2 spec)
+                             (nth 3 spec))
+                     ret))
+      t)
+     )))
+
 (defun chise-tex-encode-region-for-jis (start end)
   (interactive "r")
   (save-excursion
     (save-restriction
       (narrow-to-region start end)
       (goto-char start)
-      (let (chr ret rest spec modifier base modifier-1)
+      (let (chr ret
+               ;; rest spec
+               modifier base modifier-1)
        (while (and (skip-chars-forward "\x00-\x7F")
                    (not (eobp)))
          (setq chr (char-after))
                 ;; (if (eq (char-before) ?\e$B!T\e(B)
                 ;;     (insert " "))
                 (insert (format "\\UCSjis{%04X}" ret)))
-               ((and (encode-char chr '=ks-x1001)
-                     (setq ret (or (encode-char chr '=ucs@ks)
-                                   (char-ucs chr))))
-                (delete-char)
-                ;; (if (eq (char-before) ?\e$B!T\e(B)
-                ;;     (insert " "))
-                (insert (format "\\UCSks{%04X}" ret)))
-               ((setq ret (encode-char chr '=ucs-hangul))
-                (delete-char)
-                ;; (if (eq (char-before) ?\e$B!T\e(B)
-                ;;     (insert " "))
-                (insert (format "\\UCSks{%04X}" ret)))
-               ((eq chr ?\u00B2)
-                (delete-char)
-                (insert "$^2$"))
-               ((eq chr ?\u00B3)
-                (delete-char)
-                (insert "$^3$"))
-               ((eq chr ?\u0111)
-                (delete-char)
-                (insert "{\\usefont{T1}{pxr}{m}{n}\\dj}"))
-               ((eq chr ?\u014B)
-                (delete-char)
-                (insert "{\\usefont{T1}{pxr}{m}{n}\\ng}"))
-               ((eq chr ?\u0282)
-                (delete-char)
-                (insert "{\\usefont{T1}{pxr}{m}{n}\\k{s}}"))
-               ((eq chr ?\u2022)
-                (delete-char)
-                (insert "\\textbullet{}"))
-               ((eq chr ?\u2081)
-                (delete-char)
-                (insert "$_1$"))
-               ((eq chr ?\u2082)
-                (delete-char)
-                (insert "$_2$"))
-               ((eq chr ?\u2083)
-                (delete-char)
-                (insert "$_3$"))
-               ((eq chr ?\u2085)
-                (delete-char)
-                (insert "$_5$"))
-               ((eq chr ?\u0294)
-                (delete-char)
-                (insert "\\UCSjis{0294}"))
-               ((and (encode-char chr '=ucs@jp)
-                     (setq ret (char-representative-of-domain chr 'gb))
-                     (setq ret (encode-char ret '=ucs@gb))
-                     (<= ret #xFFFF))
-                (delete-char)
-                ;; (if (eq (char-before) ?\e$B!T\e(B)
-                ;;     (insert " "))
-                (insert (format "\\UCSgb{%04X}" ret)))
-               ((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)
-                ;; (if (eq (char-before) ?\e$B!T\e(B)
-                ;;     (insert " "))
-                (insert (format (format "\\%s{%%0%d%s}"
-                                        (nth 1 spec)
-                                        (nth 2 spec)
-                                        (nth 3 spec))
-                                ret)))
-               (t
+                ((chise-tex-encode-ucs-char-at-point chr))
+                (t
                 (forward-char))))))))
 
 (defun chise-tex-encode-region-for-utf-8-jis (start end)
       (narrow-to-region start end)
       (goto-char start)
       (let ((font-encoding 'T1)
-           chr ret rest spec modifier base modifier-1 pos)
+           chr ret
+           ;; rest spec
+           modifier base modifier-1 pos)
        (while (and (skip-chars-forward "\x00-\x7F")
                    (not (eobp)))
          (setq chr (char-after))
                   ;;     (insert " "))
                   ;; (insert (format "\\UCSjis{%04X}" ret))
                   (forward-char))
-                 ((and (encode-char chr '=ks-x1001)
-                       (setq ret (or (encode-char chr '=ucs@ks)
-                                     (char-ucs chr))))
-                  (delete-char)
-                  ;; (if (eq (char-before) ?\e$B!T\e(B)
-                  ;;     (insert " "))
-                  (insert (format "\\UCSks{%04X}" ret)))
-                 ((setq ret (encode-char chr '=ucs-hangul))
-                  (delete-char)
-                  ;; (if (eq (char-before) ?\e$B!T\e(B)
-                  ;;     (insert " "))
-                  (insert (format "\\UCSks{%04X}" ret)))
-                 ((eq chr ?\u00B2)
-                  (delete-char)
-                  (insert "$^2$"))
-                 ((eq chr ?\u00B3)
-                  (delete-char)
-                  (insert "$^3$"))
-                 ((eq chr ?\u0111)
-                  (delete-char)
-                  (insert "{\\usefont{T1}{pxr}{m}{n}\\dj}"))
-                 ((eq chr ?\u014B)
-                  (delete-char)
-                  (insert "{\\usefont{T1}{pxr}{m}{n}\\ng}"))
-                 ((eq chr ?\u0282)
-                  (delete-char)
-                  (insert "{\\usefont{T1}{pxr}{m}{n}\\k{s}}"))
-                 ((eq chr ?\u0294)
-                  (delete-char)
-                  (insert "\\UCSjis{0294}"))
-                 ((eq chr ?\u2022)
-                  (delete-char)
-                  (insert "\\textbullet{}"))
-                 ((eq chr ?\u2081)
-                  (delete-char)
-                  (insert "$_1$"))
-                 ((eq chr ?\u2082)
-                  (delete-char)
-                  (insert "$_2$"))
-                 ((eq chr ?\u2083)
-                  (delete-char)
-                  (insert "$_3$"))
-                 ((eq chr ?\u2085)
-                  (delete-char)
-                  (insert "$_5$"))
-                 ((eq chr ?\u2637)
-                  (delete-char)
-                  (insert "\\UCSgb{2637}"))
-                 ((eq (encode-char chr '=ucs@jis) #x8DBC)
-                  (delete-char)
-                  (insert (format "\\GTpjG{4933}" ret))
-                  )
-                 ((and (encode-char chr '=ucs@jp)
-                       (setq ret (char-representative-of-domain chr 'gb))
-                       (setq ret (encode-char ret '=ucs@gb))
-                       (<= ret #xFFFF))
-                  (delete-char)
-                  ;; (if (eq (char-before) ?\e$B!T\e(B)
-                  ;;     (insert " "))
-                  (insert (format "\\UCSgb{%04X}" ret)))
-                 ((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)
-                  ;; (if (eq (char-before) ?\e$B!T\e(B)
-                  ;;     (insert " "))
-                  (insert (format (format "\\%s{%%0%d%s}"
-                                          (nth 1 spec)
-                                          (nth 2 spec)
-                                          (nth 3 spec))
-                                  ret)))
-                 (t
+                  ((chise-tex-encode-ucs-char-at-point chr))
+                  (t
                   (forward-char))))))))))
 
 (defun chise-tex-decode-region (start end)