Update copyright year to 2014 by running admin/update-copyright.
[bpt/emacs.git] / lisp / language / tibetan.el
... / ...
CommitLineData
1;;; tibetan.el --- support for Tibetan language -*- coding: utf-8-emacs; -*-
2
3;; Copyright (C) 1997, 2001-2014 Free Software Foundation, Inc.
4;; Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
5;; 2006, 2007, 2008, 2009, 2010, 2011
6;; National Institute of Advanced Industrial Science and Technology (AIST)
7;; Registration Number H14PRO021
8;; Copyright (C) 2003
9;; National Institute of Advanced Industrial Science and Technology (AIST)
10;; Registration Number H13PRO009
11
12;; Author: Toru TOMABECHI <Toru.Tomabechi@orient.unil.ch>
13;; Created: Feb. 17. 1997
14;; Keywords: multilingual, Tibetan, i18n
15
16;; This file is part of GNU Emacs.
17
18;; GNU Emacs is free software: you can redistribute it and/or modify
19;; it under the terms of the GNU General Public License as published by
20;; the Free Software Foundation, either version 3 of the License, or
21;; (at your option) any later version.
22
23;; GNU Emacs is distributed in the hope that it will be useful,
24;; but WITHOUT ANY WARRANTY; without even the implied warranty of
25;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26;; GNU General Public License for more details.
27
28;; You should have received a copy of the GNU General Public License
29;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
30
31;;; History:
32
33;; 1997.03.13 Modification for special signs and punctuation.
34
35;;; Commentary:
36
37;;; Code:
38
39;;; Tibetan Character set.
40;;; \x2130 -- \x234a is a subset of Unicode v.2 \x0f00 - \x0fb9
41;;; with a slight modification. And there are some subjoined
42;;; consonants which are not specified in Unicode.
43;;; I hope I can add missing characters later.
44;;;
45;;; 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
46;;;2120 // ; obsolete glyphs (2123-5)
47;;;2130 ༀ ༁ ༂ ༃ ༄ ༅ ༆ ༇ ༈ ༉ ༊ ་ ༌ ། ༎ ༏ ; Punctuation,
48;;;2140 ༐ ༑ ༒ ༓ ༔ ༕ ༖ ༗ ༘ ༙ ༚ ༛ ༜ ༝ ༞ ༟ ; Digits and
49;;;2150 ༠ ༡ ༢ ༣ ༤ ༥ ༦ ༧ ༨ ༩ ༪ ༫ ༬ ༭ ༮ ༯ ; Special signs.
50;;;2160 ༰ ༱ ༲ ༳ ༴ ༵ ༶ ༷ ༸ ༹ ༺ ༻ ༼ ༽ ༾ ༿ ;
51;;;2170 // ;
52;;;
53;;; 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
54;;;2220 // ཀ ཁ ག གྷ ང ཅ ཆ ཇ ཉ ཊ ཋ ཌ ཌྷ ཎ ; Base consonants
55;;;2230 ཏ ཐ ད དྷ ན པ ཕ བ བྷ མ ཙ ཚ ཛ ཛྷ ཝ ཞ ; and
56;;;2240 ཟ འ ཡ ར ལ ཤ ཥ ས ཧ ཨ ཀྵ ཪ ; Vowel signs.
57;;;2250 ཱ ི ཱི ུ ཱུ ྲྀ ཷ ླྀ ཹ ེ ཻ ོ ཽ ཾ ; (\x2251 = vowel a)
58;;;2260 ཿ ྀ ཱྀ ྂ ྃ ྄ ྅ ྆ ྇ ྈ ྉ ྊ ྋ ; Long vowels and
59;;;2270 // ; vocalic r, l ARE
60;;; ; atomically
61;;; ; encoded.
62;;; 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
63;;;2320 // ྐ ྑ ྒ ྒྷ ྔ ྕ ྖ ྗ ྙ ྚ ྛ ྜ ྜྷ ྞ ; Subjoined consonants
64;;;2330 ྟ ྠ ྡ ྡྷ ྣ ྤ ྥ ྦ ྦྷ ྨ ྩ ྪ ྫ ྫྷ ྭ ྮ ;
65;;;2340 ྯ ྰ ྱ ྲ ླ ྴ ྵ ྶ ྷ ྸ ྐྵ ྺ ྻ ྼ ྾ ;
66;;;2350 ྿ ࿀ ࿁ ࿂ ࿃ ࿄ ࿅ ࿆ ࿇ ࿈ ࿉ ࿊ ࿋ ࿌ ; Hereafter, the chars
67;;;2360 ࿏ ; are not specified
68;;;2370 // ; in Unicode.
69;;;
70;;; 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
71;;;2420 // ; Precomposed
72;;;2430 ; consonants for
73;;;2440 ; ordinary Tibetan.
74;;;2450 ; They are decomposed
75;;;2460 ; into base and
76;;;2470 // ; subjoined consonants
77;;; ; when written on a
78;;; 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F ; file in Tibetan
79;;;2520 // ; coding system.
80;;;2530 ;
81;;;2540 ;
82;;;2550 ;
83;;;2560 ;
84;;;2570 // ;
85;;;
86
87
88(define-coding-system 'tibetan-iso-8bit
89 "8-bit encoding for ASCII (MSB=0) and TIBETAN (MSB=1)."
90 :coding-type 'iso-2022
91 :mnemonic ?Q
92 :designation [ascii tibetan nil nil]
93 :charset-list '(ascii tibetan))
94
95(define-coding-system-alias 'tibetan 'tibetan-iso-8bit)
96
97(set-language-info-alist
98 "Tibetan" '((charset tibetan tibetan-1-column)
99 (coding-system tibetan-iso-8bit)
100 (coding-priority iso-2022-7bit tibetan-iso-8bit)
101 (input-method . "tibetan-wylie")
102 (features tibet-util)
103 (documentation . t)
104 (sample-text . "Tibetan (བོད་སྐད་) ༄༅༅༎བཀྲ་ཤིས་བདེ་ལེགས༎ཨོཾ་མ་ཎི་པདྨེ་ཧའུྂ༎")))
105
106;; `འ' is included in the pattern for subjoined consonants because we
107;; treat it specially in tibetan-add-components.
108;; modified by Tomabechi 1999/12/10
109;; modified by Tomabechi 2000/06/08
110;; To allow infinite addition of vowels/modifiers
111;; as specified in Unicode v.3
112;; འ is removed from the class of subjoined. Tomabechi 2000/06/08
113;; (for Unicode support)
114(defconst tibetan-composable-pattern
115 "[ཀ-ཀྵཪ][ྐ-ྐྵྺྻྼ]*[཰ཱི-྄ཱཽྀྀ]*[ཾྂྃ྆-ྋ༙༵༷]*"
116 "Regexp matching a composable sequence of Tibetan characters.")
117
118;;;
119;;; Definitions of conversion data.
120;;;
121
122
123;;; alists for tibetan char <-> transcription conversion
124;;; longer transcription should come first
125(defconst tibetan-consonant-transcription-alist
126 '(("tsh" . "ཚ")
127 ("dzh" . "ཛྷ")
128 ("kSH" . "ཀྵ")
129 ("kh" . "ཁ")
130 ("gh" . "གྷ")
131 ("ng" . "ང")
132 ("ch" . "ཆ")
133 ("ny" . "ཉ")
134 ("TH" . "ཋ")
135 ("DH" . "ཌྷ")
136 ("th" . "ཐ")
137 ("dh" . "དྷ")
138 ("ph" . "ཕ")
139 ("bh" . "བྷ")
140 ("ts" . "ཙ")
141 ("dz" . "ཛ")
142 ("zh" . "ཞ")
143 ("sh" . "ཤ")
144 ("SH" . "ཥ")
145 ("k" . "ཀ")
146 ("g" . "ག")
147 ("c" . "ཅ")
148 ("j" . "ཇ")
149 ("T" . "ཊ")
150 ("D" . "ཌ")
151 ("N" . "ཎ")
152 ("t" . "ཏ")
153 ("d" . "ད")
154 ("n" . "ན")
155 ("p" . "པ")
156 ("b" . "བ")
157 ("m" . "མ")
158 ("w" . "ཝ")
159 ("z" . "ཟ")
160 ("'" . "འ")
161 ("y" . "ཡ")
162 ("r" . "ར")
163 ("l" . "ལ")
164 ("s" . "ས")
165 ("h" . "ཧ")
166 ("H" . "ཧ")
167 ("A" . "ཨ")
168 ;; Added by Tomabechi 1999/12/10
169 ("R" . "ཪ") ;; fixed form RA
170 ))
171
172
173(defconst tibetan-vowel-transcription-alist
174 '(
175 ;; Composite Vowels
176 ;; Added by Tomabechi 2000/06/08
177 ("frr" . "ཷ")
178 ("fll" . "ཹ")
179 ("fa" . "ཱ")
180 ("fi" . "ཱི")
181 ("fu" . "ཱུ")
182 ("fr" . "ྲྀ")
183 ("fl" . "ླྀ")
184 ("fI" . "ཱྀ")
185 ;; Normal Vowels
186 ("ai" . "ཻ")
187 ("au" . "ཽ")
188 ("ee" . "ཻ")
189 ("oo" . "ཽ")
190 ("a" . "") ; invisible vowel sign (\x2251)
191 ("i" . "ི")
192 ("u" . "ུ")
193 ("e" . "ེ")
194 ("o" . "ོ")
195 ("E" . "ཻ")
196 ("O" . "ཽ")
197 ("I" . "ྀ")
198 ("," . "྄") ; idem.
199 ))
200
201(defconst tibetan-modifier-transcription-alist
202 '(("M" . "ཾ")
203 ("~" . "ྂ")
204 ("`" . "ྃ")
205 ("x" . "ྈ")
206 ("X" . "ྉ")
207 ("v" . "྆")
208 ("V" . "྇")
209 ("q" . "ྊ")
210 ("Q" . "ྋ")
211 ("_/" . "༙")
212 ("_o" . "༷")
213 ("_O" . "༵")))
214
215(defconst tibetan-precomposed-transcription-alist
216 '(("phyw" . "")
217 ("tshw" . "")
218 ("rtsw" . "")
219 ("khw" . "")
220 ("nyw" . "")
221 ("tsw" . "")
222 ("zhw" . "")
223 ("shw" . "")
224 ("khy" . "")
225 ("phy" . "")
226 ("khr" . "")
227 ("thr" . "")
228 ("phr" . "")
229 ("shr" . "")
230 ("dzr" . "")
231 ("grw" . "")
232 ("rng" . "")
233 ("rny" . "")
234 ("rts" . "")
235 ("rdz" . "")
236 ("rgw" . "")
237 ("rky" . "")
238 ("rgy" . "")
239 ("rmy" . "")
240 ("lng" . "")
241 ("sng" . "")
242 ("sny" . "")
243 ("sts" . "")
244 ("sky" . "")
245 ("sgy" . "")
246 ("spy" . "")
247 ("sby" . "")
248 ("smy" . "")
249 ("skr" . "")
250 ("sgr" . "")
251 ("snr" . "")
252 ("spr" . "")
253 ("sbr" . "")
254 ("smr" . "")
255 ("kw" . "")
256 ("gw" . "")
257 ("cw" . "")
258 ("tw" . "")
259 ("dw" . "")
260 ("zw" . "")
261 ("rw" . "")
262 ("lw" . "")
263 ("sw" . "")
264 ("hw" . "")
265 ("ky" . "")
266 ("gy" . "")
267 ("py" . "")
268 ("by" . "")
269 ("my" . "")
270 ("kr" . "")
271 ("gr" . "")
272 ("tr" . "")
273 ("dr" . "")
274 ("pr" . "")
275 ("brk" . "བ")
276 ("brg" . "བ")
277 ("brng" . "བ")
278 ("brj" . "བ")
279 ("brny" . "བ")
280 ("brt" . "བ")
281 ("brd" . "བ")
282 ("brn" . "བ")
283 ("brts" . "བ")
284 ("brdz" . "བ")
285 ("brl" . "བ")
286 ("br" . "")
287 ("mr" . "")
288 ("sr" . "")
289 ("hr" . "")
290 ("jr" . "")
291 ("kl" . "")
292 ("gl" . "")
293 ("blt" . "བ")
294 ("bld" . "བ")
295 ("bl" . "")
296 ("zl" . "")
297 ("rl" . "")
298 ("sl" . "")
299 ("rk" . "")
300 ("rg" . "")
301 ("rj" . "")
302 ("rt" . "")
303 ("rd" . "")
304 ("rn" . "")
305 ("rb" . "")
306 ("rm" . "")
307 ("lk" . "")
308 ("lg" . "")
309 ("lc" . "")
310 ("lj" . "")
311 ("lt" . "")
312 ("ld" . "")
313 ("ln" . "") ; dummy \x2121
314 ("lp" . "")
315 ("lb" . "")
316 ("lh" . "")
317 ("sk" . "")
318 ("sg" . "")
319 ("st" . "")
320 ("sd" . "")
321 ("sn" . "")
322 ("sp" . "")
323 ("sb" . "")
324 ("sm" . ""))
325 )
326
327
328(defconst tibetan-subjoined-transcription-alist
329 (sort '(("+k" . "ྐ")
330 ("+kh" . "ྑ")
331 ("+g" . "ྒ")
332 ("+gh" . "ྒྷ")
333 ("+ng" . "ྔ")
334 ("+c" . "ྕ")
335 ("+ch" . "ྖ")
336 ("+j" . "ྗ")
337 ("+ny" . "ྙ")
338 ("+T" . "ྚ")
339 ("+TH" . "ྛ")
340 ("+D" . "ྜ")
341 ("+DH" . "ྜྷ")
342 ("+N" . "ྞ")
343 ("+t" . "ྟ")
344 ("+th" . "ྠ")
345 ("+d" . "ྡ")
346 ("+dh" . "ྡྷ")
347 ("+n" . "ྣ")
348 ("+p" . "ྤ")
349 ("+ph" . "ྥ")
350 ("+b" . "ྦ")
351 ("+bh" . "ྦྷ")
352 ("+m" . "ྨ")
353 ("+ts" . "ྩ")
354 ("+tsh" . "ྪ")
355 ("+dz" . "ྫ")
356 ("+dzh" . "ྫྷ")
357 ("+w" . "ྭ")
358 ("+zh" . "ྮ")
359 ("+z" . "ྯ")
360 ("+'" . "ྰ")
361 ("+y" . "ྱ")
362 ("+r" . "ྲ")
363 ("+l" . "ླ")
364 ("+sh" . "ྴ")
365 ("+SH" . "ྵ")
366 ("+s" . "ྶ")
367 ("+h" . "ྷ")
368 ("+A" . "ྸ")
369 ("+kSH" . "ྐྵ")
370 ;; Added by Tomabechi 1999/12/10
371 ("+W" . "ྺ") ;; fixed form subscribed WA
372 ("+Y" . "ྻ") ;; fixed form subscribed YA
373 ("+R" . "ྼ") ;; fixed form subscribed RA
374 )
375 (lambda (x y) (> (length (car x)) (length (car y))))))
376
377;;;
378;;; alist for Tibetan base consonant <-> subjoined consonant conversion.
379;;;
380(defconst tibetan-base-to-subjoined-alist
381 '(("ཀ" . "ྐ")
382 ("ཁ" . "ྑ")
383 ("ག" . "ྒ")
384 ("གྷ" . "ྒྷ")
385 ("ང" . "ྔ")
386 ("ཅ" . "ྕ")
387 ("ཆ" . "ྖ")
388 ("ཇ" . "ྗ")
389 ("ཉ" . "ྙ")
390 ("ཊ" . "ྚ")
391 ("ཋ" . "ྛ")
392 ("ཌ" . "ྜ")
393 ("ཌྷ" . "ྜྷ")
394 ("ཎ" . "ྞ")
395 ("ཏ" . "ྟ")
396 ("ཐ" . "ྠ")
397 ("ད" . "ྡ")
398 ("དྷ" . "ྡྷ")
399 ("ན" . "ྣ")
400 ("པ" . "ྤ")
401 ("ཕ" . "ྥ")
402 ("བ" . "ྦ")
403 ("བྷ" . "ྦྷ")
404 ("མ" . "ྨ")
405 ("ཙ" . "ྩ")
406 ("ཚ" . "ྪ")
407 ("ཛ" . "ྫ")
408 ("ཛྷ" . "ྫྷ")
409 ("ཝ" . "ྭ")
410 ("ཞ" . "ྮ")
411 ("ཟ" . "ྯ")
412 ("འ" . "ྰ")
413 ("ཡ" . "ྱ")
414 ("ར" . "ྲ")
415 ("ལ" . "ླ")
416 ("ཤ" . "ྴ")
417 ("ཥ" . "ྵ")
418 ("ས" . "ྶ")
419 ("ཧ" . "ྷ")
420 ("ཨ" . "ྸ")
421 ("ཀྵ" . "ྐྵ")
422 ;; Added by Tomabechi 1999/12/10
423 ("ཪ" . "ྼ") ;; Fixed form RA (224B->234D)
424 ))
425
426;;; alist for Tibetan composite vowels (long i, vocalic r, etc.)
427;;; New variable. created by Tomabechi 2000/06/08
428(defconst tibetan-composite-vowel-alist
429 '(;; LONG A
430 ;; ("ཱ" . ((bc . tc) ?ཱ))
431 ;; LONG I
432 ("ཱི" . (?ཱ (tc . bc) ?ི))
433 ;; LONG U
434 ("ཱུ" . (?ཱ (bc . tc) ?ུ))
435 ;; VOCALIC R
436 ("ྲྀ" . (?ྲ (tc . bc) ?ྀ))
437 ;; LONG VOCALIC R
438 ("ཷ" . (?ྲ (bc . tc) ?ཱ (tc . bc) ?ྀ))
439 ;; VOCALIC L
440 ("ླྀ" . (?ླ (tc . bc) ?ྀ))
441 ;;་LONG VOCALIC L
442 ("ཹ" . (?ླ (bc . tc) ?ཱ (tc . bc) ?ྀ))
443 ;; LONG REVERSE I
444 ("ཱྀ" . (?ཱ (tc . bc) ?ྀ))
445 ))
446
447
448
449;;;
450;;; alist for Tibetan consonantic components <-> precomposed glyph conversion.
451;;; (includes some punctuation conversion rules)
452;;;
453(defconst tibetan-precomposition-rule-alist
454 `(("ཕྱྭ" . "")
455 ("གྲྭ" . "")
456 ("ཚྭ" . "")
457 ("རྩྭ" . "")
458 ("རྒྭ" . "")
459 ("རྐྱ" . "")
460 ("རྒྱ" . "")
461 ("རྨྱ" . "")
462 ("སྐྱ" . "")
463 ("སྒྱ" . "")
464 ("སྤྱ" . "")
465 ("སྦྱ" . "")
466 ("སྨྱ" . "")
467 ("སྐྲ" . "")
468 ("སྒྲ" . "")
469 ("སྣྲ" . "")
470 ("སྤྲ" . "")
471 ("སྦྲ" . "")
472 ("སྨྲ" . "")
473 ("ཁྭ" . "")
474 ("ཉྭ" . "")
475 ("ཙྭ" . "")
476 ("ཞྭ" . "")
477 ("ཤྭ" . "")
478 ("ཁྱ" . "")
479 ("ཕྱ" . "")
480 ("ཁྲ" . "")
481 ("ཐྲ" . "")
482 ("ཕྲ" . "")
483 ("ཤྲ" . "")
484 ("ཛྲ" . "")
485 ("རྔ" . "")
486 ("རྙ" . "")
487 ("རྩ" . "")
488 ("རྫ" . "")
489 ("ལྔ" . "")
490 ("སྔ" . "")
491 ("སྙ" . "")
492 ("སྩ" . "")
493 ("ཀྭ" . "")
494 ("གྭ" . "")
495 ("ཅྭ" . "")
496 ("ཏྭ" . "")
497 ("དྭ" . "")
498 ("ཟྭ" . "")
499 ("རྭ" . "")
500 ("ལྭ" . "")
501 ("སྭ" . "")
502 ("ཧྭ" . "")
503 ("ཀྱ" . "")
504 ("གྱ" . "")
505 ("པྱ" . "")
506 ("བྱ" . "")
507 ("མྱ" . "")
508 ("ཀྲ" . "")
509 ("གྲ" . "")
510 ("ཏྲ" . "")
511 ("དྲ" . "")
512 ("པྲ" . "")
513 ("བྲ" . "")
514 ("མྲ" . "")
515 ("སྲ" . "")
516 ("ཧྲ" . "")
517 ("ཇྲ" . "")
518 ("ཀླ" . "")
519 ("གླ" . "")
520 ("བླ" . "")
521 ("ཟླ" . "")
522 ("རླ" . "")
523 ("སླ" . "")
524 ("རྐ" . "")
525 ("རྒ" . "")
526 ("རྗ" . "")
527 ("རྟ" . "")
528 ("རྡ" . "")
529 ("རྣ" . "")
530 ("རྦ" . "")
531 ("རྨ" . "")
532 ("ལྐ" . "")
533 ("ལྒ" . "")
534 ("ལྣ" . "") ; dummy 0x2121 added 2000/06/08 for transition l -> lng
535 ("ལྕ" . "")
536 ("ལྗ" . "")
537 ("ལྟ" . "")
538 ("ལྡ" . "")
539 ("ལྤ" . "")
540 ("ལྦ" . "")
541 ("ལྷ" . "")
542 ("སྐ" . "")
543 ("སྒ" . "")
544 ("སྟ" . "")
545 ("སྡ" . "")
546 ("སྣ" . "")
547 ("སྤ" . "")
548 ("སྦ" . "")
549 ("སྨ" . "")))
550
551(defconst tibetan-regexp
552 (let ((l (list tibetan-precomposed-transcription-alist
553 tibetan-consonant-transcription-alist
554 tibetan-vowel-transcription-alist
555 tibetan-modifier-transcription-alist
556 tibetan-subjoined-transcription-alist))
557 (separator "\\|")
558 tail pattern)
559 (while l
560 (setq tail (car l) l (cdr l))
561 (while tail
562 (setq pattern (cons separator (cons (car (car tail)) pattern))
563 tail (cdr tail))))
564 (apply 'concat (nreverse (cdr pattern))))
565 "Regexp matching a Tibetan transcription of a composable Tibetan sequence.
566The result of matching is to be used for indexing alists at conversion
567from a roman transcription to the corresponding Tibetan character.")
568
569(defvar tibetan-precomposed-regexp
570 (purecopy
571 (let ((l tibetan-precomposed-transcription-alist)
572 temp)
573 (setq temp "^\\(")
574 (setq temp
575 (concat temp (car (car l))))
576 (setq l (cdr l))
577 (while l
578 (setq temp
579 (concat temp "\\|" (car (car l))))
580 (setq l (cdr l)))
581 (concat temp "\\)")))
582 "Regexp string to match a romanized Tibetan complex consonant.
583The result of matching is to be used for indexing alists when the input key
584from an input method is converted to the corresponding precomposed glyph.")
585
586(defvar tibetan-precomposition-rule-regexp
587 (purecopy
588 (let ((l tibetan-precomposition-rule-alist)
589 temp)
590 (setq temp "\\(")
591 (setq temp (concat temp (car (car l))))
592 (setq l (cdr l))
593 (while l
594 (setq temp (concat temp "\\|" (car (car l))))
595 (setq l (cdr l)))
596 (concat temp "\\)")))
597 "Regexp string to match a sequence of Tibetan consonantic components, i.e.,
598one base consonant and one or more subjoined consonants.
599The result of matching is to be used for indexing alist when the component
600sequence is converted to the corresponding precomposed glyph.
601This also matches some punctuation characters which need conversion.")
602
603(defvar tibetan-decomposed nil)
604(defvar tibetan-decomposed-temp nil)
605
606;; For automatic composition.
607(set-char-table-range
608 composition-function-table '(#xF00 . #xFD1)
609 (list (vector tibetan-composable-pattern 0 'font-shape-gstring)))
610
611(provide 'tibetan)
612
613;;; tibetan.el ends here