Add dev2, bng2, gur2, gjr2, ory2, tml2, tel2, knd2 and mlm2.
[m17n/m17n-db.git] / FLT / BNG2-OTF.flt
1 ;; BNG2-OTF.flt -- Font Layout Table for bng2 OpenType fonts
2 ;; Copyright (C) 2010 AIST (H15PRO112)
3 ;; See the end for copying conditions.
4
5 (font layouter bng2-otf nil
6       (version "1.6.0")
7       (font (nil nil unicode-bmp :otf=bng2)))
8
9 ;;; <li> BNG2-OTF.flt
10 ;;;
11 ;;; For bng2 OpenType fonts to draw the Bengali script.  
12
13 ;; It seems that "Shornar Bangla.ttf" is designed to render the bng2
14 ;; script with the following glyph sequence.
15 ;; 1. pre matra
16 ;; 2. half forms and below forms
17 ;; 3. base glyph
18 ;; 4. below forms
19 ;; 5. below matra (09C1..09C4)
20 ;; 6. reph
21 ;; 7. post forms
22 ;; 8. post matra (09C0, 09D7)
23 ;; 9. candrabindu (0981)
24 ;; 10. anusvara (0982) or visarga (0983)
25
26 (category
27  ;; X: generic
28  ;; V: independent vowel
29  ;; C: consonant
30  ;; R: RA
31  ;; T: KHANDA TA
32  ;; n: NUKTA
33  ;; H: HALANT
34  ;; m: vowel sign (pre)
35  ;; b: vowel sign (below)
36  ;; p: vowel sign (post)
37  ;; a: vowel modifier (above)
38  ;; A: vowel modifier (post)
39  ;; N: ZWNJ
40  ;; J: ZWJ
41  (0x0980 0x09FF ?X)                     ; generic
42  (0x0981        ?a)                     ; SIGN CANDRABINDU
43  (0x0982 0x0983 ?A)                     ; SIGN ANUSVARA .. VISARGA
44  (0x0985 0x0994 ?V)                     ; LETTER A .. AU
45  (0x0995 0x09B9 ?C)                     ; LETTER KA .. HA
46  (0x09B0        ?R)                     ; LETTER RA
47  (0x09BC        ?n)                     ; SIGN NUKTA
48  (0x09BE        ?p)                     ; VOWEL SIGN AA
49  (0x09BF        ?m)                     ; VOWEL SIGN I
50  (0x09C0        ?p)                     ; VOWEL SIGN II
51  (0x09C1 0x09C4 ?b)                     ; VOWEL SIGN U .. RR
52  (0x09C7 0x09C8 ?m)                     ; VOWEL SIGN E .. AI
53  (0x09CD        ?H)                     ; SIGN VIRAMA
54  (0x09CE        ?T)                     ; LETTER KHANDA TA
55  (0x09D7        ?p)                     ; AU LENGTH MARK
56  (0x09DC 0x09DF ?C)                     ; LETTER RRA .. YYA
57  (0x09E0 0x09E1 ?V)                     ; LETTER VOCALIC RR, LL
58  (0x09E2 0x09E3 ?b)                     ; VOWEL SIGN L .. LL
59  (0x09F0        ?R)                     ; LETTER RA WITH MIDDLE DIAGONAL
60  (0x09F1        ?C)                     ; LETTER RA WITH LOWER DIAGONAL
61
62  (0x200C        ?N)                     ; ZWNJ
63  (0x200D        ?J)                     ; ZWJ
64  (0x25CC        ?X)                     ; DOTTED CIRCLE
65
66  (rphf          ?r)
67  (pstf          ?P)
68  )
69
70 ;; Stage 0
71 ;; Preprocessing
72 (generator
73  (0
74   (cond
75    ;; Decompose two-part vowel signs.
76    ((0x09CB)
77     0x09C7 0x09BE)
78    ((0x09CC)
79     0x09C7 0x09D7)
80
81    ;; TA + HALANT + ZWJ -> KHANDA-TA
82    ((0x09A4 0x09CD 0x200D)
83     0x09CE)
84
85    ;; consonant + NUKTA
86    ((0x09A1 0x09BC)
87     0x09DC)
88    ((0x09A2 0x09BC)
89     0x09DD)
90    ((0x09AF 0x09BC)
91     0x09DF)
92
93    ("." =))
94   *))
95
96 ;; Stage 1
97 ;; Syllable identification
98 (generator
99  (0
100   (cond
101    ;; Syllables with an independent vowel
102    ("(RH)?Vn?(J?H[CR])?m?b?p?n?a?A?"
103     < | (0 = *) | >)
104
105    ;; KHANDA-TA combines only with reph.
106    ("(RH)?(T)"
107     < (2 =) (1 :otf=bng2=rphf+) >)
108
109    ;; Consonant-based syllables
110    ("([CR]n?J?HJ?)*[CR]n?(H[NJ]?|m?([NJ]?b)?p?n?)a?A?"
111     < | (0 = *) | >)
112
113    ;; Combining marks are displayed with a DOTTED CIRCLE.
114    ("n|H|b|p|a|A|JH[CR]"
115     < 0x25CC (0 :otf=bng2=blwf,pstf+) >)
116
117    ;; Pre-base matra
118    ("(m)(p)?"
119     < (1 =) 0x25CC (2 =) >)
120
121    ("." =))
122   *))
123
124 ;; Stage 2
125 ;; Basic shaping forms and matra reordering
126 (generator
127  (0
128   (cond
129    ;; Explicit halant form starting with RA + H + ZWJ
130    (" (RHJ[CRnHJ]+)(HN?a?A?) "
131     (1 :otf?bng2=locl,nukt,akhn,blwf,pstf+)
132     | (1 b4post) (1 post) (2 = *) |)
133
134    ;; Explicit halant form starting with a reph
135    (" (RH)([CRnHJ]+)(HN?a?A?) "
136     (2 :otf?bng2=locl,nukt,akhn,blwf,pstf+)
137     | (1 :otf=bng2=rphf+) (2 b4post) (2 post) (3 = *) |)
138
139    ;; Other explicit halant forms
140    (" ([CRnHJ]+)(HN?a?A?) "
141     (1 :otf?bng2=locl,nukt,akhn,blwf,pstf+)
142     | (1 b4post) (1 post) (2 = *) |)
143
144    ;; Ordinary syllables starting with RA + H + ZWJ
145    ;; 1             2     3     45
146    (" (RHJ[CRnHJN]*)(mn?)?(bn?)?((pn?)?a?A?) "
147     ;;            |
148     ;; This is an asterisk.  (See DEV2-OTF.flt)
149     (1 :otf?bng2=locl,nukt,akhn,blwf,pstf+)
150     | (2 = *) (1 b4post) (3 = *) (1 post) (4 = *) |)
151
152    ;; Ordinary syllables starting with a reph
153    ;; 1   2           3     4     56
154    (" (RH)([CRnHJVN]+)(mn?)?(bn?)?((pn?)?a?A?) "
155     (2 :otf?bng2=locl,nukt,akhn,blwf,pstf+)
156     | (3 = *) (1 :otf=bng2=rphf+) (2 b4post) (4 = *) (2 post) (5 = *) |)
157
158    ;; Other ordinary syllables
159    ;; 1           2     3     45
160    (" ([CRnHJVN]+)(mn?)?(bn?)?((pn?)?a?A?) "
161     (1 :otf?bng2=locl,nukt,akhn,blwf,pstf+)
162     | (2 = *) (1 b4post) (3 = *) (1 post) (4 = *) |)
163
164    ("." =))
165   *)
166
167  (b4post
168   (cond
169    ;;1                 23       4
170    ("([CRnHJP]*[CRV]n?)((J?PP)+)([NJ])?$"
171     (1 :otf=bng2=locl,nukt,akhn,blwf,half,vatu,cjct+) (4 =))
172    (".+"
173     (0 :otf=bng2=locl,nukt,akhn,blwf,half,vatu,cjct+) (4 =))))
174
175  (post
176   (cond
177    ("[CRnHJP]*[CRV]n?((J?PP)+)([NJ])?$"
178     (1 :otf=bng2=pstf+))))
179  )
180
181 ;; Stage 3
182 ;; Final reordering #1 (Move pre-base matra after the last halant)
183 (generator
184  (0
185   (cond
186    ;; 1    2         3
187    (" (mn?)([^ ]+HJ?)([^H ]+) "
188     | (2 = *) (1 = *) (3 = *) |)
189
190    ("." =))
191   *))
192
193 ;; Stage 4
194 ;; Final reordering #2 (Move reph after the first halant)
195 (generator
196  (0
197   (cond
198    ;; Syllables with a reph and an explicit halant
199    ;; 1     2  3           4
200    (" (mn?)?(r)([^HP ]+HJ?)([^ ]*) "
201     | (1 = *) (3 = *) (2 =) (4 = *) |)
202
203    ;; A reph without explicit halant
204    ;; 1     2  3          4
205    (" (mn?)?(r)([^PpaA ]+)(P*H?p?n?a?A?) "
206     | (1 = *) (3 = *) (2 =) (4 = *) |)
207
208    ("." =))
209   *))
210
211 ;; Stage 5
212 ;; Nukta for matra and Presentation forms
213 (generator
214  (0
215   (cond
216    (" (mn?)?([^ ]+) "
217     | (1 :otf=bng2=nukt,init+)
218     (2 :otf=bng2=nukt,pres,abvs,blws,psts,haln,calt+) |)
219
220    ("." =))
221   *))
222
223 ;; Stage 6
224 ;; Remove ZWNJ/ZWJ
225 (generator
226  (0
227   (cond
228    ("[NJ]")
229
230    ("." =))
231   *))
232
233 ;; Stage 7
234 ;; GPOS processing
235 (generator
236  (0
237   (cond
238    (" ([^ ]+) "
239     (1 :otf=bng2=+kern,dist,abvm,blwm))
240
241    ("." =))
242   *))
243
244 ;; Copyright (C) 2010
245 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
246 ;;   Registration Number H15PRO112
247
248 ;; This file is part of the m17n database; a sub-part of the m17n
249 ;; library.
250
251 ;; The m17n library is free software; you can redistribute it and/or
252 ;; modify it under the terms of the GNU Lesser General Public License
253 ;; as published by the Free Software Foundation; either version 2.1 of
254 ;; the License, or (at your option) any later version.
255
256 ;; The m17n library is distributed in the hope that it will be useful,
257 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
258 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
259 ;; Lesser General Public License for more details.
260
261 ;; You should have received a copy of the GNU Lesser General Public
262 ;; License along with the m17n library; if not, write to the Free
263 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
264 ;; Boston, MA 02110-1301, USA.
265
266 ;; Local Variables:
267 ;; mode: emacs-lisp
268 ;; End: