comparison lisp/language/tibet-util.el @ 29363:1ebd8db9c3dc

(tibetan-add-components): Fixes for new encoding of Tibetan characters. (tibetan-decompose-precomposition-alist): New variable. (tibetan-decompose-region): Convert precomposed characters to non-precomposed characters. (tibetan-decompose-string): Likewise. (tibetan-composition-function): Fix args to thibetan-compose-string.
author Kenichi Handa <handa@m17n.org>
date Thu, 01 Jun 2000 10:59:56 +0000
parents 60eb71a9f901
children c3845ffcb423
comparison
equal deleted inserted replaced
29362:038c13f83357 29363:1ebd8db9c3dc
116 ;;; (Sanskrit visarga, though it is a vowel modifier, is considered 116 ;;; (Sanskrit visarga, though it is a vowel modifier, is considered
117 ;;; to be a punctuation.) 117 ;;; to be a punctuation.)
118 ;;; 118 ;;;
119 ;;; Here are examples of the words "bsgrubs" and "h'uM" 119 ;;; Here are examples of the words "bsgrubs" and "h'uM"
120 ;;; 120 ;;;
121 ;;; 4$(7"70"714%qx!"U0"G###C"U14"70"714"G0"G1(B 4$(7"Hx!#Ax!"Ur'"_0"H"A"U"_1(B 121 ;;; 4$(7"70"714%qx!"U0"G###C"U14"70"714"G0"G1(B 4$(7"Hx!"Rx!"Ur'"_0"H"A"U"_1(B
122 ;;; 122 ;;;
123 ;;; M 123 ;;; M
124 ;;; b s b s h 124 ;;; b s b s h
125 ;;; g ' 125 ;;; g '
126 ;;; r u 126 ;;; r u
142 rule) 142 rule)
143 ;; Special treatment for 'a chung. 143 ;; Special treatment for 'a chung.
144 ;; If 'a follows a consonant, turn it into the subjoined form. 144 ;; If 'a follows a consonant, turn it into the subjoined form.
145 (if (and (= char ?$(7"A(B) 145 (if (and (= char ?$(7"A(B)
146 (aref (char-category-set (car last)) ?0)) 146 (aref (char-category-set (car last)) ?0))
147 (setq char ?$(7#A(B)) 147 (setq char ?$(7"R(B)) ;; modified for new font by Tomabechi 1999/12/10
148 148
149 (cond 149 (cond
150 ;; Compose upper vowel sign vertically over. 150 ;; Compose upper vowel sign vertically over.
151 ((aref (char-category-set char) ?2) 151 ((aref (char-category-set char) ?2)
152 (setq rule stack-upper)) 152 (setq rule stack-upper))
153 153
154 ;; Compose lower vowel sign vertically under. 154 ;; Compose lower vowel sign vertically under.
155 ((aref (char-category-set char) ?3) 155 ((aref (char-category-set char) ?3)
156 (setq rule stack-under)) 156 (if (eq char ?$(7"Q(B) ;; `$(7"Q(B' should not visible when composed.
157 (setq rule nil)
158 (setq rule stack-under)))
157 159
158 ;; Transform ra-mgo (superscribed r) if followed by a subjoined 160 ;; Transform ra-mgo (superscribed r) if followed by a subjoined
159 ;; consonant other than w, ', y, r. 161 ;; consonant other than w, ', y, r.
160 ((and (= (car last) ?$(7"C(B) 162 ((and (= (car last) ?$(7"C(B)
161 (not (memq char '(?$(7#>(B ?$(7#A(B ?$(7#B(B ?$(7#C(B)))) 163 (not (memq char '(?$(7#>(B ?$(7"R(B ?$(7#B(B ?$(7#C(B))))
162 (setcar last ?$(7#P(B) 164 (setcar last ?$(7!"(B) ;; modified for newfont by Tomabechi 1999/12/10
163 (setq rule stack-under)) 165 (setq rule stack-under))
164 166
165 ;; Transform initial base consonant if followed by a subjoined 167 ;; Transform initial base consonant if followed by a subjoined
166 ;; consonant but 'a. 168 ;; consonant but 'a.
167 (t 169 (t
168 (let ((laststr (char-to-string (car last)))) 170 (let ((laststr (char-to-string (car last))))
169 (if (and (/= char ?$(7#A(B) 171 (if (and (/= char ?$(7"R(B) ;; modified for new font by Tomabechi
170 (string-match "[$(7"!(B-$(7"="?"@"D(B-$(7"J(B]" laststr)) 172 (string-match "[$(7"!(B-$(7"="?"@"D(B-$(7"J"K(B]" laststr))
171 (setcar last (string-to-char 173 (setcar last (string-to-char
172 (cdr (assoc (char-to-string (car last)) 174 (cdr (assoc (char-to-string (car last))
173 tibetan-base-to-subjoined-alist))))) 175 tibetan-base-to-subjoined-alist)))))
174 (setq rule stack-under)))) 176 (setq rule stack-under))))
175 177
176 (setcdr last (list rule char)))) 178 (if rule
179 (setcdr last (list rule char)))))
177 180
178 ;;;###autoload 181 ;;;###autoload
179 (defun tibetan-compose-string (str) 182 (defun tibetan-compose-string (str)
180 "Compose Tibetan string STR." 183 "Compose Tibetan string STR."
181 (let ((idx 0)) 184 (let ((idx 0))
229 (while (< (point) to) 232 (while (< (point) to)
230 (tibetan-add-components components (following-char)) 233 (tibetan-add-components components (following-char))
231 (forward-char 1)) 234 (forward-char 1))
232 (compose-region from to components))))))) 235 (compose-region from to components)))))))
233 236
234 ;;;###autoload 237 (defvar tibetan-decompose-precomposition-alist
235 (defalias 'tibetan-decompose-region 'decompose-region) 238 (mapcar (function (lambda (x) (cons (string-to-char (cdr x)) (car x))))
236 ;;;###autoload 239 tibetan-precomposition-rule-alist))
237 (defalias 'tibetan-decompose-string 'decompose-string) 240
241 ;;;###autoload
242 (defun tibetan-decompose-region (from to)
243 "Decompose Tibetan text in the region FROM and TO.
244 This is different from decompose-region because precomposed Tibetan characters
245 are decomposed into normal Tiebtan character sequences."
246 (interactive "r")
247 (save-restriction
248 (narrow-to-region from to)
249 (decompose-region from to)
250 (goto-char from)
251 (while (not (eobp))
252 (let* ((char (following-char))
253 (slot (assq char tibetan-decompose-precomposition-alist)))
254 (if slot
255 (progn
256 (delete-char 1)
257 (insert (cdr slot)))
258 (forward-char 1))))))
259
260
261 ;;;###autoload
262 (defun tibetan-decompose-string (str)
263 "Decompose Tibetan string STR.
264 This is different from decompose-string because precomposed Tibetan characters
265 are decomposed into normal Tiebtan character sequences."
266 (let ((new "")
267 (len (length str))
268 (idx 0)
269 char slot)
270 (while (< idx len)
271 (setq char (aref str idx)
272 slot (assq (aref str idx) tibetan-decompose-precomposition-alist)
273 new (concat new (if slot (cdr slot) (char-to-string char)))
274 idx (1+ idx)))
275 new))
238 276
239 ;;;###autoload 277 ;;;###autoload
240 (defun tibetan-composition-function (from to pattern &optional string) 278 (defun tibetan-composition-function (from to pattern &optional string)
241 (if string 279 (if string
242 (tibetan-compose-string string) 280 (tibetan-compose-string string)