diff options
| author | Kenichi Handa | 2008-08-29 08:01:03 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2008-08-29 08:01:03 +0000 |
| commit | ef90a979c4cdb4a17fcfc8ccb8271348e1755f36 (patch) | |
| tree | 705a5863eee9c374b9673a970470f27d78500075 | |
| parent | 4699a15aedf6ee20abee438c84fcabe874a79aa7 (diff) | |
| download | emacs-ef90a979c4cdb4a17fcfc8ccb8271348e1755f36.tar.gz emacs-ef90a979c4cdb4a17fcfc8ccb8271348e1755f36.zip | |
Encoding changed to utf-8.
(thai-composition-function): Argument changed.
| -rw-r--r-- | lisp/language/thai-util.el | 225 |
1 files changed, 113 insertions, 112 deletions
diff --git a/lisp/language/thai-util.el b/lisp/language/thai-util.el index 9359441b4b5..a5f35892cde 100644 --- a/lisp/language/thai-util.el +++ b/lisp/language/thai-util.el | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | ;;; thai-util.el --- utilities for Thai -*- coding: iso-2022-7bit; -*- | 1 | ;;; thai-util.el --- utilities for Thai -*- coding: utf-8; -*- |
| 2 | 2 | ||
| 3 | ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, | 3 | ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
| 4 | ;; 2005, 2006, 2007, 2008 | 4 | ;; 2005, 2006, 2007, 2008 |
| @@ -49,107 +49,107 @@ | |||
| 49 | ;; | 49 | ;; |
| 50 | ;; where C: consonant, V: vowel upper, v: vowel lower, | 50 | ;; where C: consonant, V: vowel upper, v: vowel lower, |
| 51 | ;; T: tone mark, U: tone mark and upper sign. | 51 | ;; T: tone mark, U: tone mark and upper sign. |
| 52 | ;; Special rule: The sign `,Tl(B' can be put on the vowel `,TT(B'. | 52 | ;; Special rule: The sign `์' can be put on the vowel `ิ'. |
| 53 | 53 | ||
| 54 | 54 | ||
| 55 | (defvar thai-composition-pattern | 55 | (defvar thai-composition-pattern |
| 56 | "\\cc\\(\\cu\\|\\cI\\cU\\|\\cv\\ct?\\)\\|\\cv\\ct\\|\\cI\\cU" | 56 | "\\cc\\(\\cu\\|\\cI\\cU\\|\\cv\\ct?\\)\\|\\cv\\ct\\|\\cI\\cU" |
| 57 | "Regular expression matching a Thai composite sequence.") | 57 | "Regular expression matching a Thai composite sequence.") |
| 58 | 58 | ||
| 59 | (let ((l '((?,T!(B consonant "LETTER KO KAI") ; 0xA1 | 59 | (let ((l '((?ก consonant "LETTER KO KAI") ; 0xA1 |
| 60 | (?,T"(B consonant "LETTER KHO KHAI") ; 0xA2 | 60 | (?ข consonant "LETTER KHO KHAI") ; 0xA2 |
| 61 | (?,T#(B consonant "LETTER KHO KHUAT") ; 0xA3 | 61 | (?ฃ consonant "LETTER KHO KHUAT") ; 0xA3 |
| 62 | (?,T$(B consonant "LETTER KHO KHWAI") ; 0xA4 | 62 | (?ค consonant "LETTER KHO KHWAI") ; 0xA4 |
| 63 | (?,T%(B consonant "LETTER KHO KHON") ; 0xA5 | 63 | (?ฅ consonant "LETTER KHO KHON") ; 0xA5 |
| 64 | (?,T&(B consonant "LETTER KHO RAKHANG") ; 0xA6 | 64 | (?ฆ consonant "LETTER KHO RAKHANG") ; 0xA6 |
| 65 | (?,T'(B consonant "LETTER NGO NGU") ; 0xA7 | 65 | (?ง consonant "LETTER NGO NGU") ; 0xA7 |
| 66 | (?,T((B consonant "LETTER CHO CHAN") ; 0xA8 | 66 | (?จ consonant "LETTER CHO CHAN") ; 0xA8 |
| 67 | (?,T)(B consonant "LETTER CHO CHING") ; 0xA9 | 67 | (?ฉ consonant "LETTER CHO CHING") ; 0xA9 |
| 68 | (?,T*(B consonant "LETTER CHO CHANG") ; 0xAA | 68 | (?ช consonant "LETTER CHO CHANG") ; 0xAA |
| 69 | (?,T+(B consonant "LETTER SO SO") ; 0xAB | 69 | (?ซ consonant "LETTER SO SO") ; 0xAB |
| 70 | (?,T,(B consonant "LETTER CHO CHOE") ; 0xAC | 70 | (?ฌ consonant "LETTER CHO CHOE") ; 0xAC |
| 71 | (?,T-(B consonant "LETTER YO YING") ; 0xAD | 71 | (?ญ consonant "LETTER YO YING") ; 0xAD |
| 72 | (?,T.(B consonant "LETTER DO CHADA") ; 0xAE | 72 | (?ฎ consonant "LETTER DO CHADA") ; 0xAE |
| 73 | (?,T/(B consonant "LETTER TO PATAK") ; 0xAF | 73 | (?ฏ consonant "LETTER TO PATAK") ; 0xAF |
| 74 | (?,T0(B consonant "LETTER THO THAN") ; 0xB0 | 74 | (?ฐ consonant "LETTER THO THAN") ; 0xB0 |
| 75 | (?,T1(B consonant "LETTER THO NANGMONTHO") ; 0xB1 | 75 | (?ฑ consonant "LETTER THO NANGMONTHO") ; 0xB1 |
| 76 | (?,T2(B consonant "LETTER THO PHUTHAO") ; 0xB2 | 76 | (?ฒ consonant "LETTER THO PHUTHAO") ; 0xB2 |
| 77 | (?,T3(B consonant "LETTER NO NEN") ; 0xB3 | 77 | (?ณ consonant "LETTER NO NEN") ; 0xB3 |
| 78 | (?,T4(B consonant "LETTER DO DEK") ; 0xB4 | 78 | (?ด consonant "LETTER DO DEK") ; 0xB4 |
| 79 | (?,T5(B consonant "LETTER TO TAO") ; 0xB5 | 79 | (?ต consonant "LETTER TO TAO") ; 0xB5 |
| 80 | (?,T6(B consonant "LETTER THO THUNG") ; 0xB6 | 80 | (?ถ consonant "LETTER THO THUNG") ; 0xB6 |
| 81 | (?,T7(B consonant "LETTER THO THAHAN") ; 0xB7 | 81 | (?ท consonant "LETTER THO THAHAN") ; 0xB7 |
| 82 | (?,T8(B consonant "LETTER THO THONG") ; 0xB8 | 82 | (?ธ consonant "LETTER THO THONG") ; 0xB8 |
| 83 | (?,T9(B consonant "LETTER NO NU") ; 0xB9 | 83 | (?น consonant "LETTER NO NU") ; 0xB9 |
| 84 | (?,T:(B consonant "LETTER BO BAIMAI") ; 0xBA | 84 | (?บ consonant "LETTER BO BAIMAI") ; 0xBA |
| 85 | (?,T;(B consonant "LETTER PO PLA") ; 0xBB | 85 | (?ป consonant "LETTER PO PLA") ; 0xBB |
| 86 | (?,T<(B consonant "LETTER PHO PHUNG") ; 0xBC | 86 | (?ผ consonant "LETTER PHO PHUNG") ; 0xBC |
| 87 | (?,T=(B consonant "LETTER FO FA") ; 0xBD | 87 | (?ฝ consonant "LETTER FO FA") ; 0xBD |
| 88 | (?,T>(B consonant "LETTER PHO PHAN") ; 0xBE | 88 | (?พ consonant "LETTER PHO PHAN") ; 0xBE |
| 89 | (?,T?(B consonant "LETTER FO FAN") ; 0xBF | 89 | (?ฟ consonant "LETTER FO FAN") ; 0xBF |
| 90 | (?,T@(B consonant "LETTER PHO SAMPHAO") ; 0xC0 | 90 | (?ภ consonant "LETTER PHO SAMPHAO") ; 0xC0 |
| 91 | (?,TA(B consonant "LETTER MO MA") ; 0xC1 | 91 | (?ม consonant "LETTER MO MA") ; 0xC1 |
| 92 | (?,TB(B consonant "LETTER YO YAK") ; 0xC2 | 92 | (?ย consonant "LETTER YO YAK") ; 0xC2 |
| 93 | (?,TC(B consonant "LETTER RO RUA") ; 0xC3 | 93 | (?ร consonant "LETTER RO RUA") ; 0xC3 |
| 94 | (?,TD(B vowel-base "LETTER RU (Pali vowel letter)") ; 0xC4 | 94 | (?ฤ vowel-base "LETTER RU (Pali vowel letter)") ; 0xC4 |
| 95 | (?,TE(B consonant "LETTER LO LING") ; 0xC5 | 95 | (?ล consonant "LETTER LO LING") ; 0xC5 |
| 96 | (?,TF(B vowel-base "LETTER LU (Pali vowel letter)") ; 0xC6 | 96 | (?ฦ vowel-base "LETTER LU (Pali vowel letter)") ; 0xC6 |
| 97 | (?,TG(B consonant "LETTER WO WAEN") ; 0xC7 | 97 | (?ว consonant "LETTER WO WAEN") ; 0xC7 |
| 98 | (?,TH(B consonant "LETTER SO SALA") ; 0xC8 | 98 | (?ศ consonant "LETTER SO SALA") ; 0xC8 |
| 99 | (?,TI(B consonant "LETTER SO RUSI") ; 0xC9 | 99 | (?ษ consonant "LETTER SO RUSI") ; 0xC9 |
| 100 | (?,TJ(B consonant "LETTER SO SUA") ; 0xCA | 100 | (?ส consonant "LETTER SO SUA") ; 0xCA |
| 101 | (?,TK(B consonant "LETTER HO HIP") ; 0xCB | 101 | (?ห consonant "LETTER HO HIP") ; 0xCB |
| 102 | (?,TL(B consonant "LETTER LO CHULA") ; 0xCC | 102 | (?ฬ consonant "LETTER LO CHULA") ; 0xCC |
| 103 | (?,TM(B consonant "LETTER O ANG") ; 0xCD | 103 | (?อ consonant "LETTER O ANG") ; 0xCD |
| 104 | (?,TN(B consonant "LETTER HO NOK HUK") ; 0xCE | 104 | (?ฮ consonant "LETTER HO NOK HUK") ; 0xCE |
| 105 | (?,TO(B special "PAI YAN NOI (abbreviation)") ; 0xCF | 105 | (?ฯ special "PAI YAN NOI (abbreviation)") ; 0xCF |
| 106 | (?,TP(B vowel-base "VOWEL SIGN SARA A") ; 0xD0 | 106 | (?ะ vowel-base "VOWEL SIGN SARA A") ; 0xD0 |
| 107 | (?,TQ(B vowel-upper "VOWEL SIGN MAI HAN-AKAT N/S-T") ; 0xD1 | 107 | (?ั vowel-upper "VOWEL SIGN MAI HAN-AKAT N/S-T") ; 0xD1 |
| 108 | (?,TR(B vowel-base "VOWEL SIGN SARA AA") ; 0xD2 | 108 | (?า vowel-base "VOWEL SIGN SARA AA") ; 0xD2 |
| 109 | (?,TS(B vowel-base "VOWEL SIGN SARA AM") ; 0xD3 | 109 | (?ำ vowel-base "VOWEL SIGN SARA AM") ; 0xD3 |
| 110 | (?,TT(B vowel-upper "VOWEL SIGN SARA I N/S-T") ; 0xD4 | 110 | (?ิ vowel-upper "VOWEL SIGN SARA I N/S-T") ; 0xD4 |
| 111 | (?,TU(B vowel-upper "VOWEL SIGN SARA II N/S-T") ; 0xD5 | 111 | (?ี vowel-upper "VOWEL SIGN SARA II N/S-T") ; 0xD5 |
| 112 | (?,TV(B vowel-upper "VOWEL SIGN SARA UE N/S-T") ; 0xD6 | 112 | (?ึ vowel-upper "VOWEL SIGN SARA UE N/S-T") ; 0xD6 |
| 113 | (?,TW(B vowel-upper "VOWEL SIGN SARA UEE N/S-T") ; 0xD7 | 113 | (?ื vowel-upper "VOWEL SIGN SARA UEE N/S-T") ; 0xD7 |
| 114 | (?,TX(B vowel-lower "VOWEL SIGN SARA U N/S-B") ; 0xD8 | 114 | (?ุ vowel-lower "VOWEL SIGN SARA U N/S-B") ; 0xD8 |
| 115 | (?,TY(B vowel-lower "VOWEL SIGN SARA UU N/S-B") ; 0xD9 | 115 | (?ู vowel-lower "VOWEL SIGN SARA UU N/S-B") ; 0xD9 |
| 116 | (?,TZ(B vowel-lower "VOWEL SIGN PHINTHU N/S-B (Pali virama)") ; 0xDA | 116 | (?ฺ vowel-lower "VOWEL SIGN PHINTHU N/S-B (Pali virama)") ; 0xDA |
| 117 | (?,T[(B invalid nil) ; 0xDA | 117 | (? invalid nil) ; 0xDA |
| 118 | (?,T\(B invalid nil) ; 0xDC | 118 | (? invalid nil) ; 0xDC |
| 119 | (?,T](B invalid nil) ; 0xDC | 119 | (? invalid nil) ; 0xDC |
| 120 | (?,T^(B invalid nil) ; 0xDC | 120 | (? invalid nil) ; 0xDC |
| 121 | (?,T_(B special "BAHT SIGN (currency symbol)") ; 0xDF | 121 | (?฿ special "BAHT SIGN (currency symbol)") ; 0xDF |
| 122 | (?,T`(B vowel-base "VOWEL SIGN SARA E") ; 0xE0 | 122 | (?เ vowel-base "VOWEL SIGN SARA E") ; 0xE0 |
| 123 | (?,Ta(B vowel-base "VOWEL SIGN SARA AE") ; 0xE1 | 123 | (?แ vowel-base "VOWEL SIGN SARA AE") ; 0xE1 |
| 124 | (?,Tb(B vowel-base "VOWEL SIGN SARA O") ; 0xE2 | 124 | (?โ vowel-base "VOWEL SIGN SARA O") ; 0xE2 |
| 125 | (?,Tc(B vowel-base "VOWEL SIGN SARA MAI MUAN") ; 0xE3 | 125 | (?ใ vowel-base "VOWEL SIGN SARA MAI MUAN") ; 0xE3 |
| 126 | (?,Td(B vowel-base "VOWEL SIGN SARA MAI MALAI") ; 0xE4 | 126 | (?ไ vowel-base "VOWEL SIGN SARA MAI MALAI") ; 0xE4 |
| 127 | (?,Te(B vowel-base "LAK KHANG YAO") ; 0xE5 | 127 | (?ๅ vowel-base "LAK KHANG YAO") ; 0xE5 |
| 128 | (?,Tf(B special "MAI YAMOK (repetion)") ; 0xE6 | 128 | (?ๆ special "MAI YAMOK (repetion)") ; 0xE6 |
| 129 | (?,Tg(B sign-upper "VOWEL SIGN MAI TAI KHU N/S-T") ; 0xE7 | 129 | (?็ sign-upper "VOWEL SIGN MAI TAI KHU N/S-T") ; 0xE7 |
| 130 | (?,Th(B tone "TONE MAI EK N/S-T") ; 0xE8 | 130 | (?่ tone "TONE MAI EK N/S-T") ; 0xE8 |
| 131 | (?,Ti(B tone "TONE MAI THO N/S-T") ; 0xE9 | 131 | (?้ tone "TONE MAI THO N/S-T") ; 0xE9 |
| 132 | (?,Tj(B tone "TONE MAI TRI N/S-T") ; 0xEA | 132 | (?๊ tone "TONE MAI TRI N/S-T") ; 0xEA |
| 133 | (?,Tk(B tone "TONE MAI CHATTAWA N/S-T") ; 0xEB | 133 | (?๋ tone "TONE MAI CHATTAWA N/S-T") ; 0xEB |
| 134 | (?,Tl(B sign-upper "THANTHAKHAT N/S-T (cancellation mark)") ; 0xEC | 134 | (?์ sign-upper "THANTHAKHAT N/S-T (cancellation mark)") ; 0xEC |
| 135 | (?,Tm(B sign-upper "NIKKHAHIT N/S-T (final nasal)") ; 0xED | 135 | (?ํ sign-upper "NIKKHAHIT N/S-T (final nasal)") ; 0xED |
| 136 | (?,Tn(B sign-upper "YAMAKKAN N/S-T") ; 0xEE | 136 | (?๎ sign-upper "YAMAKKAN N/S-T") ; 0xEE |
| 137 | (?,To(B special "FONRMAN") ; 0xEF | 137 | (?๏ special "FONRMAN") ; 0xEF |
| 138 | (?,Tp(B special "DIGIT ZERO") ; 0xF0 | 138 | (?๐ special "DIGIT ZERO") ; 0xF0 |
| 139 | (?,Tq(B special "DIGIT ONE") ; 0xF1 | 139 | (?๑ special "DIGIT ONE") ; 0xF1 |
| 140 | (?,Tr(B special "DIGIT TWO") ; 0xF2 | 140 | (?๒ special "DIGIT TWO") ; 0xF2 |
| 141 | (?,Ts(B special "DIGIT THREE") ; 0xF3 | 141 | (?๓ special "DIGIT THREE") ; 0xF3 |
| 142 | (?,Tt(B special "DIGIT FOUR") ; 0xF4 | 142 | (?๔ special "DIGIT FOUR") ; 0xF4 |
| 143 | (?,Tu(B special "DIGIT FIVE") ; 0xF5 | 143 | (?๕ special "DIGIT FIVE") ; 0xF5 |
| 144 | (?,Tv(B special "DIGIT SIX") ; 0xF6 | 144 | (?๖ special "DIGIT SIX") ; 0xF6 |
| 145 | (?,Tw(B special "DIGIT SEVEN") ; 0xF7 | 145 | (?๗ special "DIGIT SEVEN") ; 0xF7 |
| 146 | (?,Tx(B special "DIGIT EIGHT") ; 0xF8 | 146 | (?๘ special "DIGIT EIGHT") ; 0xF8 |
| 147 | (?,Ty(B special "DIGIT NINE") ; 0xF9 | 147 | (?๙ special "DIGIT NINE") ; 0xF9 |
| 148 | (?,Tz(B special "ANGKHANKHU (ellipsis)") ; 0xFA | 148 | (?๚ special "ANGKHANKHU (ellipsis)") ; 0xFA |
| 149 | (?,T{(B special "KHOMUT (beginning of religious texts)") ; 0xFB | 149 | (?๛ special "KHOMUT (beginning of religious texts)") ; 0xFB |
| 150 | (?,T|(B invalid nil) ; 0xFC | 150 | (? invalid nil) ; 0xFC |
| 151 | (?,T}(B invalid nil) ; 0xFD | 151 | (? invalid nil) ; 0xFD |
| 152 | (?,T~(B invalid nil) ; 0xFE | 152 | (? invalid nil) ; 0xFE |
| 153 | )) | 153 | )) |
| 154 | elm) | 154 | elm) |
| 155 | (while l | 155 | (while l |
| @@ -161,7 +161,7 @@ | |||
| 161 | (modify-category-entry char ?c thai-category-table)) | 161 | (modify-category-entry char ?c thai-category-table)) |
| 162 | ((memq ptype '(vowel-upper vowel-lower)) | 162 | ((memq ptype '(vowel-upper vowel-lower)) |
| 163 | (modify-category-entry char ?v thai-category-table) | 163 | (modify-category-entry char ?v thai-category-table) |
| 164 | (if (= char ?,TT(B) | 164 | (if (= char ?ิ) |
| 165 | ;; Give category `I' to "SARA I". | 165 | ;; Give category `I' to "SARA I". |
| 166 | (modify-category-entry char ?I thai-category-table))) | 166 | (modify-category-entry char ?I thai-category-table))) |
| 167 | ((eq ptype 'tone) | 167 | ((eq ptype 'tone) |
| @@ -169,7 +169,7 @@ | |||
| 169 | (modify-category-entry char ?u thai-category-table)) | 169 | (modify-category-entry char ?u thai-category-table)) |
| 170 | ((eq ptype 'sign-upper) | 170 | ((eq ptype 'sign-upper) |
| 171 | (modify-category-entry char ?u thai-category-table) | 171 | (modify-category-entry char ?u thai-category-table) |
| 172 | (if (= char ?,Tl(B) | 172 | (if (= char ?์) |
| 173 | ;; Give category `U' to "THANTHAKHAT". | 173 | ;; Give category `U' to "THANTHAKHAT". |
| 174 | (modify-category-entry char ?U thai-category-table)))) | 174 | (modify-category-entry char ?U thai-category-table)))) |
| 175 | (put-char-code-property char 'name (nth 2 elm))))) | 175 | (put-char-code-property char 'name (nth 2 elm))))) |
| @@ -227,20 +227,21 @@ positions (integers or markers) specifying the region." | |||
| 227 | (thai-compose-region (point-min) (point-max))) | 227 | (thai-compose-region (point-min) (point-max))) |
| 228 | 228 | ||
| 229 | ;;;###autoload | 229 | ;;;###autoload |
| 230 | (defun thai-composition-function (pos to font-object string) | 230 | (defun thai-composition-function (gstring) |
| 231 | (setq pos (1- pos)) | 231 | (if (= (lgstring-char-len gstring) 1) |
| 232 | (with-category-table thai-category-table | 232 | (compose-gstring-for-graphic gstring) |
| 233 | (if string | 233 | (or (font-shape-gstring gstring) |
| 234 | (if (and (>= pos 0) | 234 | (let ((glyph-len (lgstring-glyph-len gstring)) |
| 235 | (eq (string-match thai-composition-pattern string pos) pos)) | 235 | (last-char (lgstring-char gstring |
| 236 | (prog1 (match-end 0) | 236 | (1- (lgstring-char-len gstring)))) |
| 237 | (thai-compose-syllable pos (match-end 0) nil string))) | 237 | (i 0) |
| 238 | (if (>= pos (point-min)) | 238 | glyph) |
| 239 | (progn | 239 | (while (and (< i glyph-len) |
| 240 | (goto-char pos) | 240 | (setq glyph (lgstring-glyph gstring i))) |
| 241 | (if (looking-at thai-composition-pattern) | 241 | (setq i (1+ i))) |
| 242 | (prog1 (match-end 0) | 242 | (if (= last-char ?ำ) |
| 243 | (thai-compose-syllable pos (match-end 0))))))))) | 243 | (setq i (1- i))) |
| 244 | (compose-glyph-string-relative gstring 0 i 0.1))))) | ||
| 244 | 245 | ||
| 245 | ;; Thai-word-mode requires functions in the feature `thai-word'. | 246 | ;; Thai-word-mode requires functions in the feature `thai-word'. |
| 246 | (require 'thai-word) | 247 | (require 'thai-word) |