Mercurial > emacs
annotate lisp/language/mlm-util.el @ 91962:37c6e66c7e57
*** empty log message ***
author | Michael Albinus <michael.albinus@gmx.de> |
---|---|
date | Tue, 19 Feb 2008 19:23:19 +0000 |
parents | 606f2d163a64 |
children |
rev | line source |
---|---|
49702 | 1 ;;; mlm-util.el --- support for composing malayalam characters -*-coding: iso-2022-7bit;-*- |
2 | |
79711 | 3 ;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 |
4 ;; Free Software Foundation, Inc. | |
49702 | 5 |
6 ;; Maintainer: KAWABATA, Taichi <kawabata@m17n.org> | |
7 ;; Keywords: multilingual, Malayalam | |
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 | |
78236
9355f9b7bbff
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
75347
diff
changeset
|
13 ;; the Free Software Foundation; either version 3, or (at your option) |
49702 | 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 | |
64085 | 23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
24 ;; Boston, MA 02110-1301, USA. | |
49702 | 25 |
26 ;; Created: Feb. 11. 2003 | |
27 | |
28 ;;; Commentary: | |
29 | |
30 ;; This file provides character(Unicode) to glyph(CDAC) conversion and | |
31 ;; composition of Malayalam script characters. | |
32 | |
33 ;;; Code: | |
34 | |
35 ;; Malayalam Composable Pattern | |
36 ;; C .. Consonants | |
37 ;; V .. Vowel | |
38 ;; H .. Halant | |
39 ;; M .. Matra | |
40 ;; V .. Vowel | |
41 ;; A .. Anuswar | |
42 ;; D .. Chandrabindu | |
43 ;; (N .. Zerowidth Non Joiner) | |
44 ;; (J .. Zerowidth Joiner. ) | |
45 ;; 1. vowel | |
46 ;; V(A|visargam)? | |
47 ;; 2. syllable : maximum of 5 consecutive consonants. (e.g. kartsnya) | |
48 ;; ((CH)?(CH)?(CH)?CH)?C(H|M?(A|D)?)? | |
49 | |
50 (defconst malayalam-consonant | |
51 "[$,1@5(B-$,1@Y(B]") | |
52 | |
53 (defconst malayalam-composable-pattern | |
54 (concat | |
55 "\\([$,1@%(B-$,1@4(B][$,1@"(B]?\\)\\|$,1@#(B" | |
56 "\\|\\(" | |
57 "\\(?:\\(?:[$,1@5(B-$,1@Y(B]$,1@m(B\\)?\\(?:[$,1@5(B-$,1@Y(B]$,1@m(B\\)?\\(?:[$,1@5(B-$,1@Y(B]$,1@m(B\\)?[$,1@5(B-$,1@Y(B]$,1@m(B\\)?" | |
58 "[$,1@5(B-$,1@Y(B]\\(?:$,1@m(B\\|[$,1@^(B-$,1@c@f@g@h@j@j@k@l(B]?[$,1@"@m(B]?\\)?" | |
59 "\\)") | |
60 "Regexp matching a composable sequence of Malayalam characters.") | |
61 | |
62 ;;;###autoload | |
63 (defun malayalam-compose-region (from to) | |
64 (interactive "r") | |
65 (save-excursion | |
66 (save-restriction | |
67 (narrow-to-region from to) | |
68 (goto-char (point-min)) | |
69 (while (re-search-forward malayalam-composable-pattern nil t) | |
70 (malayalam-compose-syllable-region (match-beginning 0) | |
71 (match-end 0)))))) | |
72 (defun malayalam-compose-string (string) | |
73 (with-temp-buffer | |
74 (insert (decompose-string string)) | |
75 (malayalam-compose-region (point-min) (point-max)) | |
76 (buffer-string))) | |
77 | |
52518
88807cd5407c
(malayalam-post-read-conversion): Add autoload cookie.
Kenichi Handa <handa@m17n.org>
parents:
52401
diff
changeset
|
78 ;;;###autoload |
49702 | 79 (defun malayalam-post-read-conversion (len) |
80 (save-excursion | |
81 (save-restriction | |
82 (let ((buffer-modified-p (buffer-modified-p))) | |
83 (narrow-to-region (point) (+ (point) len)) | |
84 (malayalam-compose-region (point-min) (point-max)) | |
85 (set-buffer-modified-p buffer-modified-p) | |
86 (- (point-max) (point-min)))))) | |
87 | |
88 (defun malayalam-range (from to) | |
89 "Make the list of the integers of range FROM to TO." | |
90 (let (result) | |
91 (while (<= from to) (setq result (cons to result) to (1- to))) result)) | |
92 | |
93 (defun malayalam-regexp-of-hashtbl-keys (hashtbl) | |
94 "Return a regular expression that matches all keys in hashtable HASHTBL." | |
95 (let ((max-specpdl-size 1000)) | |
96 (regexp-opt | |
97 (sort | |
98 (let (dummy) | |
99 (maphash (function (lambda (key val) (setq dummy (cons key dummy)))) hashtbl) | |
100 dummy) | |
101 (function (lambda (x y) (> (length x) (length y)))))))) | |
102 | |
103 | |
104 ;;;###autoload | |
89483 | 105 (defun malayalam-composition-function (pos &optional string) |
106 "Compose Malayalam characters after the position POS. | |
107 If STRING is not nil, it is a string, and POS is an index to the string. | |
108 In this case, compose characters after POS of the string." | |
109 (if string | |
91198
34fe548702cc
(malayalam-composition-function): Use
Kenichi Handa <handa@m17n.org>
parents:
90996
diff
changeset
|
110 (if auto-compose-current-font |
34fe548702cc
(malayalam-composition-function): Use
Kenichi Handa <handa@m17n.org>
parents:
90996
diff
changeset
|
111 (if (eq (string-match "[$,1@ (B-$,1A?(B]+" pos) pos) |
34fe548702cc
(malayalam-composition-function): Use
Kenichi Handa <handa@m17n.org>
parents:
90996
diff
changeset
|
112 (or (font-shape-text 0 (match-end 0) auto-compose-current-font |
34fe548702cc
(malayalam-composition-function): Use
Kenichi Handa <handa@m17n.org>
parents:
90996
diff
changeset
|
113 string) |
34fe548702cc
(malayalam-composition-function): Use
Kenichi Handa <handa@m17n.org>
parents:
90996
diff
changeset
|
114 pos))) |
89483 | 115 (goto-char pos) |
91198
34fe548702cc
(malayalam-composition-function): Use
Kenichi Handa <handa@m17n.org>
parents:
90996
diff
changeset
|
116 (if auto-compose-current-font |
34fe548702cc
(malayalam-composition-function): Use
Kenichi Handa <handa@m17n.org>
parents:
90996
diff
changeset
|
117 (if (looking-at "[$,1@ (B-$,1A?(B]+") |
34fe548702cc
(malayalam-composition-function): Use
Kenichi Handa <handa@m17n.org>
parents:
90996
diff
changeset
|
118 (or (font-shape-text pos (match-end 0) auto-compose-current-font) |
34fe548702cc
(malayalam-composition-function): Use
Kenichi Handa <handa@m17n.org>
parents:
90996
diff
changeset
|
119 pos) |
34fe548702cc
(malayalam-composition-function): Use
Kenichi Handa <handa@m17n.org>
parents:
90996
diff
changeset
|
120 (if (looking-at malayalam-composable-pattern) |
34fe548702cc
(malayalam-composition-function): Use
Kenichi Handa <handa@m17n.org>
parents:
90996
diff
changeset
|
121 (prog1 (match-end 0) |
34fe548702cc
(malayalam-composition-function): Use
Kenichi Handa <handa@m17n.org>
parents:
90996
diff
changeset
|
122 (malayalam-compose-syllable-region pos (match-end 0)))))))) |
49702 | 123 |
124 ;; Notes on conversion steps. | |
125 | |
126 ;; 1. chars to glyphs | |
127 ;; | |
128 ;; Simple replacement of characters to glyphs is done. | |
129 | |
130 ;; 2. glyphs reordering. | |
131 ;; | |
132 ;; Two special reordering rule takes place. | |
133 ;; a. following "$,46[(B" goes to the front. | |
134 ;; b. following "$,46S6S(B", "$,46S(B" or "$,46T(B" goes to the front. | |
135 ;; This reordering occurs only to the last cluster of consonants. | |
136 ;; Preceding consonants with halant characters are not affected. | |
137 | |
138 ;; 3. Composition. | |
139 ;; | |
140 ;; left modifiers will be attached at the left. | |
141 ;; others will be attached right. | |
142 | |
143 (defvar mlm-char-glyph | |
144 '(;; various signs | |
145 ("$,1@"(B" . "$,46W(B") | |
146 ("$,1@#(B" . "$,46X(B") | |
147 ;; Independent Vowels | |
148 ("$,1@%(B" . "$,46!(B") | |
149 ("$,1@&(B" . "$,46"(B") | |
150 ("$,1@'(B" . "$,46#(B") | |
151 ("$,1@((B" . "$,46#6U(B") | |
152 ("$,1@)(B" . "$,46$(B") | |
153 ("$,1@*(B" . "$,46$6U(B") | |
154 ("$,1@+(B" . "$,46%(B") | |
155 ("$,1@,(B" . "nil") ;; not in present use, not supported. | |
156 ("$,1@.(B" . "$,46&(B") | |
157 ("$,1@/(B" . "$,46'(B") | |
158 ("$,1@0(B" . "$,46S6&(B") | |
159 ("$,1@2(B" . "$,46((B") | |
160 ("$,1@3(B" . "$,46(6M(B") | |
161 ("$,1@4(B" . "$,46(6U(B") | |
162 ;; Consonants | |
163 ("$,1@5(B" . "$,46)(B") | |
164 ("$,1@5@m@5(B" . "$,47!(B") | |
49955
15e3ed34db0a
(mlm-char-glyph): Fix several composing rules.
Kenichi Handa <handa@m17n.org>
parents:
49943
diff
changeset
|
165 ("$,1@5@m@S(B" . "$,47"(B") |
49702 | 166 ("$,1@5@m@W(B" . "$,47#(B") |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
167 ("$,1@5@m@?(B" . "$,47N(B") |
49702 | 168 ("$,1@5@m@D(B" . "$,47`(B") |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
169 ("$,1@5@a(B" . "$,47f(B") |
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
170 ("$,1@5@m@5@a(B" . "$,47g(B") |
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
171 ("$,1@5@a(B" . "$,47f(B") |
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
172 ("$,1@5@m@5@a(B" . "$,47g(B") |
49702 | 173 |
174 ("$,1@6(B" . "$,46*(B") | |
175 | |
176 ("$,1@7(B" . "$,46+(B") | |
177 ("$,1@7@m@7(B" . "$,47$(B") | |
178 ("$,1@7@m@R(B" . "$,47%(B") | |
179 ("$,1@7@m@N(B" . "$,47\(B") | |
180 ("$,1@7@m@H(B" . "$,47a(B") | |
181 | |
182 ("$,1@8(B" . "$,46,(B") | |
183 | |
184 ("$,1@9(B" . "$,46-(B") | |
185 ("$,1@9@m@5(B" . "$,47&(B") | |
186 ("$,1@9@m@9(B" . "$,47'(B") | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
187 ("$,1@9@m@5@a(B" . "$,47h(B") |
49702 | 188 |
189 ("$,1@:(B" . "$,46.(B") | |
190 ("$,1@:@m@:(B" . "$,47((B") ;; duplicate | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
191 ("$,1@:@m@;(B" . "$,47Q(B") |
49702 | 192 |
193 ("$,1@;(B" . "$,46/(B") | |
194 | |
195 ("$,1@<(B" . "$,460(B") | |
196 ("$,1@<@m@<(B" . "$,47V(B") | |
197 ("$,1@<@m@>(B" . "$,47Z(B") | |
198 | |
199 ("$,1@=(B" . "$,461(B") | |
200 | |
201 ("$,1@>(B" . "$,462(B") | |
202 ("$,1@>@m@:(B" . "$,47)(B") | |
203 ("$,1@>@m@>(B" . "$,47*(B") | |
204 | |
205 ("$,1@?(B" . "$,463(B") | |
206 ("$,1@?@m@?(B" . "$,47+(B") | |
207 | |
208 ("$,1@@(B" . "$,464(B") | |
209 ("$,1@A(B" . "$,465(B") | |
210 ("$,1@A@m@A(B" . "$,47M(B") | |
211 ("$,1@B(B" . "$,466(B") | |
212 | |
213 ("$,1@C(B" . "$,467(B") | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
214 ("$,1@C@a@m(B" . "$,47,(B") ;; half consonant |
49702 | 215 ("$,1@C@m@?(B" . "$,47-(B") |
216 ("$,1@C@m@C(B" . "$,47.(B") | |
217 ("$,1@C@m@N(B" . "$,47W(B") | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
218 ("$,1@C@m@A(B" . "$,47^(B") |
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
219 ("$,1@C@a(B" . "$,47i(B") |
49702 | 220 |
221 ("$,1@D(B" . "$,468(B") | |
222 ("$,1@D@m@D(B" . "$,47/(B") | |
223 ("$,1@D@m@E(B" . "$,470(B") | |
224 ("$,1@D@m@X(B" . "$,47U(B") | |
225 ("$,1@D@m@M(B" . "$,47[(B") | |
226 ("$,1@D@m@N(B" . "$,47_(B") | |
227 | |
228 ("$,1@E(B" . "$,469(B") | |
229 | |
230 ("$,1@F(B" . "$,46:(B") | |
231 ("$,1@F@m@F(B" . "$,471(B") | |
232 ("$,1@F@m@G(B" . "$,472(B") | |
233 | |
234 ("$,1@G(B" . "$,46;(B") | |
235 | |
236 ("$,1@H(B" . "$,46<(B") | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
237 ("$,1@H@a@m(B" . "$,473(B") ;; half consonant |
49702 | 238 ("$,1@H@m@D(B" . "$,474(B") |
239 ("$,1@H@m@F(B" . "$,475(B") | |
240 ("$,1@H@m@H(B" . "$,476(B") | |
241 ("$,1@H@m@N(B" . "$,477(B") | |
242 ("$,1@H@m@G(B" . "$,47T(B") | |
243 ("$,1@H@m@E(B" . "$,47Y(B") | |
244 ("$,1@H@m@Q(B" . "$,47b(B") | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
245 ("$,1@H@a(B" . "$,47k(B") |
68019
b9546af7814e
Delete spurious trailing whitespaces.
Kenichi Handa <handa@m17n.org>
parents:
64085
diff
changeset
|
246 ("$,1@H@m@H@a(B" . "$,47l(B") |
49702 | 247 |
248 ("$,1@J(B" . "$,46=(B") | |
249 ("$,1@J@m@J(B" . "$,478(B") ;; duplicate | |
250 ("$,1@J@m@R(B" . "$,479(B") ;; lakar | |
251 | |
252 ("$,1@K(B" . "$,46>(B") | |
253 | |
254 ("$,1@L(B" . "$,46?(B") | |
255 ("$,1@L@m@L(B" . "$,47:(B") ;; duplicate | |
256 ("$,1@L@m@R(B" . "$,47;(B") ;; lakar | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
257 ("$,1@L@m@G(B" . "$,47O(B") |
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
258 ("$,1@L@m@F(B" . "$,47P(B") |
49702 | 259 |
260 ("$,1@M(B" . "$,46@(B") | |
261 | |
262 ("$,1@N(B" . "$,46A(B") | |
263 ("$,1@N@m@J(B" . "$,47<(B") | |
264 ("$,1@N@m@N(B" . "$,47=(B") | |
265 ("$,1@N@m@R(B" . "$,47>(B") ;; lakar | |
266 | |
267 ("$,1@O(B" . "$,46B(B") | |
268 ("$,1@O@m@O(B" . "$,47?(B") ;; duplicate | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
269 ("$,1@O@m@5@m@5(B" . "$,47m(B") |
49702 | 270 |
271 ("$,1@P(B" . "$,46C(B") | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
272 ("$,1@P@a@m(B" . "$,47@(B") |
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
273 ("$,1@P@a(B" . "$,47j(B") |
49702 | 274 |
275 ("$,1@Q(B" . "$,46D(B") | |
276 ("$,1@Q@m(B" . "$,47@(B") ;; same glyph as "$,1@P@m(B" | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
277 ("$,1@Q@a@m(B" . "$,47@(B") ;; same glyph as "$,1@P@m(B" |
49702 | 278 ;;("$,1@Q@m@Q(B" . "$,47A(B") |
279 ("$,1@Q@m@Q(B" . "$,47d(B") | |
280 | |
281 ("$,1@R(B" . "$,46E(B") | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
282 ("$,1@R@a@m(B" . "$,47B(B") |
49702 | 283 ("$,1@R@m@R(B" . "$,47C(B") ;; lakar |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
284 ("$,1@R@m@J(B" . "$,47e(B") |
49702 | 285 |
286 ("$,1@S(B" . "$,46F(B") | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
287 ("$,1@S@a@m(B" . "$,47D(B") |
49702 | 288 ("$,1@S@m@S(B" . "$,47E(B") |
289 | |
290 ("$,1@T(B" . "$,46G(B") | |
291 | |
292 ("$,1@U(B" . "$,46H(B") | |
293 ("$,1@U@m@U(B" . "$,47F(B") | |
294 | |
295 ("$,1@V(B" . "$,46I(B") | |
296 ("$,1@V@m@R(B" . "$,47G(B") | |
297 ("$,1@V@m@V(B" . "$,47H(B") | |
298 ("$,1@V@m@:(B" . "$,47](B") | |
299 | |
300 ("$,1@W(B" . "$,46J(B") | |
301 ("$,1@W@m@?(B" . "$,47c(B") | |
302 | |
303 ("$,1@X(B" . "$,46K(B") | |
304 ("$,1@X@m@R(B" . "$,47I(B") | |
305 ("$,1@X@m@X(B" . "$,47J(B") | |
306 ("$,1@X@m@Q@m@Q(B" . "$,47L(B") | |
307 ("$,1@X@m@E(B" . "$,47X(B") | |
308 | |
309 ("$,1@Y(B" . "$,46L(B") | |
310 ("$,1@Y@m@R(B" . "$,47K(B") | |
311 ("$,1@Y@m@N(B" . "$,47R(B") | |
312 ("$,1@Y@m@H(B" . "$,47S(B") | |
313 | |
314 ;; Dependent vowel signs | |
315 ("$,1@^(B" . "$,46M(B") | |
316 ("$,1@_(B" . "$,46N(B") | |
317 ("$,1@`(B" . "$,46O(B") | |
318 ("$,1@a(B" . "$,46P(B") | |
319 ("$,1@b(B" . "$,46Q(B") | |
320 ("$,1@c(B" . "$,46R(B") | |
321 ("$,1@f(B" . "$,46S(B") | |
322 ("$,1@g(B" . "$,46T(B") | |
323 ("$,1@h(B" . "$,46S6S(B") | |
324 ("$,1@j(B" . "$,46S6M(B") | |
325 ("$,1@k(B" . "$,46T6M(B") | |
326 ("$,1@l(B" . "$,46U(B") | |
327 ;; Various signs | |
328 ("$,1@m(B" . "$,46V(B") | |
329 ("$,1@m@O(B" . "$,46Y(B") ;; yakar | |
49973
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
330 ("$,1@m@O@a(B" . "$,46\(B") ;; yakar + u |
bd6fa6f622f2
(mlm-char-glyph): Fix more rules.
Kenichi Handa <handa@m17n.org>
parents:
49955
diff
changeset
|
331 ("$,1@m@O@b(B" . "$,46](B") ;; yakar + uu |
49702 | 332 ("$,1@m@U(B" . "$,46Z(B") ;; vakar modifier |
333 ("$,1@m@P(B" . "$,46[(B") ;; rakar modifier is the same to rra modifier. | |
49943
f70ce138a267
(mlm-char-glyph): Add entries for "halant +
Kenichi Handa <handa@m17n.org>
parents:
49702
diff
changeset
|
334 ("$,1@m@P@m(B" . "$,46R(B") ;; halant + rakar + halant |
49702 | 335 ("$,1@m@Q(B" . "$,46[(B") ;; rrakar modifier |
49943
f70ce138a267
(mlm-char-glyph): Add entries for "halant +
Kenichi Handa <handa@m17n.org>
parents:
49702
diff
changeset
|
336 ("$,1@m@Q@m(B" . "$,46R(B") ;; halant + rrakar + halant |
49702 | 337 ("$,1@m@m(B" . "$,46V(B") ;; double omission sign to stop forming half consonant. |
338 ("$,1@w(B" . "$,46U(B") ;; not in present use, already at 0D4C. | |
339 )) | |
340 | |
341 (defvar mlm-char-glyph-hash | |
342 (let* ((hash (make-hash-table :test 'equal))) | |
343 (mapc (function (lambda (x) (puthash (car x) (cdr x) hash))) | |
344 mlm-char-glyph) | |
345 hash)) | |
346 | |
347 (defvar mlm-char-glyph-regexp | |
348 (malayalam-regexp-of-hashtbl-keys mlm-char-glyph-hash)) | |
349 | |
350 ;; Malayalam languages needed to be reordered in a complex mannar. | |
351 | |
352 (defvar mlm-consonants | |
353 (concat | |
354 "$,46)6*6+6,6-6.6/606162636465666768696:6;6<6=6>6?6@6A6B6C6D6E6F6G6H6I6J6K6L(B" | |
355 "$,47!7"7#7$7%7&7'7(7)7*7+7,7-7.7/707172737475767778797:7;7<7=7>7?7@7A7B7C7D7E7F7G7H7I7J7K7L7M7N7O7P7Q7R7S7T7U7V7W7X7Y7Z7[7\7]7^7_7`7a7b7c7d7e(B" | |
356 )) | |
357 | |
358 (defvar mlm-consonants-regexp | |
359 (concat "\\($,46[(B?[" mlm-consonants "][$,46Y6Z(B]?\\)")) | |
360 | |
361 (defvar mlm-glyph-reorder-key-glyphs "[$,46[6S6T(B]") | |
362 | |
363 (defvar mlm-glyph-reordering-regexp-list | |
364 `((,(concat "\\([" mlm-consonants "][$,46Y6Z(B]?\\)$,46[(B") . "$,46[(B\\1") | |
365 (,(concat mlm-consonants-regexp "$,46S6S(B") . "$,46S6S(B\\1") | |
366 (,(concat mlm-consonants-regexp "$,46S(B") . "$,46S(B\\1") | |
367 (,(concat mlm-consonants-regexp "$,46T(B") . "$,46T(B\\1"))) | |
368 | |
369 (defun malayalam-compose-syllable-string (string) | |
370 (with-temp-buffer | |
371 (insert (decompose-string string)) | |
372 (malayalam-compose-syllable-region (point-min) (point-max)) | |
373 (buffer-string))) | |
374 | |
375 (defun malayalam-compose-syllable-region (from to) | |
376 "Compose malayalam syllable in region FROM to TO." | |
377 (let (glyph-str | |
378 match-str | |
379 glyph-reorder-regexps | |
380 glyph-reorder-replace | |
381 glyph-reorder-regexp) | |
382 (save-excursion | |
383 (save-restriction | |
384 (narrow-to-region from to) | |
385 (goto-char (point-min)) | |
386 ;; char-glyph-conversion | |
89483 | 387 (while (not (eobp)) |
388 (if (looking-at mlm-char-glyph-regexp) | |
389 (progn | |
390 (setq match-str (match-string 0) | |
391 glyph-str | |
392 (concat glyph-str | |
393 (gethash match-str mlm-char-glyph-hash))) | |
394 (goto-char (match-end 0))) | |
395 (setq glyph-str (concat glyph-str (string (following-char)))) | |
396 (forward-char 1))) | |
49702 | 397 (when (string-match mlm-glyph-reorder-key-glyphs glyph-str) |
398 ;; glyph reordering | |
399 (setq glyph-reorder-regexps mlm-glyph-reordering-regexp-list) | |
400 (while glyph-reorder-regexps | |
401 (setq glyph-reorder-regexp (caar glyph-reorder-regexps)) | |
402 (setq glyph-reorder-replace (cdar glyph-reorder-regexps)) | |
403 (setq glyph-reorder-regexps (cdr glyph-reorder-regexps)) | |
404 (if (string-match glyph-reorder-regexp glyph-str) | |
405 (setq glyph-str | |
406 (replace-match glyph-reorder-replace nil nil | |
407 glyph-str))))) | |
408 ;; concatenate and attach reference-points. | |
409 (setq glyph-str | |
410 (cdr | |
411 (apply | |
412 'nconc | |
413 (mapcar | |
68019
b9546af7814e
Delete spurious trailing whitespaces.
Kenichi Handa <handa@m17n.org>
parents:
64085
diff
changeset
|
414 (function |
49702 | 415 (lambda (x) (list '(5 . 3) x))) ;; default ref. point. |
416 glyph-str)))) | |
417 (compose-region from to glyph-str))))) | |
418 | |
419 (provide 'mlm-util) | |
420 | |
52401 | 421 ;;; arch-tag: 7f25ee67-8f9d-49f2-837b-35c412c00eba |
49702 | 422 ;;; devan-util.el ends here |