Accept "U+0905 U+0945" as a valid sequence (mainly for Marathi).
[m17n/m17n-db.git] / FLT / DEVA-OTF.flt
1 ;; DEVA-OTF.flt -- Font Layout Table for Devanagari OpenType font
2 ;; Copyright (C) 2003, 2004, 2007  AIST (H15PRO112)
3 ;; See the end for copying conditions.
4
5 (font layouter deva-otf nil
6       (font (nil nil unicode-bmp :otf=deva=rphf)))
7
8 ;;; <li> DEVA-OTF.flt
9 ;;;
10 ;;; For Devanagari OpenType fonts to draw the Devanagari script.
11
12 (category
13  ;; X: generic
14  ;; C: consonant (except for RA)
15  ;; R: consonant RA
16  ;; n: NUKTA
17  ;; H: HALANT
18  ;; m: vowel sign (pre)
19  ;; u: vowel sign (above)
20  ;; b: vowel sign (below)
21  ;; p: vowel sign (post)
22  ;; A: vowel modifier (above)
23  ;; a: vowel modifier (post)
24  ;; S: stress sign / accent (above)
25  ;; s: stress sign / accent (below)
26  ;; V: independent vowel
27  ;; Z: internal use
28  ;; N: ZWNJ
29  ;; J: ZWJ
30  (0x0900 0x097F ?X)                     ; generic
31  (0x0900        ?Z)                     ; internal use
32  (0x0901 0x0902 ?A)                     ; SIGN CANDRABINDU .. ANUSVARA
33  (0x0903        ?a)                     ; SIGN VISARGA
34  (0x0904 0x0914 ?V)                     ; LETTER SHORT A .. AU
35  (0x0915 0x0939 ?C)                     ; LETTER KA .. HA
36  (0x0930        ?R)                     ; LETTER RA
37  (0x093C        ?n)                     ; SIGN NUKTA
38  (0x093E        ?p)                     ; VOWEL SIGN AA
39  (0x093F        ?m)                     ; VOWEL SIGN I
40  (0x0940        ?p)                     ; VOWEL SIGN II
41  (0x0941 0x0944 ?b)                     ; VOWEL SIGN UU .. VOCALIC RR
42  (0x0945 0x0948 ?u)                     ; VOWEL SIGN CANDRA E .. AI
43  (0x0949 0x094C ?p)                     ; VOWEL SIGN CANDRA O .. AU
44  (0x094D        ?H)                     ; SIGN VIRAMA
45  (0x0951        ?S)                     ; STRESS SIGN UDATTA
46  (0x0952        ?s)                     ; STRESS SIGN ANUDATTA
47  (0x0953 0x0954 ?S)                     ; GRAVE ACCENT .. ACUTE ACCENT
48  (0x0958 0x095F ?C)                     ; LETTER QA .. YYA
49  (0x0960 0x0961 ?V)                     ; LETTER VOCALIC RR  .. VOCALIC LL
50  (0x0962 0x0963 ?b)                     ; VOWEL SIGN VOCALIC L .. VOCALIC LL
51  (0x097B 0x097C ?C)                     ; LETTER GGA .. JJA
52  (0x097E 0x097F ?C)                     ; LETTER DDDA .. BBA
53  (0x200C        ?N)                     ; ZWNJ
54  (0x200D        ?J)                     ; ZWJ
55  )
56
57 ;; Stage 0
58 ;; Compose consonant and nukta
59 (generator
60  (0
61   (cond
62    ((0x0928 0x093C) 0x0929)
63    ((0x0930 0x093C) 0x0931)
64    ((0x0933 0x093C) 0x0934)
65    ((0x0915 0x093C) 0x0958)
66    ((0x0916 0x093C) 0x0959)
67    ((0x0917 0x093C) 0x095A)
68    ((0x091C 0x093C) 0x095B)
69    ((0x0921 0x093C) 0x095C)
70    ((0x0922 0x093C) 0x095D)
71    ((0x092B 0x093C) 0x095E)
72    ((0x092F 0x093C) 0x095F)
73    ("." =))
74   *))
75
76 ;; Stage 1
77 ;; Syllable identification and eordering.
78 (generator
79  (0
80   (cond
81    ;; A syllable containing a vowel sign.
82    ;;1      2            34   5   6     7   8   9   10
83    ("([CR]n?(HJ?[CR]n?)*)((m)|(b)|(u|p))(A)?(a)?(S)?(s)?"
84     < | (4 =) (1 move-h) (5 =) (10 =) (6 =) (1 reph) (7 =) (9 =) (8 =) | >)
85
86    ;; A syllable without vowel signs but with a vowel modifier.
87    ;;1      2            34   5   6   7
88    ("([CR]n?(HJ?[CR]n?)*)((A)|(a))(S)?(s)?"
89     < | (1 move-h) (7 =) (1 reph) (4 =) (6 =) (5 =) | >)
90
91    ;; No vowel signs, No vowel modifiers, but with a stress sign or an accent.
92    ;;1      2            34   5
93    ("([CR]n?(HJ?[CR]n?)*)((S)|(s))"
94     < | (1 move-h) (5 =) (1 reph) (4 =) | >)
95
96    ;; No marks at all.  Need further anylysis.
97    ("[CR]n?(HJ?[CR]n?)*(H(N|J)?)?"
98     < | (0 nomarks) | >)
99
100    ;; This combination is used in Marathi.
101    ((0x0905 0x0945)
102     < | = = | >)
103
104    ;; A syllable starting with an independent vowel.
105    ;;1  2   3   4   5
106    ("(V)(A)?(a)?(S)?(s)?"
107     < | (1 =) (5 =) (2 =) (4 =) (3 =) | >)
108
109    ("." =))
110   *)
111
112  (move-h
113   (cond
114    ;; Starting with an eyelash-RA, which remains there.
115    ("(RHJ.+)(H)(R)$"
116     (1 = *) (3 =) (2 =))
117    ("RHJ.*"
118     = *)
119
120    ;; Starting with a reph, which is removed.
121    ("RH(.+)(H)(R)$"
122     (1 = *) (3 =) (2 =))
123    ("RH(.+)"
124     (1 = *))
125
126    ("(.+)(H)(R)$"
127     (1 = *) (3 =) (2 =))
128    (".+"
129     = *)))
130
131  (reph
132   (cond
133    ("RHJ.*")
134    ("(RH).*"
135     (1 otf:deva=rphf+))))
136
137  (del-reph
138   (cond
139    ("RHJ.*"
140     = *)
141    ("RH(.*)"
142     (1 = *))
143    (".+"
144     = *)))
145
146  (nomarks
147   (cond
148    ;; Ending with a Halant and a ZWJ.
149    (".+HJ$"
150     (0 del-reph) (0 reph))
151
152    ;; Ending with a Halant and an optional ZWNJ.  Add ZWNJ explicitly.
153    ("(.+)(H)N?$"
154     (1 move-h) (1 reph) (2 =) 0x200C)
155
156    ;; Ending with a consonant.
157    (".+"
158     (0 move-h) (0 reph))))
159  )
160
161 ;; Stage 2
162 ;; Apply GSUB features.  If a syllable ends with a halant and a ZWNJ,
163 ;; render the final halant explicitly.
164 (generator
165  (0
166   (cond
167    ;; Allow eyelash RA to appear at the beginning.
168    (" (RH)J([^ ]+)(H)N "
169     | (1 otf:deva=half+) (2 gsub) (3 =) |)
170    (" (m)?(RH)J([^ ]*) "
171     | (1 =) (2 otf:deva=half+) (3 gsub) |)
172
173    ;; Avoid applying 'blwf' and 'half' to the "RH" at the beginning;
174    (" (R)([^ ]*)(H)N "
175     | (1 =) (2 gsub) (3 =) |)
176    (" (m?R)([^ ]*) "
177     | (1 otf:deva=pres+) (2 gsub) |)
178
179    (" ([^ ]+)(H)N "
180     | (1 gsub) (2 =) |)
181    (" ([^ ]+) "
182     | (1 gsub) |)
183
184    ("." =))
185   *)
186
187  ;; Dispite Rule R5a (The Unicode Standard 5.0, p.305), we use the
188  ;; below form to depict the sequence "RHJ" at non-initial positions.
189  ;; This is to avoid interpreting the sequence "CHRHJ" as "CH" +
190  ;; "RHJ".  It should be parsed as "CHR" + "HJ".
191  (gsub
192   (cond
193    ("([^J]*)J(.*)"
194     (1 otf:deva=nukt,akhn,blwf,half,vatu,pres+) (2 gsub))
195    (".*"
196     otf:deva=nukt,akhn,blwf,half,vatu,pres+)))
197  )
198
199 ;; Stage 3
200 ;; Apply other features.
201 (generator
202  (0
203   (cond
204    (" ([^ ]+) "
205     (1 otf:deva=abvs,blws,psts,haln+abvm,blwm,dist))
206    ("."
207     [ = ]))
208   *))
209
210 ;; Copyright (C) 2003, 2004, 2007
211 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
212 ;;   Registration Number H15PRO112
213
214 ;; This file is part of the m17n database; a sub-part of the m17n
215 ;; library.
216
217 ;; The m17n library is free software; you can redistribute it and/or
218 ;; modify it under the terms of the GNU Lesser General Public License
219 ;; as published by the Free Software Foundation; either version 2.1 of
220 ;; the License, or (at your option) any later version.
221
222 ;; The m17n library is distributed in the hope that it will be useful,
223 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
224 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
225 ;; Lesser General Public License for more details.
226
227 ;; You should have received a copy of the GNU Lesser General Public
228 ;; License along with the m17n library; if not, write to the Free
229 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
230 ;; Boston, MA 02110-1301, USA.
231
232 ;; Local Variables:
233 ;; mode: emacs-lisp
234 ;; End: