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