aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2007-06-16 01:58:08 +0000
committerKenichi Handa2007-06-16 01:58:08 +0000
commitee4f828424c4eeb6d421fec41ab3d34a66c719b1 (patch)
treef45ed5e433fe71a77f76ba04295947931b8f08e1
parentb878f5f15ab1c6074c6f839c08700185e6eb300b (diff)
downloademacs-ee4f828424c4eeb6d421fec41ab3d34a66c719b1.tar.gz
emacs-ee4f828424c4eeb6d421fec41ab3d34a66c719b1.zip
New file.
-rw-r--r--lisp/language/tai-viet.el66
-rw-r--r--lisp/language/tv-util.el145
2 files changed, 211 insertions, 0 deletions
diff --git a/lisp/language/tai-viet.el b/lisp/language/tai-viet.el
new file mode 100644
index 00000000000..a262d5738ec
--- /dev/null
+++ b/lisp/language/tai-viet.el
@@ -0,0 +1,66 @@
1;;; tai-viet.el --- support for Tai Viet -*- coding: utf-8; no-byte-compile: t -*-
2
3;; Copyright (C) 2007
4;; National Institute of Advanced Industrial Science and Technology (AIST)
5;; Registration Number H13PRO009
6;; Copyright (C) 2007 Free Software Foundation, Inc.
7
8;; Keywords: multilingual, Tai Viet, i18n
9
10;; This file is part of GNU Emacs.
11
12;; GNU Emacs is free software; you can redistribute it and/or modify
13;; it under the terms of the GNU General Public License as published by
14;; the Free Software Foundation; either version 2, or (at your option)
15;; any later version.
16
17;; GNU Emacs is distributed in the hope that it will be useful,
18;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20;; GNU General Public License for more details.
21
22;; You should have received a copy of the GNU General Public License
23;; along with GNU Emacs; see the file COPYING. If not, write to the
24;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
25;; Boston, MA 02110-1301, USA.
26
27;;; Commentary:
28
29;; Tai Viet is being included in the Unicode at the range U+AA80..U+AADF.
30
31;;; Code:
32
33(set-char-table-range composition-function-table
34 '(#xAA80 . #xAADF)
35 'tai-viet-composition-function)
36
37(set-language-info-alist
38 "TaiViet" '((charset unicode)
39 (coding-system utf-8)
40 (coding-priority utf-8)
41 (input-method . "tai-sonla")
42 (sample-text
43 "TaiViet (ꪁꪫꪱꪣ ꪽꪕ)\t\tꪅꪰꪙ꫃ ꪨꪮ꫃ ꪁꪫꪱ / ꪅꪾ ꪨ� ꪁꪫꪱ")
44 (documentation . "\
45TaiViet refers to the Tai language used by Tai people in
46Vietnam, and also refers to the script used for this language.
47Both the script and language have the same origin as that of Thai
48language/script used in Thailand, but now they differ from each
49other in a significant way (especially the scripts are).
50
51The language name is spelled as \"ꪁꪫꪱꪣ ꪽꪕ\", and the script name is
52spelled as \"ꪎ� ꪽꪕ\" in the modern form, \"ꪎꪴ ꪽꪕ\" in the traditional
53from.
54
55As the proposal for TaiViet script to the Unicode is still on
56the progress, we use the Private Use Area for TaiViet
57characters (U+F000..U+F07E). A TaiViet font encoded accordingly
58is available at this web page:
59 http://www.m17n.org/TaiViet/
60")))
61
62(provide 'tai-viet)
63
64;; Local Variables:
65;; coding: utf-8
66;; End:
diff --git a/lisp/language/tv-util.el b/lisp/language/tv-util.el
new file mode 100644
index 00000000000..9407379e098
--- /dev/null
+++ b/lisp/language/tv-util.el
@@ -0,0 +1,145 @@
1;;; tv-util.el --- support for Tai Viet -*- coding: utf-8 -*-
2
3;; Copyright (C) 2007
4;; National Institute of Advanced Industrial Science and Technology (AIST)
5;; Registration Number H13PRO009
6
7;; Keywords: multilingual, Tai Viet, i18n
8
9;; This file is part of GNU Emacs.
10
11;; GNU Emacs is free software; you can redistribute it and/or modify
12;; it under the terms of the GNU General Public License as published by
13;; the Free Software Foundation; either version 2, or (at your option)
14;; any later version.
15
16;; GNU Emacs is distributed in the hope that it will be useful,
17;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19;; GNU General Public License for more details.
20
21;; You should have received a copy of the GNU General Public License
22;; along with GNU Emacs; see the file COPYING. If not, write to the
23;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24;; Boston, MA 02110-1301, USA.
25
26;;; Code
27
28;; Regexp matching with a sequence of Tai Viet characters.
29(defconst tai-viet-re
30 (format "[\xaa80-\xaac2\xaadb-\xaadf]+"))
31
32;; Char-table of information about glyph type of Tai Viet characters.
33(defconst tai-viet-glyph-info
34 (let ((table (make-char-table nil))
35 (specials '((right-overhang . "ꪊꪋꪌꪍꪏꪓꪖꪜꪞꪡꪤꪨ")
36 (left-overhang . "ꫂ")
37 (combining-vowel . "ꪴꪰꪲꪳꪷꪸꪾ")
38 (combining-tone . "꪿꫁"))))
39 ;; Set all TaiViet characters to `t'.
40 (set-char-table-range table (cons #xaa80 #xaac2) t)
41 (set-char-table-range table (cons #xaadb #xaadf) t)
42 ;; Overwrite it for special characters.
43 (dolist (elt specials)
44 (let ((category (car elt))
45 (chars (cdr elt)))
46 (dotimes (i (length chars))
47 (aset table (aref chars i) category))))
48 table))
49
50(defun tai-viet-compose-string (from to string)
51 "Compose Tai Viet characters in STRING between indices FROM and TO."
52 (let* ((ch (aref string from))
53 (info (aref tai-viet-glyph-info ch))
54 prev-info)
55 (if (eq info 'non-spacing)
56 (compose-string string from (1+ from) (string ch ?\t)))
57 (setq from (1+ from) prev-info info)
58 (while (and (< from to)
59 (tai-viet-char-p (setq ch (aref string from))))
60 (setq info (aref tai-viet-glyph-info ch))
61 (if (and (eq info 'non-spacing)
62 (eq prev-info 'non-spacing))
63 (compose-string from (1+ from) (string ?\t ch)))
64 (setq from (1+ from) prev-info info))
65 (if (eq info 'right-overhang)
66 (compose-string string (1- from) from (string ch ?\t)))
67 from))
68
69(defun tai-viet-compose-region (from to)
70 "Compose Tai Viet characters in the region between FROM and TO."
71 (decompose-region from to)
72 (let ((normal-rule '(Br . Bl))
73 (tone-rule '(tr . bl))
74 (prev-viet nil)
75 ch info pos components overhang)
76 (while (< from to)
77 (or ch
78 (setq ch (char-after from)
79 info (aref tai-viet-glyph-info ch)))
80 (setq from (1+ from))
81 (if (not info)
82 (setq prev-viet nil
83 ch nil)
84 (if (memq info '(combining-vowel combining-tone))
85 (progn
86 ;; Display this as a spacing glyph.
87 (compose-region (1- from) from (string ?\t ch))
88 (setq prev-viet t
89 ch nil))
90 (setq pos (1- from)
91 components ch
92 overhang (if (eq info 'right-overhang)
93 'right-overhang
94 (if (and (not prev-viet) (eq info 'left-overhang))
95 'left-overhang))
96 prev-viet t
97 ch nil)
98 (if (and (< from to)
99 (setq ch (char-after from)
100 info (aref tai-viet-glyph-info ch)))
101 (if (memq info '(combining-vowel combining-tone))
102 (progn
103 (setq components
104 (list components normal-rule ch)
105 from (1+ from)
106 ch nil)
107 (if (and (< from to)
108 (setq ch (char-after from)
109 info (aref tai-viet-glyph-info ch))
110 (eq info 'combining-tone))
111 (setq components (nconc components
112 (list tone-rule ch))
113 from (1+ from)))
114 (if (eq overhang 'left-overhang)
115 (setq components (cons ?\t
116 (cons normal-rule components)))
117 (if (and (eq overhang 'right-overhang)
118 (>= from to))
119 (setq components (nconc components
120 (list normal-rule ?\t)))))
121 (compose-region pos from components))
122 (if (eq overhang 'left-overhang)
123 (compose-region pos from (string ?\t components))))
124 (if (eq overhang 'left-overhang)
125 (compose-region pos from (string ?\t components))
126 (if (and (eq overhang 'right-overhang) (>= from to))
127 (compose-region pos from (string components ?\t))))))))
128 from))
129
130
131;;;###autoload
132(defun tai-viet-composition-function (pos &optional string)
133 (let (to)
134 (if string
135 (progn
136 (if (string-match tai-viet-re string pos)
137 (tai-viet-compose-string pos (match-end 0) string)
138 (1+ pos)))
139 (goto-char pos)
140 (if (looking-at tai-viet-re)
141 (tai-viet-compose-region pos (match-end 0))
142 (1+ pos)))))
143
144;;
145(provide 'tai-viet-util)