From c054d399007b8e474503284447af04c6f81f275d Mon Sep 17 00:00:00 2001 From: tomo Date: Thu, 24 Jan 2008 08:08:18 +0000 Subject: [PATCH] (chise-tex-accent-macro-alist): New variable. (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 | 81 +++++++++++++++++++++++++++++------------- 1 file changed, 56 insertions(+), 25 deletions(-) diff --git a/chise2otf/elisp/chise-tex.el b/chise2otf/elisp/chise-tex.el index 092b39b..3eb1948 100644 --- a/chise2otf/elisp/chise-tex.el +++ b/chise2otf/elisp/chise-tex.el @@ -55,6 +55,23 @@ (=ucs-bmp@cns "UCScns" 4 X) )) +(defvar chise-tex-accent-macro-alist + '((?\u0300 . "`") ; + (?\u0301 . "'") ; + (?\u0302 . "^") ; + (?\u0303 . "~") ; + (?\u0304 . "=") ; + (?\u0306 . "u") ; + (?\u0307 . ".") ; + (?\u0308 . "\"") ; + (?\u0309 . "Hook") + (?\u030C . "v") ; + (?\u0323 . "d") ; + (?\u0327 . "c") ; + (?\u032E . "ubreve") + (?\u0331 . "umacron") + )) + (defun chise-tex-encode-region-for-gb (start end) (interactive "r") (save-excursion @@ -259,6 +276,28 @@ (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)) @@ -275,9 +314,11 @@ (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) @@ -289,21 +330,7 @@ (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)) @@ -312,18 +339,19 @@ (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)) @@ -415,6 +443,9 @@ (narrow-to-region start end) (goto-char start) (let (macro code ret me rest spec) + (while (search-forward "\\={\\i}" nil t) + (replace-match ".DNo" t t)) + (goto-char start) (while (re-search-forward "\\\\\\(.\\){\\(.\\)}" nil t) (when (and (setq macro -- 1.7.10.4