(chise-tex-accent-macro-alist): New variable.
authortomo <tomo>
Thu, 24 Jan 2008 08:08:18 +0000 (08:08 +0000)
committertomo <tomo>
Thu, 24 Jan 2008 08:08:18 +0000 (08:08 +0000)
(chise-tex-encode-region-for-utf-8-jis): Support Greek characters;
don't encode U+00C5 and U+00E5; refer `chise-tex-accent-macro-alist';
use "\'{\^X}" instead of "\CircAcute{X}"; use "\~{\^X}" instead of
"\CircTilde{X}"; add setting for `HornTilde'.
(chise-tex-decode-region): Decode "\={\i}".

chise2otf/elisp/chise-tex.el

index 092b39b..3eb1948 100644 (file)
     (=ucs-bmp@cns      "UCScns"        4 X)
     ))
 
+(defvar chise-tex-accent-macro-alist
+  '((?\u0300 . "`") ; <COMBINING GRAVE ACCENT>
+    (?\u0301 . "'") ; <COMBINING ACUTE ACCENT>
+    (?\u0302 . "^") ; <COMBINING CIRCUMFLEX ACCENT>
+    (?\u0303 . "~") ; <COMBINING TILDE>
+    (?\u0304 . "=") ; <COMBINING MACRON>
+    (?\u0306 . "u") ; <COMBINING BREVE>
+    (?\u0307 . ".") ; <COMBINING DOT ABOVE>
+    (?\u0308 . "\"") ; <COMBINING DIAERESIS>
+    (?\u0309 . "Hook")
+    (?\u030C . "v") ; <COMBINING CARON>
+    (?\u0323 . "d") ; <COMBINING DOT BELOW>
+    (?\u0327 . "c") ; <COMBINING CEDILLA>
+    (?\u032E . "ubreve")
+    (?\u0331 . "umacron")
+    ))
+
 (defun chise-tex-encode-region-for-gb (start end)
   (interactive "r")
   (save-excursion
              (forward-char)
              (setq font-encoding 'T2A))
            )
+          ((and (setq ret (encode-char chr '=ucs))
+                (and (<= #x0374 ret)(<= ret #x03F3)))
+           (if (eq font-encoding 'LGR)
+               (forward-char)
+             (setq pos (point))
+             (unless (and (prog1
+                              (search-backward
+                               "\\fontencoding{LGR}\\selectfont{}" nil t)
+                            (goto-char pos))
+                          (eq pos (match-end 0)))
+               (insert "\\fontencoding{LGR}\\selectfont{}")
+               )
+             (forward-char)
+             (setq font-encoding 'LGR))
+           (skip-chars-forward "\u0374-\u03F3")
+           (unless (eq font-encoding 'T1)
+             (unless (looking-at
+                      "\\\\fontencoding{T1}\\\\selectfont{}")
+               (insert "\\fontencoding{T1}\\selectfont{}")
+               )
+             (setq font-encoding 'T1))
+           )
           (t
            (unless (eq font-encoding 'T1)
               (setq pos (point))
                   (insert "\\UCSjis{00D7}"))
                  ((encode-char chr '=jis-x0208-1983)
                   (forward-char))
-                 ((and (setq ret (encode-char chr '=ucs))
-                       (or (and (<= #x0374 ret)(<= ret #x03F3))
-                           (eq ret #x1E2B)))
+                 ((and (setq ret (char-ucs chr))
+                       (or (eq ret #x00C5)
+                           (eq ret #x00E5)
+                           (eq ret #x1E2B)
+                           ))
                   (forward-char))
                  ;; ((setq ret (encode-char chr '=jis-x0208-1990))
                  ;;  (delete-char)
                        (not (eq (char-ucs chr) #x0451))
                        (setq ret (char-feature chr '=decomposition))
                        (setq modifier (assq (nth 1 ret)
-                                            '((?\u0300 . "`")
-                                              (?\u0301 . "'")
-                                              (?\u0302 . "^")
-                                              (?\u0303 . "~")
-                                              (?\u0304 . "=")
-                                              (?\u0306 . "u")
-                                              (?\u0307 . ".")
-                                              (?\u0308 . "\"")
-                                              (?\u0309 . "Hook")
-                                              (?\u030C . "v")
-                                              (?\u0323 . "d")
-                                              (?\u0327 . "c")
-                                              (?\u032E . "ubreve")
-                                              (?\u0331 . "umacron")
-                                              ))))
+                                            chise-tex-accent-macro-alist)))
                   (delete-char)
                   (setq base (car ret))
                   (if (and (setq ret (char-feature base '=decomposition))
                                        (cdr
                                         (assq (nth 1 ret)
                                               '((?\u0302
-                                                 (?\u0300 . "CircGrave")
-                                                 (?\u0301 . "CircAcute")
-                                                 (?\u0303 . "CircTilde")
-                                                 (?\u0309 . "CircHook")
+                                                 (?\u0300 . "\\CircGrave{%c}")
+                                                 (?\u0301 . "\\'{\\^%c}")
+                                                 (?\u0303 . "\\~{\\^%c}")
+                                                 (?\u0309 . "\\CircHook{%c}")
                                                  )
                                                 (?\u031B
-                                                 (?\u0301 . "HornAcute")
+                                                 (?\u0301 . "\\HornAcute{%c}")
+                                                 (?\u0303 . "\\HornTilde{%c}")
                                                  )
                                                 (?\u0323
-                                                 (?\u0302 . "Circudot")
+                                                 (?\u0302 . "\\Circudot{%c}")
                                                  )))))))
-                      (insert (format "\\%s{%c}" (cdr modifier-1) (car ret)))
+                      (insert (format (cdr modifier-1) (car ret)))
                     (insert (format "\\%s{%c}" (cdr modifier) base))))
                  ((and (or (encode-char chr '=jis-x0213-1-2000)
                            (encode-char chr '=jis-x0213-2-2000))
       (narrow-to-region start end)
       (goto-char start)
       (let (macro code ret me rest spec)
+       (while (search-forward "\\={\\i}" nil t)
+         (replace-match "\e.D\eNo" t t))
+       (goto-char start)
        (while (re-search-forward "\\\\\\(.\\){\\(.\\)}" nil t)
          (when (and
                 (setq macro