Mercurial > emacs
annotate lisp/language/tv-util.el @ 91902:153651069fb2
(x_make_gc): Use the default font id of the frame for
GCs.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Sun, 17 Feb 2008 02:01:59 +0000 |
parents | 0c76c1616cf9 |
children | 55b7f25d920a |
rev | line source |
---|---|
90938 | 1 ;;; tv-util.el --- support for Tai Viet -*- coding: utf-8 -*- |
2 | |
91437
0c76c1616cf9
Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents:
91277
diff
changeset
|
3 ;; Copyright (C) 2007, 2008 |
90938 | 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 | |
91437
0c76c1616cf9
Update copyright years and GPL version.
Glenn Morris <rgm@gnu.org>
parents:
91277
diff
changeset
|
13 ;; the Free Software Foundation; either version 3, or (at your option) |
90938 | 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 | |
91217
9cf3b1c148b9
(tai-viet-re): Include '-'.
Kenichi Handa <handa@m17n.org>
parents:
90950
diff
changeset
|
30 (format "[\xaa80-\xaac2\xaadb-\xaadf-]+")) |
90938 | 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 . "ꪴꪰꪲꪳꪷꪸꪾ") | |
91217
9cf3b1c148b9
(tai-viet-re): Include '-'.
Kenichi Handa <handa@m17n.org>
parents:
90950
diff
changeset
|
38 (combining-tone . "꪿꫁") |
9cf3b1c148b9
(tai-viet-re): Include '-'.
Kenichi Handa <handa@m17n.org>
parents:
90950
diff
changeset
|
39 (misc . "-")))) |
90938 | 40 ;; Set all TaiViet characters to `t'. |
41 (set-char-table-range table (cons #xaa80 #xaac2) t) | |
42 (set-char-table-range table (cons #xaadb #xaadf) t) | |
43 ;; Overwrite it for special characters. | |
44 (dolist (elt specials) | |
45 (let ((category (car elt)) | |
46 (chars (cdr elt))) | |
47 (dotimes (i (length chars)) | |
48 (aset table (aref chars i) category)))) | |
49 table)) | |
50 | |
51 (defun tai-viet-compose-string (from to string) | |
52 "Compose Tai Viet characters in STRING between indices FROM and TO." | |
53 (let* ((ch (aref string from)) | |
54 (info (aref tai-viet-glyph-info ch)) | |
55 prev-info) | |
56 (if (eq info 'non-spacing) | |
57 (compose-string string from (1+ from) (string ch ?\t))) | |
58 (setq from (1+ from) prev-info info) | |
59 (while (and (< from to) | |
90949 | 60 (>= #xaa80 (setq ch (aref string from))) |
61 (<= #xaaDF ch)) | |
90938 | 62 (setq info (aref tai-viet-glyph-info ch)) |
63 (if (and (eq info 'non-spacing) | |
64 (eq prev-info 'non-spacing)) | |
65 (compose-string from (1+ from) (string ?\t ch))) | |
66 (setq from (1+ from) prev-info info)) | |
67 (if (eq info 'right-overhang) | |
68 (compose-string string (1- from) from (string ch ?\t))) | |
69 from)) | |
70 | |
71 (defun tai-viet-compose-region (from to) | |
72 "Compose Tai Viet characters in the region between FROM and TO." | |
73 (decompose-region from to) | |
74 (let ((normal-rule '(Br . Bl)) | |
75 (tone-rule '(tr . bl)) | |
76 (prev-viet nil) | |
77 ch info pos components overhang) | |
78 (while (< from to) | |
79 (or ch | |
80 (setq ch (char-after from) | |
81 info (aref tai-viet-glyph-info ch))) | |
82 (setq from (1+ from)) | |
83 (if (not info) | |
84 (setq prev-viet nil | |
85 ch nil) | |
86 (if (memq info '(combining-vowel combining-tone)) | |
87 (progn | |
88 ;; Display this as a spacing glyph. | |
89 (compose-region (1- from) from (string ?\t ch)) | |
90 (setq prev-viet t | |
91 ch nil)) | |
92 (setq pos (1- from) | |
93 components ch | |
94 overhang (if (eq info 'right-overhang) | |
95 'right-overhang | |
96 (if (and (not prev-viet) (eq info 'left-overhang)) | |
97 'left-overhang)) | |
98 prev-viet t | |
99 ch nil) | |
100 (if (and (< from to) | |
101 (setq ch (char-after from) | |
102 info (aref tai-viet-glyph-info ch))) | |
103 (if (memq info '(combining-vowel combining-tone)) | |
104 (progn | |
105 (setq components | |
106 (list components normal-rule ch) | |
107 from (1+ from) | |
108 ch nil) | |
109 (if (and (< from to) | |
110 (setq ch (char-after from) | |
111 info (aref tai-viet-glyph-info ch)) | |
112 (eq info 'combining-tone)) | |
113 (setq components (nconc components | |
114 (list tone-rule ch)) | |
115 from (1+ from))) | |
116 (if (eq overhang 'left-overhang) | |
117 (setq components (cons ?\t | |
118 (cons normal-rule components))) | |
119 (if (and (eq overhang 'right-overhang) | |
120 (>= from to)) | |
121 (setq components (nconc components | |
122 (list normal-rule ?\t))))) | |
123 (compose-region pos from components)) | |
124 (if (eq overhang 'left-overhang) | |
125 (compose-region pos from (string ?\t components)))) | |
126 (if (eq overhang 'left-overhang) | |
127 (compose-region pos from (string ?\t components)) | |
128 (if (and (eq overhang 'right-overhang) (>= from to)) | |
129 (compose-region pos from (string components ?\t)))))))) | |
130 from)) | |
131 | |
132 | |
133 ;;;###autoload | |
91277
0dfd79b5e5c5
(tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents:
91217
diff
changeset
|
134 (defun tai-viet-composition-function (from to font-object string) |
0dfd79b5e5c5
(tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents:
91217
diff
changeset
|
135 (if string |
0dfd79b5e5c5
(tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents:
91217
diff
changeset
|
136 (if (string-match tai-viet-re string from) |
0dfd79b5e5c5
(tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents:
91217
diff
changeset
|
137 (tai-viet-compose-string from (match-end 0) string)) |
0dfd79b5e5c5
(tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents:
91217
diff
changeset
|
138 (goto-char from) |
0dfd79b5e5c5
(tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents:
91217
diff
changeset
|
139 (if (looking-at tai-viet-re) |
0dfd79b5e5c5
(tai-viet-composition-function): Fix
Kenichi Handa <handa@m17n.org>
parents:
91217
diff
changeset
|
140 (tai-viet-compose-region from (match-end 0))))) |
90938 | 141 |
142 ;; | |
143 (provide 'tai-viet-util) | |
90950 | 144 |
145 ;; arch-tag: a45ac3fc-07d0-44d5-8841-2ebea7e11f5b |