*** empty log message ***
[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, 2008  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  (0x0972        ?V)                     ; LETTER CANDRA A
52  (0x097B 0x097C ?C)                     ; LETTER GGA .. JJA
53  (0x097E 0x097F ?C)                     ; LETTER DDDA .. BBA
54  (0x200C        ?N)                     ; ZWNJ
55  (0x200D        ?J)                     ; ZWJ
56  )
57
58 ;; Stage 0
59 ;; Compose consonant and nukta
60 (generator
61  (0
62   (cond
63    ((0x0928 0x093C) 0x0929)
64    ((0x0930 0x093C) 0x0931)
65    ((0x0933 0x093C) 0x0934)
66    ((0x0915 0x093C) 0x0958)
67    ((0x0916 0x093C) 0x0959)
68    ((0x0917 0x093C) 0x095A)
69    ((0x091C 0x093C) 0x095B)
70    ((0x0921 0x093C) 0x095C)
71    ((0x0922 0x093C) 0x095D)
72    ((0x092B 0x093C) 0x095E)
73    ((0x092F 0x093C) 0x095F)
74    ("." =))
75   *))
76
77 ;; Stage 1
78 ;; Syllable identification and eordering.
79 (generator
80  (0
81   (cond
82    ;; A syllable containing a vowel sign.
83    ;;1      2            34   5   6     7   8   9   10
84    ("([CR]n?(HJ?[CR]n?)*)((m)|(b)|(u|p))(A)?(a)?(S)?(s)?"
85     < | (4 =) (1 move-h) (5 =) (10 =) (6 =) (1 reph) (7 =) (9 =) (8 =) | >)
86
87    ;; A syllable without vowel signs but with a vowel modifier.
88    ;;1      2            34   5   6   7
89    ("([CR]n?(HJ?[CR]n?)*)((A)|(a))(S)?(s)?"
90     < | (1 move-h) (7 =) (1 reph) (4 =) (6 =) (5 =) | >)
91
92    ;; No vowel signs, No vowel modifiers, but with a stress sign or an accent.
93    ;;1      2            34   5
94    ("([CR]n?(HJ?[CR]n?)*)((S)|(s))"
95     < | (1 move-h) (5 =) (1 reph) (4 =) | >)
96
97    ;; No marks at all.  Need further anylysis.
98    ("[CR]n?(HJ?[CR]n?)*(H(N|J)?)?"
99     < | (0 nomarks) | >)
100
101    ;; This combination is used in Marathi.
102    ((0x0905 0x0945)
103     < | = = | >)
104
105    ;; A syllable starting with an independent vowel.
106    ;;1  2   3   4   5
107    ("(V)(A)?(a)?(S)?(s)?"
108     < | (1 =) (5 =) (2 =) (4 =) (3 =) | >)
109
110    ("." =))
111   *)
112
113  (move-h
114   (cond
115    ;; Starting with an eyelash-RA, which remains there.
116    ("(RHJ.+)(H)(R)$"
117     (1 = *) (3 =) (2 =))
118    ("RHJ.*"
119     = *)
120
121    ;; Starting with a reph, which is removed.
122    ("RH(.+)(H)(R)$"
123     (1 = *) (3 =) (2 =))
124    ("RH(.+)"
125     (1 = *))
126
127    ("(.+)(H)(R)$"
128     (1 = *) (3 =) (2 =))
129    (".+"
130     = *)))
131
132  (reph
133   (cond
134    ("RHJ.*")
135    ("(RH).*"
136     (1 otf:deva=rphf+))))
137
138  (del-reph
139   (cond
140    ("RHJ.*"
141     = *)
142    ("RH(.*)"
143     (1 = *))
144    (".+"
145     = *)))
146
147  (nomarks
148   (cond
149    ;; Ending with a Halant and a ZWJ.
150    (".+HJ$"
151     (0 del-reph) (0 reph))
152
153    ;; Ending with a Halant and an optional ZWNJ.  Add ZWNJ explicitly.
154    ("(.+)(H)N?$"
155     (1 move-h) (1 reph) (2 =) 0x200C)
156
157    ;; Ending with a consonant.
158    (".+"
159     (0 move-h) (0 reph))))
160  )
161
162 ;; Stage 2
163 ;; Apply GSUB features.  If a syllable ends with a halant and a ZWNJ,
164 ;; render the final halant explicitly.
165 (generator
166  (0
167   (cond
168    ;; Allow eyelash RA to appear at the beginning.
169    (" (RH)J([^ ]+)(H)N "
170     | (1 otf:deva=half+) (2 gsub) (3 =) |)
171    (" (m)?(RH)J([^ ]*) "
172     | (1 =) (2 otf:deva=half+) (3 gsub) |)
173
174    ;; Avoid applying 'blwf' and 'half' to the "RH" at the beginning;
175    (" (R)([^ ]*)(H)N "
176     | (1 =) (2 gsub) (3 =) |)
177    (" (m?R)([^ ]*) "
178     | (1 otf:deva=pres+) (2 gsub) |)
179
180    (" ([^ ]+)(H)N "
181     | (1 gsub) (2 =) |)
182    (" ([^ ]+) "
183     | (1 gsub) |)
184
185    ("." =))
186   *)
187
188  ;; Dispite Rule R5a (The Unicode Standard 5.0, p.305), we use the
189  ;; below form to depict the sequence "RHJ" at non-initial positions.
190  ;; This is to avoid interpreting the sequence "CHRHJ" as "CH" +
191  ;; "RHJ".  It should be parsed as "CHR" + "HJ".
192  (gsub
193   (cond
194    ("([^J]*)J(.*)"
195     (1 otf:deva=nukt,akhn,blwf,half,vatu,pres+) (2 gsub))
196    (".*"
197     otf:deva=nukt,akhn,blwf,half,vatu,pres+)))
198  )
199
200 ;; Stage 3
201 ;; Apply other features.
202 (generator
203  (0
204   (cond
205    (" ([^ ]+) "
206     (1 otf:deva=abvs,blws,psts,haln+abvm,blwm,dist))
207    ("."
208     [ = ]))
209   *))
210
211 ;; Copyright (C) 2003, 2004, 2007, 2008
212 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
213 ;;   Registration Number H15PRO112
214
215 ;; This file is part of the m17n database; a sub-part of the m17n
216 ;; library.
217
218 ;; The m17n library is free software; you can redistribute it and/or
219 ;; modify it under the terms of the GNU Lesser General Public License
220 ;; as published by the Free Software Foundation; either version 2.1 of
221 ;; the License, or (at your option) any later version.
222
223 ;; The m17n library is distributed in the hope that it will be useful,
224 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
225 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
226 ;; Lesser General Public License for more details.
227
228 ;; You should have received a copy of the GNU Lesser General Public
229 ;; License along with the m17n library; if not, write to the Free
230 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
231 ;; Boston, MA 02110-1301, USA.
232
233 ;; Local Variables:
234 ;; mode: emacs-lisp
235 ;; End: