Commit ef90a979 authored by Kenichi Handa's avatar Kenichi Handa
Browse files

Encoding changed to utf-8.

(thai-composition-function): Argument changed.
parent 4699a15a
;;; thai-util.el --- utilities for Thai -*- coding: iso-2022-7bit; -*-
;;; thai-util.el --- utilities for Thai -*- coding: utf-8; -*-
;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
;; 2005, 2006, 2007, 2008
......@@ -49,107 +49,107 @@
;;
;; where C: consonant, V: vowel upper, v: vowel lower,
;; T: tone mark, U: tone mark and upper sign.
;; Special rule: The sign `,Tl(B' can be put on the vowel `,TT(B'.
;; Special rule: The sign `' can be put on the vowel `'.
(defvar thai-composition-pattern
"\\cc\\(\\cu\\|\\cI\\cU\\|\\cv\\ct?\\)\\|\\cv\\ct\\|\\cI\\cU"
"Regular expression matching a Thai composite sequence.")
(let ((l '((?,T!(B consonant "LETTER KO KAI") ; 0xA1
(?,T"(B consonant "LETTER KHO KHAI") ; 0xA2
(?,T#(B consonant "LETTER KHO KHUAT") ; 0xA3
(?,T$(B consonant "LETTER KHO KHWAI") ; 0xA4
(?,T%(B consonant "LETTER KHO KHON") ; 0xA5
(?,T&(B consonant "LETTER KHO RAKHANG") ; 0xA6
(?,T'(B consonant "LETTER NGO NGU") ; 0xA7
(?,T((B consonant "LETTER CHO CHAN") ; 0xA8
(?,T)(B consonant "LETTER CHO CHING") ; 0xA9
(?,T*(B consonant "LETTER CHO CHANG") ; 0xAA
(?,T+(B consonant "LETTER SO SO") ; 0xAB
(?,T,(B consonant "LETTER CHO CHOE") ; 0xAC
(?,T-(B consonant "LETTER YO YING") ; 0xAD
(?,T.(B consonant "LETTER DO CHADA") ; 0xAE
(?,T/(B consonant "LETTER TO PATAK") ; 0xAF
(?,T0(B consonant "LETTER THO THAN") ; 0xB0
(?,T1(B consonant "LETTER THO NANGMONTHO") ; 0xB1
(?,T2(B consonant "LETTER THO PHUTHAO") ; 0xB2
(?,T3(B consonant "LETTER NO NEN") ; 0xB3
(?,T4(B consonant "LETTER DO DEK") ; 0xB4
(?,T5(B consonant "LETTER TO TAO") ; 0xB5
(?,T6(B consonant "LETTER THO THUNG") ; 0xB6
(?,T7(B consonant "LETTER THO THAHAN") ; 0xB7
(?,T8(B consonant "LETTER THO THONG") ; 0xB8
(?,T9(B consonant "LETTER NO NU") ; 0xB9
(?,T:(B consonant "LETTER BO BAIMAI") ; 0xBA
(?,T;(B consonant "LETTER PO PLA") ; 0xBB
(?,T<(B consonant "LETTER PHO PHUNG") ; 0xBC
(?,T=(B consonant "LETTER FO FA") ; 0xBD
(?,T>(B consonant "LETTER PHO PHAN") ; 0xBE
(?,T?(B consonant "LETTER FO FAN") ; 0xBF
(?,T@(B consonant "LETTER PHO SAMPHAO") ; 0xC0
(?,TA(B consonant "LETTER MO MA") ; 0xC1
(?,TB(B consonant "LETTER YO YAK") ; 0xC2
(?,TC(B consonant "LETTER RO RUA") ; 0xC3
(?,TD(B vowel-base "LETTER RU (Pali vowel letter)") ; 0xC4
(?,TE(B consonant "LETTER LO LING") ; 0xC5
(?,TF(B vowel-base "LETTER LU (Pali vowel letter)") ; 0xC6
(?,TG(B consonant "LETTER WO WAEN") ; 0xC7
(?,TH(B consonant "LETTER SO SALA") ; 0xC8
(?,TI(B consonant "LETTER SO RUSI") ; 0xC9
(?,TJ(B consonant "LETTER SO SUA") ; 0xCA
(?,TK(B consonant "LETTER HO HIP") ; 0xCB
(?,TL(B consonant "LETTER LO CHULA") ; 0xCC
(?,TM(B consonant "LETTER O ANG") ; 0xCD
(?,TN(B consonant "LETTER HO NOK HUK") ; 0xCE
(?,TO(B special "PAI YAN NOI (abbreviation)") ; 0xCF
(?,TP(B vowel-base "VOWEL SIGN SARA A") ; 0xD0
(?,TQ(B vowel-upper "VOWEL SIGN MAI HAN-AKAT N/S-T") ; 0xD1
(?,TR(B vowel-base "VOWEL SIGN SARA AA") ; 0xD2
(?,TS(B vowel-base "VOWEL SIGN SARA AM") ; 0xD3
(?,TT(B vowel-upper "VOWEL SIGN SARA I N/S-T") ; 0xD4
(?,TU(B vowel-upper "VOWEL SIGN SARA II N/S-T") ; 0xD5
(?,TV(B vowel-upper "VOWEL SIGN SARA UE N/S-T") ; 0xD6
(?,TW(B vowel-upper "VOWEL SIGN SARA UEE N/S-T") ; 0xD7
(?,TX(B vowel-lower "VOWEL SIGN SARA U N/S-B") ; 0xD8
(?,TY(B vowel-lower "VOWEL SIGN SARA UU N/S-B") ; 0xD9
(?,TZ(B vowel-lower "VOWEL SIGN PHINTHU N/S-B (Pali virama)") ; 0xDA
(?,T[(B invalid nil) ; 0xDA
(?,T\(B invalid nil) ; 0xDC
(?,T](B invalid nil) ; 0xDC
(?,T^(B invalid nil) ; 0xDC
(?,T_(B special "BAHT SIGN (currency symbol)") ; 0xDF
(?,T`(B vowel-base "VOWEL SIGN SARA E") ; 0xE0
(?,Ta(B vowel-base "VOWEL SIGN SARA AE") ; 0xE1
(?,Tb(B vowel-base "VOWEL SIGN SARA O") ; 0xE2
(?,Tc(B vowel-base "VOWEL SIGN SARA MAI MUAN") ; 0xE3
(?,Td(B vowel-base "VOWEL SIGN SARA MAI MALAI") ; 0xE4
(?,Te(B vowel-base "LAK KHANG YAO") ; 0xE5
(?,Tf(B special "MAI YAMOK (repetion)") ; 0xE6
(?,Tg(B sign-upper "VOWEL SIGN MAI TAI KHU N/S-T") ; 0xE7
(?,Th(B tone "TONE MAI EK N/S-T") ; 0xE8
(?,Ti(B tone "TONE MAI THO N/S-T") ; 0xE9
(?,Tj(B tone "TONE MAI TRI N/S-T") ; 0xEA
(?,Tk(B tone "TONE MAI CHATTAWA N/S-T") ; 0xEB
(?,Tl(B sign-upper "THANTHAKHAT N/S-T (cancellation mark)") ; 0xEC
(?,Tm(B sign-upper "NIKKHAHIT N/S-T (final nasal)") ; 0xED
(?,Tn(B sign-upper "YAMAKKAN N/S-T") ; 0xEE
(?,To(B special "FONRMAN") ; 0xEF
(?,Tp(B special "DIGIT ZERO") ; 0xF0
(?,Tq(B special "DIGIT ONE") ; 0xF1
(?,Tr(B special "DIGIT TWO") ; 0xF2
(?,Ts(B special "DIGIT THREE") ; 0xF3
(?,Tt(B special "DIGIT FOUR") ; 0xF4
(?,Tu(B special "DIGIT FIVE") ; 0xF5
(?,Tv(B special "DIGIT SIX") ; 0xF6
(?,Tw(B special "DIGIT SEVEN") ; 0xF7
(?,Tx(B special "DIGIT EIGHT") ; 0xF8
(?,Ty(B special "DIGIT NINE") ; 0xF9
(?,Tz(B special "ANGKHANKHU (ellipsis)") ; 0xFA
(?,T{(B special "KHOMUT (beginning of religious texts)") ; 0xFB
(?,T|(B invalid nil) ; 0xFC
(?,T}(B invalid nil) ; 0xFD
(?,T~(B invalid nil) ; 0xFE
(let ((l '((? consonant "LETTER KO KAI") ; 0xA1
(? consonant "LETTER KHO KHAI") ; 0xA2
(? consonant "LETTER KHO KHUAT") ; 0xA3
(? consonant "LETTER KHO KHWAI") ; 0xA4
(? consonant "LETTER KHO KHON") ; 0xA5
(? consonant "LETTER KHO RAKHANG") ; 0xA6
(? consonant "LETTER NGO NGU") ; 0xA7
(? consonant "LETTER CHO CHAN") ; 0xA8
(? consonant "LETTER CHO CHING") ; 0xA9
(? consonant "LETTER CHO CHANG") ; 0xAA
(? consonant "LETTER SO SO") ; 0xAB
(? consonant "LETTER CHO CHOE") ; 0xAC
(? consonant "LETTER YO YING") ; 0xAD
(? consonant "LETTER DO CHADA") ; 0xAE
(? consonant "LETTER TO PATAK") ; 0xAF
(? consonant "LETTER THO THAN") ; 0xB0
(? consonant "LETTER THO NANGMONTHO") ; 0xB1
(? consonant "LETTER THO PHUTHAO") ; 0xB2
(? consonant "LETTER NO NEN") ; 0xB3
(? consonant "LETTER DO DEK") ; 0xB4
(? consonant "LETTER TO TAO") ; 0xB5
(? consonant "LETTER THO THUNG") ; 0xB6
(? consonant "LETTER THO THAHAN") ; 0xB7
(? consonant "LETTER THO THONG") ; 0xB8
(? consonant "LETTER NO NU") ; 0xB9
(? consonant "LETTER BO BAIMAI") ; 0xBA
(? consonant "LETTER PO PLA") ; 0xBB
(? consonant "LETTER PHO PHUNG") ; 0xBC
(? consonant "LETTER FO FA") ; 0xBD
(? consonant "LETTER PHO PHAN") ; 0xBE
(? consonant "LETTER FO FAN") ; 0xBF
(? consonant "LETTER PHO SAMPHAO") ; 0xC0
(? consonant "LETTER MO MA") ; 0xC1
(? consonant "LETTER YO YAK") ; 0xC2
(? consonant "LETTER RO RUA") ; 0xC3
(? vowel-base "LETTER RU (Pali vowel letter)") ; 0xC4
(? consonant "LETTER LO LING") ; 0xC5
(? vowel-base "LETTER LU (Pali vowel letter)") ; 0xC6
(? consonant "LETTER WO WAEN") ; 0xC7
(? consonant "LETTER SO SALA") ; 0xC8
(? consonant "LETTER SO RUSI") ; 0xC9
(? consonant "LETTER SO SUA") ; 0xCA
(? consonant "LETTER HO HIP") ; 0xCB
(? consonant "LETTER LO CHULA") ; 0xCC
(? consonant "LETTER O ANG") ; 0xCD
(? consonant "LETTER HO NOK HUK") ; 0xCE
(? special "PAI YAN NOI (abbreviation)") ; 0xCF
(? vowel-base "VOWEL SIGN SARA A") ; 0xD0
(? vowel-upper "VOWEL SIGN MAI HAN-AKAT N/S-T") ; 0xD1
(? vowel-base "VOWEL SIGN SARA AA") ; 0xD2
(? vowel-base "VOWEL SIGN SARA AM") ; 0xD3
(? vowel-upper "VOWEL SIGN SARA I N/S-T") ; 0xD4
(? vowel-upper "VOWEL SIGN SARA II N/S-T") ; 0xD5
(? vowel-upper "VOWEL SIGN SARA UE N/S-T") ; 0xD6
(? vowel-upper "VOWEL SIGN SARA UEE N/S-T") ; 0xD7
(? vowel-lower "VOWEL SIGN SARA U N/S-B") ; 0xD8
(? vowel-lower "VOWEL SIGN SARA UU N/S-B") ; 0xD9
(? vowel-lower "VOWEL SIGN PHINTHU N/S-B (Pali virama)") ; 0xDA
(? invalid nil) ; 0xDA
(? invalid nil) ; 0xDC
(? invalid nil) ; 0xDC
(? invalid nil) ; 0xDC
(?฿ special "BAHT SIGN (currency symbol)") ; 0xDF
(? vowel-base "VOWEL SIGN SARA E") ; 0xE0
(? vowel-base "VOWEL SIGN SARA AE") ; 0xE1
(? vowel-base "VOWEL SIGN SARA O") ; 0xE2
(? vowel-base "VOWEL SIGN SARA MAI MUAN") ; 0xE3
(? vowel-base "VOWEL SIGN SARA MAI MALAI") ; 0xE4
(? vowel-base "LAK KHANG YAO") ; 0xE5
(? special "MAI YAMOK (repetion)") ; 0xE6
(? sign-upper "VOWEL SIGN MAI TAI KHU N/S-T") ; 0xE7
(? tone "TONE MAI EK N/S-T") ; 0xE8
(? tone "TONE MAI THO N/S-T") ; 0xE9
(? tone "TONE MAI TRI N/S-T") ; 0xEA
(? tone "TONE MAI CHATTAWA N/S-T") ; 0xEB
(? sign-upper "THANTHAKHAT N/S-T (cancellation mark)") ; 0xEC
(? sign-upper "NIKKHAHIT N/S-T (final nasal)") ; 0xED
(? sign-upper "YAMAKKAN N/S-T") ; 0xEE
(? special "FONRMAN") ; 0xEF
(? special "DIGIT ZERO") ; 0xF0
(? special "DIGIT ONE") ; 0xF1
(? special "DIGIT TWO") ; 0xF2
(? special "DIGIT THREE") ; 0xF3
(? special "DIGIT FOUR") ; 0xF4
(? special "DIGIT FIVE") ; 0xF5
(? special "DIGIT SIX") ; 0xF6
(? special "DIGIT SEVEN") ; 0xF7
(? special "DIGIT EIGHT") ; 0xF8
(? special "DIGIT NINE") ; 0xF9
(? special "ANGKHANKHU (ellipsis)") ; 0xFA
(? special "KHOMUT (beginning of religious texts)") ; 0xFB
(? invalid nil) ; 0xFC
(? invalid nil) ; 0xFD
(? invalid nil) ; 0xFE
))
elm)
(while l
......@@ -161,7 +161,7 @@
(modify-category-entry char ?c thai-category-table))
((memq ptype '(vowel-upper vowel-lower))
(modify-category-entry char ?v thai-category-table)
(if (= char ?,TT(B)
(if (= char ?)
;; Give category `I' to "SARA I".
(modify-category-entry char ?I thai-category-table)))
((eq ptype 'tone)
......@@ -169,7 +169,7 @@
(modify-category-entry char ?u thai-category-table))
((eq ptype 'sign-upper)
(modify-category-entry char ?u thai-category-table)
(if (= char ?,Tl(B)
(if (= char ?)
;; Give category `U' to "THANTHAKHAT".
(modify-category-entry char ?U thai-category-table))))
(put-char-code-property char 'name (nth 2 elm)))))
......@@ -227,20 +227,21 @@ positions (integers or markers) specifying the region."
(thai-compose-region (point-min) (point-max)))
;;;###autoload
(defun thai-composition-function (pos to font-object string)
(setq pos (1- pos))
(with-category-table thai-category-table
(if string
(if (and (>= pos 0)
(eq (string-match thai-composition-pattern string pos) pos))
(prog1 (match-end 0)
(thai-compose-syllable pos (match-end 0) nil string)))
(if (>= pos (point-min))
(progn
(goto-char pos)
(if (looking-at thai-composition-pattern)
(prog1 (match-end 0)
(thai-compose-syllable pos (match-end 0)))))))))
(defun thai-composition-function (gstring)
(if (= (lgstring-char-len gstring) 1)
(compose-gstring-for-graphic gstring)
(or (font-shape-gstring gstring)
(let ((glyph-len (lgstring-glyph-len gstring))
(last-char (lgstring-char gstring
(1- (lgstring-char-len gstring))))
(i 0)
glyph)
(while (and (< i glyph-len)
(setq glyph (lgstring-glyph gstring i)))
(setq i (1+ i)))
(if (= last-char ?)
(setq i (1- i)))
(compose-glyph-string-relative gstring 0 i 0.1)))))
;; Thai-word-mode requires functions in the feature `thai-word'.
(require 'thai-word)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment