Mercurial > emacs
comparison lisp/language/devan-util.el @ 21442:b598d28da979
Typos in comment fixed.
(devanagari-vertical-modifier-p): Target string to be matched with
GLYPH is modified.
(devanagari-non-vertical-modifier-p): Likewise.
(devanagari-wide-to-narrow-char): New function.
(devanagari-wide-to-narrow-iter): The second arg is changed to
2-COL-GLYPH.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Thu, 09 Apr 1998 05:39:41 +0000 |
parents | e933240ee6c0 |
children | 901451c61b3f |
comparison
equal
deleted
inserted
replaced
21441:dec2ca6d662d | 21442:b598d28da979 |
---|---|
25 | 25 |
26 ;;; Commentary: | 26 ;;; Commentary: |
27 | 27 |
28 ;; History: | 28 ;; History: |
29 ;; 1996.10.18 written by KAWABATA, Taichi <kawabata@is.s.u-tokyo.ac.jp> | 29 ;; 1996.10.18 written by KAWABATA, Taichi <kawabata@is.s.u-tokyo.ac.jp> |
30 ;; 1997.1.20 fixed some bugs. | |
31 ;; 1997.3.24 fixed some bugs. | 30 ;; 1997.3.24 fixed some bugs. |
32 | 31 |
33 ;; Future work :: | 32 ;; Future work :: |
34 ;; Decompose the input characters and process them on the character basis. | 33 ;; Decompose the input characters and process them on the character basis. |
35 | 34 |
157 ;; This is acceptable BEFORE proper consonant-syllable is input. The | 156 ;; This is acceptable BEFORE proper consonant-syllable is input. The |
158 ;; string which doesn't match with the above expression is invalid and | 157 ;; string which doesn't match with the above expression is invalid and |
159 ;; thus must be fixed. | 158 ;; thus must be fixed. |
160 ;; | 159 ;; |
161 ;; Note: | 160 ;; Note: |
162 ;; Third case can be considered, which is acceptable syllable and can | 161 ;; Third case can be considered, which is an acceptable syllable and can |
163 ;; not add any code more. | 162 ;; not add any code more. |
164 ;; | 163 ;; |
165 ;; [[C [N] H] [C [N] H] [C [N] H] C [N] H] C [N] [M] D | 164 ;; [[C [N] H] [C [N] H] [C [N] H] C [N] H] C [N] [M] D |
166 ;; | 165 ;; |
167 ;; However, to make editing possible even in this condition, we will | 166 ;; However, to make editing possible even in this condition, we will |
277 ;; | 276 ;; |
278 ;; TO DO: | 277 ;; TO DO: |
279 ;; Prepare multiple specific list of rules for each languages | 278 ;; Prepare multiple specific list of rules for each languages |
280 ;; which adopts Devanagari script. | 279 ;; which adopts Devanagari script. |
281 ;; | 280 ;; |
282 | |
283 | 281 |
284 (defconst devanagari-char-to-glyph-rules | 282 (defconst devanagari-char-to-glyph-rules |
285 '( | 283 '( |
286 | 284 |
287 ;; `r' at the top of syllable and followed by other consonants. | 285 ;; `r' at the top of syllable and followed by other consonants. |
1083 ;; If it is a vertical modifier, whether it should be 1-column shape or not | 1081 ;; If it is a vertical modifier, whether it should be 1-column shape or not |
1084 ;; depends on previous non-vertical modifier. | 1082 ;; depends on previous non-vertical modifier. |
1085 ; return nil if it is not vertical modifier. | 1083 ; return nil if it is not vertical modifier. |
1086 (defun devanagari-vertical-modifier-p (glyph) | 1084 (defun devanagari-vertical-modifier-p (glyph) |
1087 (string-match (char-to-string glyph) | 1085 (string-match (char-to-string glyph) |
1088 "[$(5!]!^!_!`!a!b!c!h!i"p"q"r#K#L#M(B]")) | 1086 "[$(5!"!]!^!_!`!a!b!c!h!i"p"q"r#K#L#M(B]")) |
1089 | 1087 |
1090 (defun devanagari-non-vertical-modifier-p (glyph) | 1088 (defun devanagari-non-vertical-modifier-p (glyph) |
1091 (string-match (char-to-string glyph) | 1089 (string-match (char-to-string glyph) |
1092 "[$(5!Z![!\!d!e!f!g(B]")) | 1090 ; "[$(5!Z![!\!d!e!f!g(B]")) |
1093 | 1091 "[$(5![(B]")) |
1092 | |
1093 (defun devanagari-wide-to-narrow-char (char) | |
1094 "Return the corresponding narrow character if it exists." | |
1095 (let ((narrow (cdr (assq char devanagari-1-column-char)))) | |
1096 (if narrow narrow char))) | |
1094 | 1097 |
1095 ;; | 1098 ;; |
1096 ;; Phase 2.5 Convert Appropriate Character to 1-column shape. | 1099 ;; Phase 2.5 Convert Appropriate Character to 1-column shape. |
1097 ;; | 1100 ;; |
1098 ;; This is temporary and should be removed out when Emacs supports | 1101 ;; This is temporary and should be removed out when Emacs supports |
1107 ;; | 1110 ;; |
1108 ;; Execution Examples | 1111 ;; Execution Examples |
1109 ;;(devanagari-wide-to-narrow '(?$(5!3(B (ml . ml) ?$(5!a(B)) | 1112 ;;(devanagari-wide-to-narrow '(?$(5!3(B (ml . ml) ?$(5!a(B)) |
1110 ;;(devanagari-wide-to-narrow '(?$(5!F(B (ml . ml) ?$(5!a(B)) | 1113 ;;(devanagari-wide-to-narrow '(?$(5!F(B (ml . ml) ?$(5!a(B)) |
1111 | 1114 |
1112 ;(defun devanagari-wide-to-narrow (src-list) | |
1113 ; (if (null src-list) '() | |
1114 ; (cons | |
1115 ; (if (and (numberp (car src-list)) | |
1116 ; (cdr (assq (car src-list) devanagari-1-column-char))) | |
1117 ; (cdr (assq (car src-list) devanagari-1-column-char)) | |
1118 ; (car src-list)) | |
1119 ; (devanagari-wide-to-narrow (cdr src-list))))) | |
1120 | |
1121 (defun devanagari-wide-to-narrow (src-list) | 1115 (defun devanagari-wide-to-narrow (src-list) |
1122 (devanagari-wide-to-narrow-iter src-list t)) | 1116 (devanagari-wide-to-narrow-iter src-list t)) |
1123 | 1117 |
1124 (defun devanagari-wide-to-narrow-iter (src-list wide-p) | 1118 (defun devanagari-wide-to-narrow-iter (src-list 2-col-glyph) |
1125 (let ((glyph (car src-list))) | 1119 (let ((glyph (car src-list))) |
1126 (cond ((null src-list) '()) | 1120 (cond ((null src-list) '()) |
1127 ; not glyph code | 1121 ; not glyph code |
1128 ((not (numberp glyph)) | 1122 ((not (numberp glyph)) |
1129 (cons glyph (devanagari-wide-to-narrow-iter (cdr src-list) wide-p))) | 1123 (cons glyph (devanagari-wide-to-narrow-iter (cdr src-list) 2-col-glyph))) |
1130 ; vertical modifier glyph | 1124 ; glyphs to be processed regardless of the value of "2-col-glyph" |
1125 ((devanagari-non-vertical-modifier-p glyph) | |
1126 (cons (devanagari-wide-to-narrow-char glyph) | |
1127 (devanagari-wide-to-narrow-iter (cdr src-list) 2-col-glyph))) | |
1128 ; glyphs which are depends on the value of "2-col-glyph" | |
1131 ((devanagari-vertical-modifier-p glyph) | 1129 ((devanagari-vertical-modifier-p glyph) |
1132 (if (and (null wide-p) | 1130 (if 2-col-glyph |
1133 (cdr (assq glyph devanagari-1-column-char))) | |
1134 (cons (cdr (assq glyph devanagari-1-column-char)) | |
1135 (devanagari-wide-to-narrow-iter (cdr src-list) nil)) | |
1136 (cons glyph | 1131 (cons glyph |
1137 (devanagari-wide-to-narrow-iter (cdr src-list) t)))) | 1132 (devanagari-wide-to-narrow-iter (cdr src-list) t)) |
1138 ; nonvertical modifier glyph | 1133 (cons (devanagari-wide-to-narrow-char glyph) |
1139 ((devanagari-non-vertical-modifier-p glyph) | 1134 (devanagari-wide-to-narrow-iter (cdr src-list) 2-col-glyph)))) |
1140 (if (cdr (assq glyph devanagari-1-column-char)) | |
1141 (cons (cdr (assq glyph devanagari-1-column-char)) | |
1142 (devanagari-wide-to-narrow-iter (cdr src-list) wide-p)) | |
1143 (cons glyph | |
1144 (devanagari-wide-to-narrow-iter (cdr src-list) wide-p)))) | |
1145 ; normal glyph | 1135 ; normal glyph |
1146 (t | 1136 (t |
1147 (if (cdr (assq glyph devanagari-1-column-char)) | 1137 (if (cdr (assq glyph devanagari-1-column-char)) |
1148 (cons (cdr (assq glyph devanagari-1-column-char)) | 1138 (cons (devanagari-wide-to-narrow-char glyph) |
1149 (devanagari-wide-to-narrow-iter (cdr src-list) nil)) | 1139 (devanagari-wide-to-narrow-iter (cdr src-list) nil)) |
1150 (cons glyph | 1140 (cons glyph |
1151 (devanagari-wide-to-narrow-iter (cdr src-list) t))))))) | 1141 (devanagari-wide-to-narrow-iter (cdr src-list) t))))))) |
1152 | 1142 |
1153 | 1143 |