Mercurial > hg > xemacs-beta
annotate lisp/mule/devan-util.el @ 5844:83e5c3cd6be6
Improve Installation text for Postgresql.
| author | Stephen J. Turnbull <stephen@xemacs.org> |
|---|---|
| date | Sat, 10 Jan 2015 19:43:28 +0900 |
| parents | ac37a5f7e5be |
| children |
| rev | line source |
|---|---|
| 778 | 1 ;;; devan-util.el --- support for Devanagari Script Composition -*- coding: iso-2022-7bit; -*- |
| 771 | 2 |
| 3 ;; Copyright (C) 1996, 2001 Free Software Foundation, Inc. | |
| 4 | |
| 5 ;; Author: KAWABATA, Taichi <kawabata@is.s.u-tokyo.ac.jp> | |
| 6 | |
| 7 ;; Keywords: multilingual, Indian, Devanagari | |
| 8 | |
| 9 ;; This file is part of XEmacs. | |
| 10 | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4021
diff
changeset
|
11 ;; XEmacs is free software: you can redistribute it and/or modify it |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4021
diff
changeset
|
12 ;; under the terms of the GNU General Public License as published by the |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4021
diff
changeset
|
13 ;; Free Software Foundation, either version 3 of the License, or (at your |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4021
diff
changeset
|
14 ;; option) any later version. |
| 771 | 15 |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4021
diff
changeset
|
16 ;; XEmacs is distributed in the hope that it will be useful, but WITHOUT |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4021
diff
changeset
|
17 ;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4021
diff
changeset
|
18 ;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4021
diff
changeset
|
19 ;; for more details. |
| 771 | 20 |
| 21 ;; You should have received a copy of the GNU General Public License | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
4021
diff
changeset
|
22 ;; along with XEmacs. If not, see <http://www.gnu.org/licenses/>. |
| 771 | 23 |
| 778 | 24 ;;; Synched up with: Emacs 21.1 (language/devan-util.el). |
| 771 | 25 |
| 26 ;;; Commentary: | |
| 27 | |
| 28 ;; History: | |
| 29 ;; 1996.10.18 written by KAWABATA, Taichi <kawabata@is.s.u-tokyo.ac.jp> | |
| 30 ;; 1997.3.24 fixed some bugs. | |
| 31 | |
| 32 ;; Future work :: | |
| 33 ;; Decompose the input characters and process them on the character basis. | |
| 34 | |
| 35 ;; Devanagari script composition rules and related programs. | |
| 36 | |
| 37 ;;; Code: | |
| 38 | |
| 39 ;;; | |
| 40 ;;; Steps toward composition of Devanagari Characters. | |
| 41 ;;; | |
| 42 | |
| 43 ;;; Basic functions. | |
| 44 | |
| 45 ;;;###autoload | |
| 46 (defun indian-to-devanagari (char) | |
| 47 "Convert IS 13194 character CHAR to Devanagari basic characters. | |
| 48 If CHAR is not IS 13194, return CHAR as is." | |
| 49 (let ((charcodes (split-char char))) | |
| 50 (if (eq (car charcodes) 'indian-is13194) | |
| 51 (make-char 'indian-2-column ?\x21 (nth 1 charcodes)) | |
| 52 char))) | |
| 53 | |
| 54 ;;;###autoload | |
| 55 (defun devanagari-to-indian (char) | |
| 56 "Convert Devanagari basic character CHAR to IS 13194 characters. | |
| 57 If CHAR is not Devanagari basic character, return CHAR as is." | |
| 58 (let ((charcodes (split-char char))) | |
| 59 (if (and (eq (car charcodes) 'indian-2-column) | |
| 60 (= (nth 1 charcodes) ?\x21)) | |
| 61 (make-char 'indian-is13194 (nth 2 charcodes)) | |
| 62 char))) | |
| 63 | |
| 64 ;;;###autoload | |
| 65 (defun indian-to-devanagari-region (from to) | |
| 66 "Convert IS 13194 characters in region to Devanagari basic characters. | |
| 67 When called from a program, expects two arguments, | |
| 68 positions (integers or markers) specifying the region." | |
| 69 (interactive "r") | |
| 70 (save-excursion | |
| 71 (goto-char from) | |
| 72 (while (< (point) to) | |
| 73 (let ((char (following-char))) | |
| 74 (if (eq (char-charset char) 'indian-is13194) | |
| 75 (progn | |
| 76 (delete-char 1) | |
| 77 (insert (indian-to-devanagari char))) | |
| 78 (forward-char 1)))))) | |
| 79 | |
| 80 ;;;###autoload | |
| 81 (defun devanagari-to-indian-region (from to) | |
| 82 "Convert Devanagari basic characters in region to Indian characters. | |
| 83 When called from a program, expects two arguments, | |
| 84 positions (integers or markers) specifying the region." | |
| 85 (interactive "r") | |
| 86 (save-excursion | |
| 87 (goto-char from) | |
| 88 (while (< (point) to) | |
| 89 (let ((char (following-char))) | |
| 90 (if (eq (char-charset char) 'indian-2-column) | |
| 91 (progn | |
| 92 (delete-char 1) | |
| 93 (insert (devanagari-to-indian char))) | |
| 94 (forward-char 1)))))) | |
| 95 | |
| 96 ;;;###autoload | |
| 97 (defun indian-to-devanagari-string (string) | |
| 98 "Convert Indian characters in STRING to Devanagari Basic characters." | |
| 99 (let* ((len (length string)) | |
| 100 (i 0) | |
| 101 (vec (make-vector len 0))) | |
| 102 (while (< i len) | |
| 103 (aset vec i (indian-to-devanagari (aref string i))) | |
| 104 (setq i (1+ i))) | |
| 105 (concat vec))) | |
| 106 | |
| 107 ;; Phase 0 - Determine whether the characters can be composed. | |
| 108 ;; | |
| 109 ;;; | |
| 110 ;;; Regular expressions to split characters for composition. | |
| 111 ;;; | |
| 112 ;; | |
| 113 ;; Indian script word contains one or more syllables. | |
| 114 ;; In BNF, it can be expressed as follows: | |
| 115 ;; | |
| 116 ;; Word ::= {Syllable} [Cons-Syllable] | |
| 117 ;; Syllable ::= Cons-Vowel-Syllable | Vowel-Syllable | |
| 118 ;; Vowel-Syllable ::= V[D] | |
| 119 ;; Cons-Vowel-Syllable ::= [Cons-Syllable] Full-Cons [M] [D] | |
| 120 ;; Cons-Syllable ::= [Pure-Cons] [Pure-Cons] [Pure-Cons] Pure-Cons | |
| 121 ;; Pure-Cons ::= Full-Cons H | |
| 122 ;; Full-Cons ::= C [N] | |
| 123 ;; | |
| 124 ;; {} repeat, [] optional | |
| 125 ;; | |
| 126 ;; C - Consonant ($(5!3!4!5!6!7!8!9!:!;!<!=!>!?!@!A!B!C!D!E(B | |
| 127 ;; $(5!F!G!H!I!J!K!L!M!N!O!P!Q!R!S!T!U!V!W!X(B) | |
| 128 ;; N - Nukta ($(5!i(B) | |
| 129 ;; H - Halant($(5!h(B) or Virama | |
| 130 ;; V - Vowel ($(5!$!%!&!'!(!)!*!+!,!-!.!/!0!1!2#&#'#*(B) | |
| 131 ;; ("$(5#&#'#*(B" can be obtained by IS13194 vowels with nukta.) | |
| 132 ;; D - Vowel Modifiers, i.e. Anuswar, Chandrabindu ($(5!!!"(B) | |
| 133 ;; (Visaraga ($(5!#(B) is excluded.) | |
| 134 ;; M - Matra ($(5!Z![!\!]!^!_!`!a!b!c!d!e!f!g#K#L#M(B) | |
| 135 ;; ("$(5#K#L#M(B" can be obtained by IS13194 matras with nukta.) | |
| 136 ;; | |
| 137 ;; In Emacs, one syllable of Indian language is considered to be one | |
| 138 ;; composite glyph. If we expand the above expression for | |
| 139 ;; cons-vowel-syllable, it would be: | |
| 140 ;; | |
| 141 ;; [[C [N] H] [C [N] H] [C [N] H] C [N] H] C [N] [M] [D] | |
| 142 ;; | |
| 143 ;; Therefore, in worst case, the one syllable may contain | |
| 144 ;; following characters. | |
| 145 ;; | |
| 146 ;; C N H C N H C N H C N H C N M D | |
| 147 ;; | |
| 148 ;; The example is a sanskrit word "kArtsnya", where five consecutive | |
| 149 ;; consonants appear. | |
| 150 ;; | |
| 151 ;; On the other hand, consonant-syllable, which appears at the end of | |
| 152 ;; the word, would have the following expression: | |
| 153 ;; | |
| 154 ;; [C [N] H] [C [N] H] [C [N] H] C [N] H | |
| 155 ;; | |
| 156 ;; This is acceptable BEFORE proper consonant-syllable is input. The | |
| 157 ;; string which doesn't match with the above expression is invalid and | |
| 158 ;; thus must be fixed. | |
| 159 ;; | |
| 160 ;; Note: | |
| 161 ;; Third case can be considered, which is an acceptable syllable and can | |
| 162 ;; not add any code more. | |
| 163 ;; | |
| 164 ;; [[C [N] H] [C [N] H] [C [N] H] C [N] H] C [N] [M] D | |
| 165 ;; | |
| 166 ;; However, to make editing possible even in this condition, we will | |
| 167 ;; not consider about this case. | |
| 168 ;; | |
| 169 ;; Note: | |
| 170 ;; Currently, it seems that the only following consonants would have | |
| 171 ;; Nukta sign attatched. | |
| 172 ;; ($(5!3!4!5!:!?!@!I(B) | |
| 173 ;; Therefore, [$(5!3(B-$(5!X(B]$(5!i(B? can be re-written as | |
| 174 ;; \\([$(5!3!4!5!:!?!@!I(B]$(5!i(B\\)\\|[$(5!3(B-$(5!X(B] | |
| 175 | |
| 176 (defconst devanagari-full-cons | |
| 177 "\\(\\([$(5!3!4!5!:!?!@!I(B]$(5!i(B\\)\\|[$(5!3(B-$(5!X$.$E"%(B]\\)" | |
| 178 "Devanagari full consonant") | |
| 179 | |
| 180 (defconst devanagari-pure-cons | |
| 181 (concat "\\(" devanagari-full-cons "$(5!h(B\\)") | |
| 182 "Devanagari pure consonant") | |
| 183 | |
| 184 (defconst devanagari-matra | |
| 185 "\\(\\([$(5!_![!\(B]$(5!i(B\\)\\|[$(5!Z(B-$(5!g#K#L#M(B]\\)" | |
| 186 "Devanagari Matra Signs. '$(5#K#L#M(B' can also be created from the combination | |
| 187 of '$(5!_![!\(B' and nukta sign.") | |
| 188 | |
| 189 (defconst devanagari-vowel | |
| 190 "\\(\\([$(5!*!&!'(B]$(5!i(B\\)\\|[$(5!$(B-$(5!2#&#'#*(B]\\)" | |
| 191 "Devanagari Vowels. '$(5#&#'#*(B' can also be created from the combination | |
| 192 of '$(5!*!&!'(B' and nukta sign.") | |
| 193 | |
| 194 (defconst devanagari-vowel-syllable | |
| 195 (concat devanagari-vowel "[$(5!!!"(B]?") | |
| 196 "Devanagari vowel syllable.") | |
| 197 | |
| 198 (defconst devanagari-cons-syllable | |
| 199 (concat devanagari-pure-cons "?" devanagari-pure-cons "?" | |
| 200 devanagari-pure-cons "?" devanagari-pure-cons "$") | |
| 201 "Devanagari consonant syllable") | |
| 202 | |
| 203 (defconst devanagari-cons-vowel-syllable | |
| 204 (concat "\\(" | |
| 205 devanagari-pure-cons "?" devanagari-pure-cons "?" | |
| 206 devanagari-pure-cons "?" devanagari-pure-cons "\\)?" | |
| 207 devanagari-full-cons devanagari-matra "?[$(5!!!"(B]?") | |
| 208 "Devanagari consonant vowel syllable.") | |
| 209 | |
| 210 ;; | |
| 211 ;; Also, digits and virams should be processed other than syllables. | |
| 212 ;; | |
| 213 ;; In IS 13194, Avagrah is obtained by Nukta after Viram, and | |
| 214 ;; OM is obtained by Nukta after Chandrabindu | |
| 215 ;; | |
| 216 | |
| 217 (defconst devanagari-digit-viram-visarga | |
| 218 "[$(5!q(B-$(5!z!j!#(B]") | |
| 219 | |
| 220 (defconst devanagari-other-sign | |
| 221 "\\([$(5!!!j(B]$(5!i(B\\)\\|\\([$(5#!#J(B]\\)") | |
| 222 | |
| 223 (defconst devanagari-composite-glyph-unit | |
| 224 (concat "\\(" devanagari-cons-syllable | |
| 225 "\\)\\|\\(" devanagari-vowel-syllable | |
| 226 "\\)\\|\\(" devanagari-cons-vowel-syllable | |
| 227 "\\)\\|\\(" devanagari-other-sign | |
| 228 "\\)\\|\\(" devanagari-digit-viram-visarga "\\)") | |
| 2391 | 229 "Regexp matching Devanagari string to be composed from one glyph.") |
| 771 | 230 |
| 231 ;;(put-charset-property charset-devanagari-1-column | |
| 232 ;; 'char-to-glyph 'devanagari-compose-string) | |
| 233 ;;(put-charset-property charset-devanagari-2-column | |
| 234 ;; 'char-to-glyph 'devanagari-compose-string) | |
| 235 | |
| 236 ;; Sample | |
| 237 ;; | |
| 238 ;;(string-match devanagari-cons-vowel-syllable-examine "$(5!X![(B") => 0 | |
| 239 ;;(string-match devanagari-cons-vowel-syllable-examine "$(5!F!h!D!\(B") => 0 | |
| 240 ;;(string-match devanagari-cons-vowel-syllable-examine "$(5!X![!F!h!D!\(B") => 0 | |
| 241 | |
| 242 ;; | |
| 243 ;; Steps toward the composition | |
| 244 ;; Converting Character Codes to Composite Glyph. | |
| 245 ;; | |
| 246 ;; Example : $(5!X![(B/$(5!F!h!D!\(B | |
| 247 ;; | |
| 248 ;; First, convert Characters to appropriate glyphs. | |
| 249 ;; | |
| 250 ;; => $(5!X![(B/$(5"F!D!\(B | |
| 251 ;; | |
| 252 ;; Then, determine the base glyph, apply-orders and apply-rules. | |
| 253 ;; | |
| 254 ;; => $(5!X(B (ml.mr) $(5![(B / $(5!D(B (ml.mr) $(5"F(B (mr ml) $(5!\(B | |
| 255 ;; | |
| 256 ;; Finally, convert 2-column glyphs to 1-column glyph | |
| 257 ;; if such a glyph exist. | |
| 258 ;; | |
| 259 ;; => $(6!X(B (ml.mr) $(6![(B / $(6!D(B (ml.mr) $(6"F(B (mr ml) $(6!\(B | |
| 260 ;; | |
| 261 ;; Compose the glyph. | |
| 262 ;; | |
| 263 ;; => 4$(6!Xt%![0!X![1(B/4$(6!Dt%"Fv#!\0!D"F!\1(B | |
| 264 ;; => 4$(6!Xt%![0!X![14!Dt%"Fv#!\0!D"F!\1(B | |
| 265 ;; | |
| 266 | |
| 267 ;; | |
| 268 ;; Phase 1: Converting Character Code to Glyph Code. | |
| 269 ;; | |
| 270 ;; | |
| 271 ;; IMPORTANT: | |
| 272 ;; There may be many rules that you many want to suppress. | |
| 273 ;; In that case, please comment out that rule. | |
| 274 ;; | |
| 275 ;; RULES WILL BE EVALUATED FROM FIRST TO LAST. | |
| 276 ;; PUT MORE SPECIFIC RULES FIRST. | |
| 277 ;; | |
| 278 ;; TO DO: | |
| 279 ;; Prepare multiple specific list of rules for each languages | |
| 280 ;; that adopt Devanagari script. | |
| 281 ;; | |
| 282 | |
| 283 (defconst devanagari-char-to-glyph-rules | |
| 284 '( | |
| 285 | |
| 286 ;; `r' at the top of syllable and followed by other consonants. | |
| 287 ;; ("[^$(5!h(B]\\($(5!O!h(B\\)[$(5!3(B-$(5!X(B]" "$(5"p(B") | |
| 288 ("^\\($(5!O!h(B\\)[$(5!3(B-$(5!X(B]" "$(5"p(B") | |
| 289 | |
| 290 ;; Ligature Rules | |
| 291 ("\\($(5!3!h!B!h!O!h!M(B\\)" "$(5$!(B" sanskrit) | |
| 292 ("\\($(5!3!h!B!h!T(B\\)" "$(5$"(B" sanskrit) | |
| 293 ("\\($(5!3!h!B!h!M(B\\)" "$(5$#(B" sanskrit) | |
| 294 ("\\($(5!3!h!F!h!M(B\\)" "$(5$$(B") | |
| 295 ("\\($(5!3!h!O!h!M(B\\)" "$(5$%(B") | |
| 296 ("\\($(5!3!h!O(B\\)" "$(5"#(B") ; Post "r" | |
| 297 ("\\($(5!3!h!T!h!M(B\\)" "$(5$&(B" sanskrit) | |
| 298 ("\\($(5!3!h(B\\)$(5!3!h(B[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"3(B") ; Special Half Form | |
| 299 ("\\($(5!3!h!3(B\\)" "$(5$'(B") | |
| 300 ("\\($(5!3!h(B\\)$(5!B!h!O(B" "$(5"3(B") ; Special Rules for "k-tr" | |
| 301 ("\\($(5!3!h!B(B\\)" "$(5$((B") | |
| 302 ("\\($(5!3!h!F(B\\)" "$(5$)(B") | |
| 303 ("\\($(5!3!h!L(B\\)" "$(5$*(B") | |
| 304 ("\\($(5!3!h!M(B\\)" "$(5$+(B") | |
| 305 ("\\($(5!3!h!Q(B\\)" "$(5$,(B") | |
| 306 ("\\($(5!3!h!T(B\\)" "$(5$-(B") | |
| 307 ("\\($(5!3!h!V!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"l(B") ; Half Form | |
| 308 ("\\($(5$.!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"l(B") ; Half Form | |
| 309 ("\\($(5!3!h!V(B\\)" "$(5$.(B") | |
| 310 ("\\($(5!3!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"3(B") ; Half Form | |
| 311 ("\\($(5!3!i!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"s(B") ; Nukta Half Form | |
| 312 ("\\($(5!3!i(B\\)" "$(5#3(B") ; Nukta | |
| 313 ("\\($(5!4!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"4(B") ; Half Form | |
| 314 ("\\($(5!4!i!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"t(B") ; Nukta Half Form | |
| 315 ("\\($(5!4!i(B\\)" "$(5#4(B") ; Nukta | |
| 316 ("\\($(5!5!h!O!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"`(B") ; Half Form | |
| 317 ("\\($(5!5!h!O(B\\)" "$(5"$(B") ; Post "r" | |
| 318 ("\\($(5!5!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"5(B") ; Half Form | |
| 319 ("\\($(5!5!i!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"u(B") ; Nukta Half Form | |
| 320 ("\\($(5!5!i(B\\)" "$(5#5(B") ; Nukta | |
| 321 ("\\($(5!6!h!F!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"a(B") ; Half Form | |
| 322 ("\\($(5!6!h!F(B\\)" "$(5$/(B") | |
| 323 ; Slot | |
| 324 ("\\($(5!6!h!O(B\\)" "$(5!6"q(B") ; Post "r" | |
| 325 ("\\($(5!6!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"6(B") ; Half Form | |
| 326 ("\\($(5!7!h!3!h!B!h!M(B\\)" "$(5$0(B" sanskrit) | |
| 327 ("\\($(5!7!h!3!h!V!h!T(B\\)" "$(5$1(B" sanskrit) | |
| 328 ("\\($(5!7!h!3!h!B(B\\)" "$(5$2(B" sanskrit) | |
| 329 ("\\($(5!7!h!3!h!V(B\\)" "$(5$3(B" sanskrit) | |
| 330 ("\\($(5!7!h!3!h!O(B\\)" "$(5$9"q(B") ; Special Rule. May be precomposed font needed. | |
| 331 ("\\($(5!7!h!6!h!O(B\\)" "$(5$4(B" sanskrit) | |
| 332 ("\\($(5!7!h!3!h!M(B\\)" "$(5$5(B" sanskrit) | |
| 333 ("\\($(5!7!h!4!h!M(B\\)" "$(5$6(B" sanskrit) | |
| 334 ("\\($(5!7!h!5!h!M(B\\)" "$(5$7(B" sanskrit) | |
| 335 ("\\($(5!7!h!6!h!M(B\\)" "$(5$8(B" sanskrit) | |
| 336 ("\\($(5!7!h!3(B\\)" "$(5$9(B") | |
| 337 ("\\($(5!7!h!4(B\\)" "$(5$:(B") | |
| 338 ("\\($(5!7!h!5!h!O(B\\)" "$(5$;"q(B") ; Special Rule. May be precomposed font needed. | |
| 339 ("\\($(5!7!h!5(B\\)" "$(5$;(B") | |
| 340 ("\\($(5!7!h!6(B\\)" "$(5$<(B") | |
| 341 ("\\($(5!7!h!7(B\\)" "$(5$=(B") | |
| 342 ("\\($(5!7!h!F(B\\)" "$(5$>(B") | |
| 343 ("\\($(5!7!h!L(B\\)" "$(5$?(B") | |
| 344 ("\\($(5!7!h!M(B\\)" "$(5$@(B") | |
| 345 ("\\($(5!8!h(B\\)[$(5!8!<(B]$(5!h(B" "$(5"8(B") ; Half Form | |
| 346 ("\\($(5!8!h!8(B\\)" "$(5$A(B") | |
| 347 ("\\($(5!8!h!<(B\\)" "$(5$B(B") | |
| 348 ("\\($(5!8!h!O!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"8"q(B") ; Half Form Post "r" | |
| 349 ("\\($(5!8!h!O(B\\)" "$(5!8"q(B") ; Post "r" | |
| 350 ("\\($(5!8!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"8(B") ; Half Form | |
| 351 ("\\($(5!9!h!M(B\\)" "$(5$C(B") | |
| 352 ("\\($(5!:!h!O(B\\)" "$(5$D(B") | |
| 353 ("\\($(5!:!h!<!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"m(B") ; Half Form | |
| 354 ("\\($(5!:!h!<(B\\)" "$(5$E(B") | |
| 355 ("\\($(5!:!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5":(B") ; Half Form | |
| 356 ("\\($(5!:!i!h!O(B\\)" "$(5"!(B") ; Nukta Post "r" | |
| 357 ("\\($(5!:!i!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"z(B") ; Nukta Half Form | |
| 358 ("\\($(5!:!i(B\\)" "$(5#:(B") ; Nukta | |
| 359 ("\\($(5!;!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5";(B") ; Half Form | |
| 360 ("\\($(5!<!h(B\\)$(5!8!h(B[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"<(B") ; Special Half Form | |
| 361 ("\\($(5!<!h!8(B\\)" "$(5$F(B") | |
| 362 ("\\($(5!<!h(B\\)$(5!:!h(B[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"<(B") ; Special Half Form | |
| 363 ("\\($(5!<!h!:(B\\)" "$(5$G(B") | |
| 364 ("\\($(5!<!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"<(B") ; Half Form | |
| 365 ("\\($(5!=!h!3(B\\)" "$(5$H(B") | |
| 366 ("\\($(5!=!h!=(B\\)" "$(5$I(B") | |
| 367 ("\\($(5!=!h!>(B\\)" "$(5$J(B") | |
| 368 ("\\($(5!=!h!M(B\\)" "$(5$K(B") | |
| 369 ("\\($(5!>!h!M(B\\)" "$(5$L(B") | |
| 370 ("\\($(5!?!h!5!h!M(B\\)" "$(5$M(B" sanskrit) | |
| 371 ("\\($(5!?!h!6!h!O(B\\)" "$(5$N(B" sanskrit) | |
| 372 ("\\($(5!?!h!O!h!M(B\\)" "$(5$O(B") | |
| 373 ("\\($(5!?!h!5(B\\)" "$(5$P(B") | |
| 374 ("\\($(5!?!h!6(B\\)" "$(5$Q(B") | |
| 375 ("\\($(5!?!h!?(B\\)" "$(5$R(B") | |
| 376 ("\\($(5!?!h!L(B\\)" "$(5$S(B") | |
| 377 ("\\($(5!?!h!M(B\\)" "$(5$T(B") | |
| 378 ("\\($(5!?!i(B\\)" "$(5#?(B") ; Nukta | |
| 379 ("\\($(5!@!h!M(B\\)" "$(5$`(B") | |
| 380 ("\\($(5!@!i(B\\)" "$(5#@(B") ; Nukta | |
| 381 ("\\($(5!A!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"A(B") ; Half Form | |
| 382 ("\\($(5!B!h(B\\)$(5!B!h!O(B" "$(5"B(B") ; Special Rule for "t-tr" | |
| 383 ("\\($(5!B!h!B!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"c(B") ; Half Form | |
| 384 ("\\($(5!B!h!B(B\\)" "$(5$a(B") | |
| 385 ("\\($(5!B!h!F(B\\)" "$(5$b(B") | |
| 386 ("\\($(5!B!h!O!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"d(B") ; Half Form Post "r" | |
| 387 ("\\($(5!B!h!O(B\\)" "$(5"%(B") ; Post "r" | |
| 388 ("\\($(5!B!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"B(B") ; Half Form | |
| 389 ("\\($(5!C!h!O(B\\)" "$(5!C"q(B") ; Post "r" | |
| 390 ("\\($(5!C!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"C(B") ; Half Form | |
| 391 ("\\($(5!D!h!D!h!M(B\\)" "$(5$c(B") | |
| 392 ("\\($(5!D!h!E!h!M(B\\)" "$(5$d(B") | |
| 393 ("\\($(5!D!h!K!h!M(B\\)" "$(5$e(B") | |
| 394 ("\\($(5!D!h!K!h!O(B\\)" "$(5$r"r(B") ; Special Case for "dbhr" ; *** | |
| 395 ("\\($(5!D!h!O!h!M(B\\)" "$(5$f(B") | |
| 396 ("\\($(5!D!h!T!h!M(B\\)" "$(5$g(B") | |
| 397 ("\\($(5!D!h!5!h!O(B\\)" "$(5$h(B") | |
| 398 ("\\($(5!D!h!6!h!O(B\\)" "$(5$i(B") | |
| 399 ("\\($(5!D!h!D!h!T(B\\)" "$(5$j(B") | |
| 400 ("\\($(5!D!h!E!h!T(B\\)" "$(5$k(B") | |
| 401 ("\\($(5!D!h(B\\)$(5!E!h(B[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5!D!h(B") ; Special Half Form (for ddhra) | |
| 402 ("\\($(5!D!h!5(B\\)" "$(5$l(B") | |
| 403 ("\\($(5!D!h!6(B\\)" "$(5$m(B") | |
| 404 ("\\($(5!D!h!D(B\\)" "$(5$n(B") | |
| 405 ("\\($(5!D!h!E(B\\)" "$(5$o(B") | |
| 406 ("\\($(5!D!h!F(B\\)" "$(5$p(B") | |
| 407 ("\\($(5!D!h(B\\)$(5!J!h(B" "$(5!D!h(B") ; Suppressing "db-" | |
| 408 ("\\($(5!D!h!J(B\\)" "$(5$q(B") | |
| 409 ("\\($(5!D!h!K(B\\)" "$(5$r(B") | |
| 410 ("\\($(5!D!h!L(B\\)" "$(5$s(B") | |
| 411 ("\\($(5!D!h!M(B\\)" "$(5$t(B") | |
| 412 ("\\($(5!D!h!T(B\\)" "$(5$u(B") | |
| 413 ("\\($(5!E!h!F!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"e(B") ; Half Form | |
| 414 ("\\($(5!E!h!F(B\\)" "$(5$v(B") | |
| 415 ("\\($(5!E!h!O!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"f(B") ; Half Form Post "r" | |
| 416 ("\\($(5!E!h!O(B\\)" "$(5!E"q(B") ; Post "r" | |
| 417 ("\\($(5!E!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"E(B") ; Half Form | |
| 418 ("\\($(5!F!h!F!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"k(B") ; Half Form | |
| 419 ("\\($(5!F!h!F(B\\)" "$(5$w(B") | |
| 420 ("\\($(5!F!h!O(B\\)" "$(5!F"q(B") | |
| 421 ("\\($(5!F!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"F(B") ; Half Form | |
| 422 ("\\($(5!G!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"G(B") ; Nukta Half Form | |
| 423 ("\\($(5!H!h(B\\)$(5!B!h!O(B" "$(5"H(B") ; Special Rule for "p-tr" | |
| 424 ("\\($(5!H!h!B!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"g(B") ; Half Form | |
| 425 ("\\($(5!H!h!B(B\\)" "$(5$x(B") | |
| 426 ("\\($(5!H!h!F(B\\)" "$(5$y(B") | |
| 427 ("\\($(5!H!h!Q(B\\)" "$(5$z(B") | |
| 428 ("\\($(5!H!h!O(B\\)" "$(5"&(B") ; Post "r" | |
| 429 ("\\($(5!H!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"H(B") ; Half Form | |
| 430 ("\\($(5!I!h!O(B\\)" "$(5"'(B") ; Post "r" | |
| 431 ("\\($(5!I!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"I(B") ; Half Form | |
| 432 ("\\($(5!I!i!h!O(B\\)" "$(5""(B") ; Nukta Post "r" | |
| 433 ("\\($(5!I!i!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"y(B") ; Nukta Half Form | |
| 434 ("\\($(5!I!i(B\\)" "$(5#I(B") ; Nukta | |
| 435 ("\\($(5!J!h(B\\)$(5!F!h(B[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"J(B") ; Special Half Form | |
| 436 ("\\($(5!J!h!F(B\\)" "$(5${(B") | |
| 437 ("\\($(5!J!h(B\\)$(5!J!h(B[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"J(B") ; Special Half Form | |
| 438 ("\\($(5!J!h!J(B\\)" "$(5$|(B") | |
| 439 ("\\($(5!J!h(B\\)$(5!T!h(B[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"J(B") ; Special Half Form | |
| 440 ("\\($(5!J!h!T(B\\)" "$(5$}(B") | |
| 441 ("\\($(5!J!h!O(B\\)" "$(5!J"q(B") ; Post "r" | |
| 442 ("\\($(5!J!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"J(B") ; Half Form | |
| 443 ("\\($(5!K!h!F(B\\)" "$(5$~(B") | |
| 444 ("\\($(5!K!h!O(B\\)" "$(5!K"q(B") ; Post "r" | |
| 445 ("\\($(5!K!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"K(B") ; Half Form | |
| 446 ("\\($(5!L!h!F(B\\)" "$(5#P(B") | |
| 447 ("\\($(5!L!h!Q(B\\)" "$(5#Q(B") | |
| 448 ("\\($(5!L!h!O(B\\)" "$(5!L"q(B") ; Post "r" | |
| 449 ("\\($(5!L!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"L(B") ; Half Form | |
| 450 ("\\($(5!M!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"M(B") ; Half Form | |
| 451 ("\\($(5!N!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"N(B") ; Half Form | |
| 452 ;; special form for "ru". | |
| 453 ("\\($(5!O!](B\\)" "$(5",(B") | |
| 454 ("\\($(5!O!^(B\\)" "$(5"-(B") | |
| 455 ("\\($(5!P!](B\\)" "$(5".(B") | |
| 456 ("\\($(5!P!^(B\\)" "$(5"/(B") | |
| 457 ;; | |
| 458 ("\\($(5!Q!h!Q(B\\)" "$(5#`(B" sanskrit) | |
| 459 ("\\($(5!Q!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"Q(B") ; Half Form | |
| 460 ("\\($(5!R!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"R(B") ; Half Form | |
| 461 ("\\($(5!S!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"S(B") ; Half Form | |
| 462 ("\\($(5!T!h!F(B\\)" "$(5#a(B") | |
| 463 ("\\($(5!T!h!T(B\\)" "$(5#b(B") | |
| 464 ("\\($(5!T!h!O(B\\)" "$(5!T"q(B") ; Post "r" | |
| 465 ("\\($(5!T!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"T(B") ; Half Form | |
| 466 ("\\($(5!U!h!8!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"h(B") ; Half Form | |
| 467 ("\\($(5!U!h!8(B\\)" "$(5#c(B") | |
| 468 ("\\($(5!U!h!F(B\\)" "$(5#d(B") | |
| 469 ("\\($(5!U!h!J(B\\)" "$(5#e(B") | |
| 470 ("\\($(5!U!h!Q(B\\)" "$(5#f(B") | |
| 471 ("\\($(5!U!h(B\\)$(5!T!h!O(B" "$(5"U(B") ; Special Half Form | |
| 472 ("\\($(5!U!h!T!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"j(B") ; Half Form | |
| 473 ; ("\\($(5!U!h!T(B\\)" "$(5#g(B") | |
| 474 ("\\($(5!U!h!O!h!T(B\\)" "$(5#g(B") | |
| 475 ("\\($(5!U!h!O!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"i(B") ; Half Form | |
| 476 ("\\($(5!U!h!O(B\\)" "$(5")(B") ; Post "r" | |
| 477 ("\\($(5!U!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"U(B") ; Half Form | |
| 478 ("\\($(5!V!h!=!h!O!h!M(B\\)" "$(5#h(B") | |
| 479 ("\\($(5!V!h!=!h!M(B\\)" "$(5#i(B") | |
| 480 ("\\($(5!V!h!=!h!T(B\\)" "$(5#j(B") | |
| 481 ("\\($(5!V!h!=(B\\)" "$(5#k(B") | |
| 482 ("\\($(5!V!h!>(B\\)" "$(5#l(B") | |
| 483 ("\\($(5!V!h!O(B\\)" "$(5!V"q(B") ; Post "r" | |
| 484 ("\\($(5!V!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"V(B") ; Half Form | |
| 485 ("\\($(5!W!h!F!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"W"F(B") ; Special Half Form | |
| 486 ("\\($(5!W!h!F(B\\)" "$(5#m(B") | |
| 487 ("\\($(5!W!h!O(B\\)" "$(5#n(B") | |
| 488 ("\\($(5!W!h(B\\)[$(5!3(B-$(5!N!P(B-$(5!X(B]" "$(5"W(B") ; Half Form | |
| 489 ("\\($(5!X!h!A(B\\)" "$(5#p(B") | |
| 490 ("\\($(5!X!h!F(B\\)" "$(5#q(B") | |
| 491 ("\\($(5!X!h!L(B\\)" "$(5#r(B") | |
| 492 ("\\($(5!X!h!M(B\\)" "$(5#s(B") | |
| 493 ("\\($(5!X!h!O(B\\)" "$(5#t(B") | |
| 494 ("\\($(5!X!h!Q(B\\)" "$(5#u(B") | |
| 495 ("\\($(5!X!h!T(B\\)" "$(5#v(B") | |
| 496 ;; Special Ligature Rules | |
| 497 ("\\($(5!X!_(B\\)" "$(5#R(B") | |
| 498 | |
| 499 ;; For consonants other than listed above, glyph-composition will | |
| 500 ;; be applied. If the consonant which is preceding "$(5!O(B" does not | |
| 501 ;; have the vertical line (such as "$(5!?(B"), "$(5"r(B" is put beneath the | |
| 502 ;; consonant. | |
| 503 ;; | |
| 504 ("[$(5!7!9!=!>!?!@!D!O!P!R!S!X(B]\\($(5!h!O(B\\)" "$(5"r(B") | |
| 505 ("[$(5!6!8!C!E!F!H!J!K!L!M!T!V(B]\\($(5!h!O(B\\)" "$(5"q(B") | |
| 506 ("$(5!?!i(B\\($(5!h!O(B\\)" "$(5"r(B") | |
| 507 ("$(5!@!i(B\\($(5!h!O(B\\)" "$(5"r(B") | |
| 508 | |
| 509 ;; Nukta with Non-Consonants | |
| 510 ("\\($(5!!!i(B\\)" "$(5#!(B") | |
| 511 ("\\($(5!&!i(B\\)" "$(5#&(B") | |
| 512 ("\\($(5!'!i(B\\)" "$(5#'(B") | |
| 513 ("\\($(5!*!i(B\\)" "$(5#*(B") | |
| 514 ("\\($(5 | |
| 526 ) | |
| 527 "Alist of regexps of Devanagari character sequences vs composed characters.") | |
| 528 | |
| 529 (let ((rules devanagari-char-to-glyph-rules)) | |
| 530 (while rules | |
| 531 (let ((rule (car rules)) | |
| 532 (chars) (char) (glyphs) (glyph)) | |
| 533 (setq rules (cdr rules)) | |
| 534 (string-match "\\\\(\\(.+\\)\\\\)" (car rule)) | |
| 535 (setq chars (substring (car rule) (match-beginning 1) (match-end 1))) | |
| 536 (setq char (string-to-char chars)) | |
| 537 (setq glyphs (cdr rule)) | |
| 538 (setq glyph (string-to-char (car glyphs))) | |
| 539 (put-char-code-property | |
| 540 char 'char-to-glyph | |
| 541 ;; We don't "cons" it since priority is top to down. | |
| 542 (append (get-char-code-property char 'char-to-glyph) (list rule))) | |
| 543 | |
| 544 (if (and (< ?(5z(B glyph) ; Glyphs only. | |
| 545 (null (get-char-code-property glyph 'glyph-to-char))) | |
| 546 ; One glyph may corresponds to multiple characters, | |
| 547 ; e.g., surrounding vowel in Tamil, etc. | |
| 548 ; but for Devanagari, we put this restriction | |
| 549 ; to make sure the fact that one glyph corresponds to one char. | |
| 550 (put-char-code-property | |
| 551 glyph 'glyph-to-char | |
| 552 (cons (list (car glyphs) chars) | |
| 553 (get-char-code-property glyph 'glyph-to-char) | |
| 554 )))))) | |
| 555 | |
| 556 ;; | |
| 557 ;; Function used in both characters-to-glyphs conversion and | |
| 558 ;; glyphs-to-characters conversion. | |
| 559 ;; | |
| 560 | |
| 561 (defun max-match-len (regexp) | |
| 562 "Return the maximum length of text that can match the pattern REGEXP. | |
| 563 Only [...] pattern of regexp is recognized." | |
| 564 (let ((len 0) | |
| 565 (index 0)) | |
| 566 (while (string-match "\\[\\([^\]]\\)+\\]" regexp index) | |
| 567 (setq len (+ len (- (match-beginning 0) index) 1) | |
| 568 index (match-end 0))) | |
| 569 len)) | |
| 570 | |
| 571 ;; Return t iff at least one member appears in both LIST1 and LIST2. | |
| 572 (defun intersecting-p (list1 list2) | |
| 573 (let ((found nil)) | |
| 574 (while (and list1 (not found)) | |
| 575 (if (memq (car list1) list2) | |
| 576 (setq found t) | |
| 577 (setq list1 (cdr list1)))) | |
| 578 found)) | |
| 579 | |
| 580 (defun string-conversion-by-rule (source symbol &rest specs) | |
| 581 "Convert string SOURCE by rules stored in SYMBOL property of each character. | |
| 582 The remaining arguments forms a list SPECS that restricts applicable rules. | |
| 583 | |
| 584 The rules has the form ((REGEXP STR RULE-SPEC ...) ...). | |
| 585 Each character sequence in STRING that matches REGEXP is | |
| 586 replaced by STR. | |
| 587 | |
| 588 If SPECS is nil, only rules with no RULE-SPECs is applied. Otherwise | |
| 589 rules with no RULE-SPECS and rules that have at least one member of | |
| 590 SPECS in RULE-SPECs is applied. | |
| 591 | |
| 592 Rules are tested in the order of the list, thus more specific rules | |
| 593 should be placed in front of less specific rules. | |
| 594 | |
| 595 If rule is given in the forms of regexp '...\\(...\\)...', a character | |
| 596 sequence that matches the pattern inside of the parenthesis is the | |
| 597 subject of the match. Otherwise, the entire expression is the subject | |
| 598 of the match." | |
| 599 (let ((pos 0) | |
| 600 (dst-str "")) | |
| 601 (while (< pos (length source)) | |
| 602 (let ((found nil) | |
| 603 (rules (get-char-code-property | |
| 604 (string-to-char | |
| 605 (substring source pos)) symbol))) | |
| 606 (while rules | |
| 607 (let* ((rule (car rules)) | |
| 608 (regexp (car rule)) | |
| 609 (replace-str (car (cdr rule))) | |
| 610 (rule-specs (cdr (cdr rule))) | |
| 611 search-pos) | |
| 612 (if (not (or (null rule-specs) | |
| 613 (intersecting-p specs rule-specs))) | |
| 614 (setq rules (cdr rules)) | |
| 615 (if (null (string-match "\\\\(.+\\\\)" regexp)) | |
| 616 (progn | |
| 617 (setq regexp (concat "\\(" regexp "\\)")) | |
| 618 (setq search-pos pos)) | |
| 619 (setq search-pos (- pos (max-match-len | |
| 620 (substring regexp | |
| 621 (string-match "^[^\\\\]*" regexp) | |
| 622 (match-end 0)))))) | |
| 623 (if (< search-pos 0) (setq search-pos 0)) | |
| 624 (if (string-match regexp source search-pos) | |
| 625 (if (= (match-beginning 1) pos) | |
| 626 (progn | |
| 627 (setq dst-str (concat dst-str replace-str)) | |
| 628 (setq rules nil) ; Get out of the loop. | |
| 629 (setq found t) | |
| 630 ;; proceed `pos' for replaced characters. | |
| 631 (setq pos (match-end 1))) | |
| 632 (setq rules (cdr rules))) | |
| 633 (setq rules (cdr rules)))))) | |
| 634 ;; proceed to next position | |
| 635 (if (not found) | |
| 636 (setq dst-str (concat dst-str (substring source pos (1+ pos))) | |
| 637 pos (1+ pos))))) | |
| 638 dst-str)) | |
| 639 | |
| 640 | |
| 641 ;; | |
| 642 ;; Convert Character Code to Glyph Code | |
| 643 ;; | |
| 644 | |
| 645 ;;;###autoload | |
| 646 (defun char-to-glyph-devanagari (string &rest langs) | |
| 647 "Convert Devanagari characters in STRING to Devanagari glyphs. | |
| 648 Ligatures and special rules are processed." | |
| 649 (apply | |
| 650 'string-conversion-by-rule | |
| 651 (append (list string 'char-to-glyph) langs))) | |
| 652 | |
| 653 ;; Example: | |
| 654 ;;(char-to-glyph-devanagari "$(5!X) | |
| 729 (?$(5!^(B 0 (br . tr)) | |
| 730 (?$(5!_(B 0 (br . tr)) | |
| 731 (?$(5!`(B 0 (mr . mr)) ; (tc . bc) | |
| 732 (?$(5!a(B 0 (mr . mr)) | |
| 733 (?$(5!b(B 0 (mr . mr)) | |
| 734 (?$(5!c(B 0 (mr . mr)) | |
| 735 (?$(5!d(B 0) | |
| 736 (?$(5!e(B 0) | |
| 737 (?$(5!f(B 0) | |
| 738 (?$(5!g(B 0) | |
| 739 (?$(5!h(B 0 (br . tr)) | |
| 740 (?$(5!i(B 0 (br . tr)) | |
| 741 (?$(5!j(B 0) | |
| 742 (nil 0) | |
| 743 (nil 0) | |
| 744 (nil 0) | |
| 745 (nil 0) | |
| 746 (nil 0) | |
| 747 (nil 0) | |
| 748 (?$(5!q(B 0) | |
| 749 (?$(5!r(B 0) | |
| 750 (?$(5!s(B 0) | |
| 751 (?$(5!t(B 0) | |
| 752 (?$(5!u(B 0) | |
| 753 (?$(5!v(B 0) | |
| 754 (?$(5!w(B 0) | |
| 755 (?$(5!x(B 0) | |
| 756 (?$(5!y(B 0) | |
| 757 (?$(5!z(B 0) | |
| 758 (nil 0) | |
| 759 (nil 0) | |
| 760 (nil 0) | |
| 761 (nil 0) | |
| 762 (?$(5"!(B 0) | |
| 763 (?$(5""(B 0) | |
| 764 (?$(5"#(B 0) | |
| 765 (?$(5"$(B 0) | |
| 766 (?$(5"%(B 0) | |
| 767 (?$(5"&(B 0) | |
| 768 (?$(5"'(B 0) | |
| 769 (?$(5"((B 0) | |
| 770 (?$(5")(B 0) | |
| 771 (?$(5"*(B 0) | |
| 772 (?$(5"+(B 0) | |
| 773 (?$(5",(B 0) | |
| 774 (?$(5"-(B 0) | |
| 775 (?$(5".(B 0) | |
| 776 (?$(5"/(B 0) | |
| 777 (?$(5"0(B 0) | |
| 778 (?$(5"1(B 0) | |
| 779 (?$(5"2(B 0) | |
| 780 (?$(5"3(B 0) | |
| 781 (?$(5"4(B 0) | |
| 782 (?$(5"5(B 0) | |
| 783 (?$(5"6(B 0) | |
| 784 (?$(5"7(B 0) | |
| 785 (?$(5"8(B 0) | |
| 786 (?$(5"9(B 0) | |
| 787 (?$(5":(B 0) | |
| 788 (?$(5";(B 0) | |
| 789 (?$(5"<(B 0) | |
| 790 (?$(5"=(B 0) | |
| 791 (?$(5">(B 0) | |
| 792 (?$(5"?(B 0) | |
| 793 (?$(5"@(B 0) | |
| 794 (?$(5"A(B 0) | |
| 795 (?$(5"B(B 0) | |
| 796 (?$(5"C(B 0) | |
| 797 (?$(5"D(B 0) | |
| 798 (?$(5"E(B 0) | |
| 799 (?$(5"F(B 0) | |
| 800 (?$(5"G(B 0) | |
| 801 (?$(5"H(B 0) | |
| 802 (?$(5"I(B 0) | |
| 803 (?$(5"J(B 0) | |
| 804 (?$(5"K(B 0) | |
| 805 (?$(5"L(B 0) | |
| 806 (?$(5"M(B 0) | |
| 807 (?$(5"N(B 0) | |
| 808 (?$(5"O(B 0) | |
| 809 (?$(5"P(B 0) | |
| 810 (?$(5"Q(B 0) | |
| 811 (?$(5"R(B 0) | |
| 812 (?$(5"S(B 0) | |
| 813 (?$(5"T(B 0) | |
| 814 (?$(5"U(B 0) | |
| 815 (?$(5"V(B 0) | |
| 816 (?$(5"W(B 0) | |
| 817 (?$(5"X(B 0) | |
| 818 (?$(5"Y(B 0) | |
| 819 (?$(5"Z(B 0) | |
| 820 (?$(5"[(B 0) | |
| 821 (?$(5"\(B 0) | |
| 822 (?$(5"](B 0) | |
| 823 (?$(5"^(B 0) | |
| 824 (?$(5"_(B 0) | |
| 825 (?$(5"`(B 0) | |
| 826 (?$(5"a(B 0) | |
| 827 (?$(5"b(B 0) | |
| 828 (?$(5"c(B 0) | |
| 829 (?$(5"d(B 0) | |
| 830 (?$(5"e(B 0) | |
| 831 (?$(5"f(B 0) | |
| 832 (?$(5"g(B 0) | |
| 833 (?$(5"h(B 0) | |
| 834 (?$(5"i(B 0) | |
| 835 (?$(5"j(B 0) | |
| 836 (?$(5"k(B 0) | |
| 837 (?$(5"l(B 0) | |
| 838 (?$(5"m(B 0) | |
| 839 (?$(5"n(B 0) | |
| 840 (?$(5"o(B 0) | |
| 841 (?$(5"p(B 10 (mr . mr)) | |
| 842 (?$(5"q(B 0 (br . br)) | |
| 843 (?$(5"r(B 0 (br . tr)) | |
| 844 (?$(5"s(B 0) | |
| 845 (?$(5"t(B 0) | |
| 846 (?$(5"u(B 0) | |
| 847 (?$(5"v(B 0) | |
| 848 (?$(5"w(B 0) | |
| 849 (?$(5"x(B 0) | |
| 850 (?$(5"y(B 0) | |
| 851 (?$(5"z(B 0) | |
| 852 (?$(5"{(B 0) | |
| 853 (?$(5"|(B 0) | |
| 854 (?$(5"}(B 0) | |
| 855 (?$(5"~(B 0) | |
| 856 (?$(5#!(B 0) | |
| 857 (?$(5#"(B 0) | |
| 858 (?$(5##(B 0) | |
| 859 (?$(5#$(B 0) | |
| 860 (?$(5#%(B 0) | |
| 861 (?$(5#&(B 0) | |
| 862 (?$(5#'(B 0) | |
| 863 (?$(5#((B 0) | |
| 864 (?$(5#)(B 0) | |
| 865 (?$(5#*(B 0) | |
| 866 (?$(5#+(B 0) | |
| 867 (?$(5#,(B 0) | |
| 868 (?$(5#-(B 0) | |
| 869 (?$(5#.(B 0) | |
| 870 (?$(5#/(B 0) | |
| 871 (?$(5#0(B 0) | |
| 872 (?$(5#1(B 0) | |
| 873 (?$(5#2(B 0) | |
| 874 (?$(5#3(B 0) | |
| 875 (?$(5#4(B 0) | |
| 876 (?$(5#5(B 0) | |
| 877 (?$(5#6(B 0) | |
| 878 (?$(5#7(B 0) | |
| 879 (?$(5#8(B 0) | |
| 880 (?$(5#9(B 0) | |
| 881 (?$(5#:(B 0) | |
| 882 (?$(5#;(B 0) | |
| 883 (?$(5#<(B 0) | |
| 884 (?$(5#=(B 0) | |
| 885 (?$(5#>(B 0) | |
| 886 (?$(5#?(B 0) | |
| 887 (?$(5#@(B 0) | |
| 888 (?$(5#A(B 0) | |
| 889 (?$(5#B(B 0) | |
| 890 (?$(5#C(B 0) | |
| 891 (?$(5#D(B 0) | |
| 892 (?$(5#E(B 0) | |
| 893 (?$(5#F(B 0) | |
| 894 (?$(5#G(B 0) | |
| 895 (?$(5#H(B 0) | |
| 896 (?$(5#I(B 0) | |
| 897 (?$(5#J(B 0) | |
| 898 (?$(5#K(B 0 (br . tr)) | |
| 899 (?$(5#L(B 0 (br . tr)) | |
| 900 (?$(5#M(B 0 (br . tr)) | |
| 901 (?$(5#N(B 0) | |
| 902 (?$(5#O(B 0) | |
| 903 (?$(5#P(B 0) | |
| 904 (?$(5#Q(B 0) | |
| 905 (?$(5#R(B 0) | |
| 906 (?$(5#S(B 0) | |
| 907 (?$(5#T(B 0) | |
| 908 (?$(5#U(B 0) | |
| 909 (?$(5#V(B 0) | |
| 910 (?$(5#W(B 0) | |
| 911 (?$(5#X(B 0) | |
| 912 (?$(5#Y(B 0) | |
| 913 (?$(5#Z(B 0) | |
| 914 (?$(5#[(B 0) | |
| 915 (?$(5#\(B 0) | |
| 916 (?$(5#](B 0) | |
| 917 (?$(5#^(B 0) | |
| 918 (?$(5#_(B 0) | |
| 919 (?$(5#`(B 0) | |
| 920 (?$(5#a(B 0) | |
| 921 (?$(5#b(B 0) | |
| 922 (?$(5#c(B 0) | |
| 923 (?$(5#d(B 0) | |
| 924 (?$(5#e(B 0) | |
| 925 (?$(5#f(B 0) | |
| 926 (?$(5#g(B 0) | |
| 927 (?$(5#h(B 0) | |
| 928 (?$(5#i(B 0) | |
| 929 (?$(5#j(B 0) | |
| 930 (?$(5#k(B 0) | |
| 931 (?$(5#l(B 0) | |
| 932 (?$(5#m(B 0) | |
| 933 (?$(5#n(B 0) | |
| 934 (?$(5#o(B 0) | |
| 935 (?$(5#p(B 0) | |
| 936 (?$(5#q(B 0) | |
| 937 (?$(5#r(B 0) | |
| 938 (?$(5#s(B 0) | |
| 939 (?$(5#t(B 0) | |
| 940 (?$(5#u(B 0) | |
| 941 (?$(5#v(B 0) | |
| 942 (?$(5#w(B 0) | |
| 943 (?$(5#x(B 0) | |
| 944 (?$(5#y(B 0) | |
| 945 (?$(5#z(B 0) | |
| 946 (?$(5#{(B 0) | |
| 947 (?$(5#|(B 0) | |
| 948 (?$(5#}(B 0) | |
| 949 (?$(5#~(B 0) | |
| 950 (?$(5$!(B 0) | |
| 951 (?$(5$"(B 0) | |
| 952 (?$(5$#(B 0) | |
| 953 (?$(5$$(B 0) | |
| 954 (?$(5$%(B 0) | |
| 955 (?$(5$&(B 0) | |
| 956 (?$(5$'(B 0) | |
| 957 (?$(5$((B 0) | |
| 958 (?$(5$)(B 0) | |
| 959 (?$(5$*(B 0) | |
| 960 (?$(5$+(B 0) | |
| 961 (?$(5$,(B 0) | |
| 962 (?$(5$-(B 0) | |
| 963 (?$(5$.(B 0) | |
| 964 (?$(5$/(B 0) | |
| 965 (?$(5$0(B 0) | |
| 966 (?$(5$1(B 0) | |
| 967 (?$(5$2(B 0) | |
| 968 (?$(5$3(B 0) | |
| 969 (?$(5$4(B 0) | |
| 970 (?$(5$5(B 0) | |
| 971 (?$(5$6(B 0) | |
| 972 (?$(5$7(B 0) | |
| 973 (?$(5$8(B 0) | |
| 974 (?$(5$9(B 0) | |
| 975 (?$(5$:(B 0) | |
| 976 (?$(5$;(B 0) | |
| 977 (?$(5$<(B 0) | |
| 978 (?$(5$=(B 0) | |
| 979 (?$(5$>(B 0) | |
| 980 (?$(5$?(B 0) | |
| 981 (?$(5$@(B 0) | |
| 982 (?$(5$A(B 0) | |
| 983 (?$(5$B(B 0) | |
| 984 (?$(5$C(B 0) | |
| 985 (?$(5$D(B 0) | |
| 986 (?$(5$E(B 0) | |
| 987 (?$(5$F(B 0) | |
| 988 (?$(5$G(B 0) | |
| 989 (?$(5$H(B 0) | |
| 990 (?$(5$I(B 0) | |
| 991 (?$(5$J(B 0) | |
| 992 (?$(5$K(B 0) | |
| 993 (?$(5$L(B 0) | |
| 994 (?$(5$M(B 0) | |
| 995 (?$(5$N(B 0) | |
| 996 (?$(5$O(B 0) | |
| 997 (?$(5$P(B 0) | |
| 998 (?$(5$Q(B 0) | |
| 999 (?$(5$R(B 0) | |
| 1000 (?$(5$S(B 0) | |
| 1001 (?$(5$T(B 0) | |
| 1002 (?$(5$U(B 0) | |
| 1003 (?$(5$V(B 0) | |
| 1004 (?$(5$W(B 0) | |
| 1005 (?$(5$X(B 0) | |
| 1006 (?$(5$Y(B 0) | |
| 1007 (?$(5$Z(B 0) | |
| 1008 (?$(5$[(B 0) | |
| 1009 (?$(5$\(B 0) | |
| 1010 (?$(5$](B 0) | |
| 1011 (?$(5$^(B 0) | |
| 1012 (?$(5$_(B 0) | |
| 1013 (?$(5$`(B 0) | |
| 1014 (?$(5$a(B 0) | |
| 1015 (?$(5$b(B 0) | |
| 1016 (?$(5$c(B 0) | |
| 1017 (?$(5$d(B 0) | |
| 1018 (?$(5$e(B 0) | |
| 1019 (?$(5$f(B 0) | |
| 1020 (?$(5$g(B 0) | |
| 1021 (?$(5$h(B 0) | |
| 1022 (?$(5$i(B 0) | |
| 1023 (?$(5$j(B 0) | |
| 1024 (?$(5$k(B 0) | |
| 1025 (?$(5$l(B 0) | |
| 1026 (?$(5$m(B 0) | |
| 1027 (?$(5$n(B 0) | |
| 1028 (?$(5$o(B 0) | |
| 1029 (?$(5$p(B 0) | |
| 1030 (?$(5$q(B 0) | |
| 1031 (?$(5$r(B 0) | |
| 1032 (?$(5$s(B 0) | |
| 1033 (?$(5$t(B 0) | |
| 1034 (?$(5$u(B 0) | |
| 1035 (?$(5$v(B 0) | |
| 1036 (?$(5$w(B 0) | |
| 1037 (?$(5$x(B 0) | |
| 1038 (?$(5$y(B 0) | |
| 1039 (?$(5$z(B 0) | |
| 1040 (?$(5${(B 0) | |
| 1041 (?$(5$|(B 0) | |
| 1042 (?$(5$}(B 0) | |
| 1043 (?$(5$~(B 0) | |
| 1044 )) | |
| 1045 | |
| 1046 ;; Determine composition priority and rule of the array of Glyphs. | |
| 1047 ;; Sort the glyphs with their priority. | |
| 1048 | |
| 1049 (defun devanagari-reorder-glyphs-for-composition (string start end) | |
| 1050 (let ((pos start) | |
| 1051 (ordered-glyphs nil)) | |
| 1052 (while (< pos end) | |
| 1053 (let ((glyph (aref string pos))) | |
| 1054 (setq pos (1+ pos)) | |
| 1055 (setq ordered-glyphs | |
| 1056 (append ordered-glyphs | |
| 1057 (list (assq glyph devanagari-composition-rules)))))) | |
|
5363
311f6817efc2
Remove various redundant wrapper lambdas, core lisp.
Aidan Kehoe <kehoea@parhasard.net>
parents:
4021
diff
changeset
|
1058 (sort* ordered-glyphs '< :key 'cadr))) |
| 771 | 1059 ;;(devanagari-compose-to-one-glyph "$(5"5!X![(B") => "4$(6!Xv#"5t%![0!X"5![1(B" |
| 1060 | |
| 1061 (defun devanagari-compose-to-one-glyph (devanagari-string) | |
| 1062 (let* ((o-glyph-list (devanagari-reorder-glyphs-for-composition | |
| 1063 devanagari-string 0 (length devanagari-string))) | |
| 1064 ;; List of glyphs to be composed. | |
| 1065 (cmp-glyph-list (list (car (car o-glyph-list)))) | |
| 1066 (o-glyph-list (cdr o-glyph-list))) | |
| 1067 (while o-glyph-list | |
| 1068 (let* ((o-glyph (car o-glyph-list)) | |
| 1069 (glyph (if (< 2 (length o-glyph)) | |
| 1070 ;; default composition | |
| 1071 (list (car (cdr (cdr o-glyph))) (car o-glyph)) | |
| 1072 ;; composition with a specified rule | |
| 1073 (list '(mr . ml) (car o-glyph))))) | |
| 1074 (setq o-glyph-list (cdr o-glyph-list)) | |
| 1075 (setq cmp-glyph-list (append cmp-glyph-list glyph)))) | |
| 1076 ;; Before applying compose-chars, convert glyphs to | |
| 1077 ;; 1-column width if possible. | |
| 1078 (setq cmp-glyph-list (devanagari-wide-to-narrow cmp-glyph-list)) | |
|
5366
f00192e1cd49
Examining the result of #'length: `eql', not `=', it's better style & cheaper
Aidan Kehoe <kehoea@parhasard.net>
parents:
5363
diff
changeset
|
1079 (if (eql (length cmp-glyph-list) 1) (char-to-string (car cmp-glyph-list)) |
| 771 | 1080 (apply 'compose-chars cmp-glyph-list)))) |
| 1081 | |
| 1082 (defun devanagari-composition-component (string &optional start end) | |
| 1083 (or start (setq start 0)) | |
| 1084 (or end (setq end (length string))) | |
| 1085 (let* ((o-glyph-list (devanagari-reorder-glyphs-for-composition | |
| 1086 string start end)) | |
| 1087 ;; List of glyphs to be composed. | |
| 1088 (cmp-glyph-list (list (car (car o-glyph-list))))) | |
| 1089 (setq o-glyph-list (cdr o-glyph-list)) | |
| 1090 (while o-glyph-list | |
| 1091 (let* ((o-glyph (car o-glyph-list)) | |
| 1092 (glyph (if (< 2 (length o-glyph)) | |
| 1093 ;; default composition | |
| 1094 (list (car (cdr (cdr o-glyph))) (car o-glyph)) | |
| 1095 ;; composition with a specified rule | |
| 1096 (list '(mr . ml) (car o-glyph))))) | |
| 1097 (setq o-glyph-list (cdr o-glyph-list)) | |
| 1098 (setq cmp-glyph-list (append cmp-glyph-list glyph)))) | |
| 1099 ;; Convert glyphs to 1-column width if possible. | |
| 1100 (devanagari-wide-to-narrow cmp-glyph-list))) | |
| 1101 | |
| 1102 ;; Utility function for Phase 2.5 | |
| 1103 | |
| 1104 ;; Check whether GLYPH is a Devanagari vertical modifier or not. | |
| 1105 ;; If it is a vertical modifier, whether it should be 1-column shape or not | |
| 1106 ;; depends on previous non-vertical modifier. | |
| 1107 (defun devanagari-vertical-modifier-p (glyph) | |
| 1108 (string-match (char-to-string glyph) | |
| 1109 "[$(5!"!]!^!_!`!a!b!c!h!i"p"q"r#K#L#M(B]")) | |
| 1110 | |
| 1111 (defun devanagari-non-vertical-modifier-p (glyph) | |
| 1112 (string-match (char-to-string glyph) | |
| 1113 ; "[$(5!Z![!\!d!e!f!g(B]")) | |
| 1114 "[$(5![(B]")) | |
| 1115 | |
| 1116 (defun devanagari-wide-to-narrow-char (char) | |
| 1117 "Convert Devanagari character CHAR to the corresponding narrow character. | |
| 1118 If there's no corresponding narrow character, return CHAR as is." | |
| 1119 (let ((narrow (cdr (assq char devanagari-1-column-char)))) | |
| 1120 (or narrow char))) | |
| 1121 | |
| 1122 ;; | |
| 1123 ;; Phase 2.5 Convert appropriate character to 1-column shape. | |
| 1124 ;; | |
| 1125 ;; This is temporary and should be removed out when Emacs supports | |
| 1126 ;; variable width characters. | |
| 1127 ;; | |
| 1128 ;; This will convert the composing glyphs (2 column glyphs) | |
| 1129 ;; to narrow (1 column) glyphs if they exist. | |
| 1130 ;; | |
| 1131 ;; devanagari-wide-to-narrow-old converts glyphs simply. | |
| 1132 ;; devanagari-wide-to-narrow takes care of upper/lower apply-glyphs | |
| 1133 ;; with 2 column base-glyph. | |
| 1134 ;; | |
| 1135 ;; Execution Examples | |
| 1136 ;;(devanagari-wide-to-narrow '(?$(5!3(B (ml . ml) ?$(5!a(B)) | |
| 1137 ;;(devanagari-wide-to-narrow '(?$(5!F(B (ml . ml) ?$(5!a(B)) | |
| 1138 | |
| 1139 (defun devanagari-wide-to-narrow (src-list) | |
| 1140 (devanagari-wide-to-narrow-iter src-list t)) | |
| 1141 | |
| 1142 (defun devanagari-wide-to-narrow-iter (src-list 2-col-glyph) | |
| 1143 (let ((glyph (car src-list))) | |
| 1144 (cond ((null src-list) '()) | |
| 1145 ; not glyph code | |
| 1146 ((not (numberp glyph)) | |
| 1147 (cons glyph | |
| 1148 (devanagari-wide-to-narrow-iter (cdr src-list) 2-col-glyph))) | |
| 1149 ; glyphs to be processed regardless of the value of "2-col-glyph" | |
| 1150 ((devanagari-non-vertical-modifier-p glyph) | |
| 1151 (cons (devanagari-wide-to-narrow-char glyph) | |
| 1152 (devanagari-wide-to-narrow-iter (cdr src-list) 2-col-glyph))) | |
| 1153 ; glyphs which are depends on the value of "2-col-glyph" | |
| 1154 ((devanagari-vertical-modifier-p glyph) | |
| 1155 (if 2-col-glyph | |
| 1156 (cons glyph | |
| 1157 (devanagari-wide-to-narrow-iter (cdr src-list) t)) | |
| 1158 (cons (devanagari-wide-to-narrow-char glyph) | |
| 1159 (devanagari-wide-to-narrow-iter (cdr src-list) | |
| 1160 2-col-glyph)))) | |
| 1161 ; normal glyph | |
| 1162 (t | |
| 1163 (if (cdr (assq glyph devanagari-1-column-char)) | |
| 1164 (cons (devanagari-wide-to-narrow-char glyph) | |
| 1165 (devanagari-wide-to-narrow-iter (cdr src-list) nil)) | |
| 1166 (cons glyph | |
| 1167 (devanagari-wide-to-narrow-iter (cdr src-list) t))))))) | |
| 1168 | |
| 1169 | |
| 1170 ;; | |
| 1171 ;; Summary | |
| 1172 ;; | |
| 1173 | |
| 1174 ;; | |
| 1175 ;; Decomposition of composite sequence. | |
| 1176 ;; | |
| 1177 | |
| 1178 ;;;###autoload | |
| 1179 (defun devanagari-decompose-string (str) | |
| 1180 "Decompose Devanagari string STR" | |
| 1181 (decompose-string (copy-sequence str))) | |
| 1182 | |
| 1183 ;;;###autoload | |
| 1184 (defun devanagari-decompose-region (from to) | |
| 1185 (interactive "r") | |
| 1186 (decompose-region from to)) | |
| 1187 | |
| 1188 ;;; | |
| 1189 ;;; Composition | |
| 1190 ;;; | |
| 1191 | |
| 1192 ;;;###autoload | |
| 1193 (defun devanagari-compose-string (str &rest langs) | |
| 1194 (setq str (copy-sequence str)) | |
| 1195 (let ((idx 0) | |
| 788 | 1196 ;rest match-b match-e |
| 1197 ) | |
| 771 | 1198 (while (string-match devanagari-composite-glyph-unit str idx) |
| 1199 (let* ((match-b (match-beginning 0)) | |
| 1200 (match-e (match-end 0)) | |
| 1201 (cmps (devanagari-composition-component | |
| 1202 (apply | |
| 1203 'char-to-glyph-devanagari | |
| 1204 (cons (substring str match-b match-e) langs))))) | |
| 1205 (compose-string str match-b match-e cmps) | |
| 1206 (setq idx match-e)))) | |
| 1207 str) | |
| 1208 | |
| 1209 ;;;###autoload | |
| 1210 (defun devanagari-compose-region (from to &rest langs) | |
| 1211 (interactive "r") | |
| 1212 (save-excursion | |
| 1213 (save-restriction | |
| 1214 (narrow-to-region from to) | |
| 1215 (goto-char (point-min)) | |
| 1216 (while (re-search-forward devanagari-composite-glyph-unit nil t) | |
| 1217 (let* ((match-b (match-beginning 0)) (match-e (match-end 0)) | |
| 1218 (cmps (devanagari-composition-component | |
| 1219 (apply | |
| 1220 'char-to-glyph-devanagari | |
| 1221 (cons (buffer-substring match-b match-e) langs))))) | |
| 1222 (compose-region match-b match-e cmps)))))) | |
| 1223 | |
| 1224 ;; For pre-write and post-read conversion | |
| 1225 | |
| 1226 ;;;###autoload | |
| 1227 (defun devanagari-compose-from-is13194-region (from to) | |
| 1228 "Compose IS 13194 characters in the region to Devanagari characters." | |
| 1229 (interactive "r") | |
| 1230 (save-excursion | |
| 1231 (save-restriction | |
| 1232 (narrow-to-region from to) | |
| 1233 (indian-to-devanagari-region (point-min) (point-max)) | |
| 1234 (devanagari-compose-region (point-min) (point-max)) | |
| 1235 (- (point-max) (point-min))))) | |
| 1236 | |
| 1237 ;;;###autoload | |
| 1238 (defun in-is13194-devanagari-post-read-conversion (len) | |
| 1239 (let ((pos (point))) | |
| 1240 (devanagari-compose-from-is13194-region pos (+ pos len)))) | |
| 1241 | |
| 1242 ;;;###autoload | |
| 1243 (defun devanagari-decompose-to-is13194-region (from to) | |
| 1244 "Decompose Devanagari characters in the region to IS 13194 characters." | |
| 1245 (interactive "r") | |
| 1246 (save-excursion | |
| 1247 (save-restriction | |
| 1248 (narrow-to-region from to) | |
| 1249 (devanagari-decompose-region (point-min) (point-max)) | |
| 1250 (devanagari-to-indian-region (point-min) (point-max))))) | |
| 1251 | |
| 1252 ;;;###autoload | |
| 1253 (defun in-is13194-devanagari-pre-write-conversion (from to) | |
| 1254 (let ((old-buf (current-buffer))) | |
| 1255 (set-buffer (generate-new-buffer " *temp*")) | |
| 1256 (if (stringp from) | |
| 1257 (insert from) | |
| 1258 (insert-buffer-substring old-buf from to)) | |
| 1259 (devanagari-decompose-to-is13194-region (point-min) (point-max)) | |
| 1260 ;; Should return nil as annotations. | |
| 1261 nil)) | |
| 1262 | |
| 1263 ;; For input/output of ITRANS | |
| 1264 | |
| 1265 ;;;###autoload | |
| 1266 (defun devanagari-encode-itrans-region (from to) | |
| 1267 (interactive "r") | |
| 1268 (save-restriction | |
| 1269 (narrow-to-region from to) | |
| 1270 (devanagari-decompose-to-is13194-region (point-min) (point-max)) | |
| 1271 (indian-encode-itrans-region (point-min) (point-max)))) | |
| 1272 | |
| 1273 ;;;###autoload | |
| 1274 (defun devanagari-decode-itrans-region (from to) | |
| 1275 (interactive "r") | |
| 1276 (save-restriction | |
| 1277 (narrow-to-region from to) | |
| 1278 (indian-decode-itrans-region (point-min) (point-max)) | |
| 1279 (devanagari-compose-from-is13194-region (point-min) (point-max)))) | |
| 1280 | |
| 1281 ;; | |
| 1282 (provide 'devan-util) | |
| 1283 | |
| 1284 ;; Local Variables: | |
| 1285 ;; coding: iso-2022-7bit | |
| 1286 ;; End: | |
| 778 | 1287 |
| 1288 ;;; devan-util.el end here |
