Add dev2, bng2, gur2, gjr2, ory2, tml2, tel2, knd2 and mlm2.
[m17n/m17n-db.git] / FLT / BENG-OTF.flt
1 ;; BENG-OTF.flt -- Font Layout Table for Bengali OpenType font
2 ;; Copyright (C) 2004, 2007  AIST (H15PRO112)
3 ;; See the end for copying conditions.
4
5 (font layouter beng-otf nil
6       (font (nil nil unicode-bmp :otf=beng=rphf)))
7
8 ;;; <li> BENG-OTF.flt
9 ;;;
10 ;;; For Bengali OpenType fonts to draw the Bengali script.  
11
12 (category
13  ;; X: generic
14  ;; V: independent vowel
15  ;; C: consonant (except for R, B and Y)
16  ;; R: consonant RA
17  ;; B: consonant BA
18  ;; Y: consonant YA
19  ;; T: KHANDA TA
20  ;; n: NUKTA
21  ;; H: HALANT
22  ;; m: vowel sign (pre)
23  ;; b: vowel sign (below)
24  ;; p: vowel sign (post)
25  ;; A: vowel modifier (above)
26  ;; a: vowel modifier (post)
27  ;; Z: internal use
28  ;; N: ZWNJ (ZERO WIDTH NON-JOINER)
29  ;; J: ZWJ (ZERO WIDTH JOINER)
30  (0x0980 0x09FF ?X)                     ; generic
31  (0x0980        ?Z)                     ; internal use
32  (0x0981        ?A)                     ; SIGN CANDRABINDU
33  (0x0982 0x0983 ?a)                     ; SIGN ANUSVARA .. VISARGA
34  (0x0985 0x0994 ?V)                     ; LETTER A .. AU
35  (0x0995 0x09B9 ?C)                     ; LETTER KA .. HA
36  (0x09AC        ?B)                     ; LETTER BA
37  (0x09AF        ?Y)                     ; LETTER YA
38  (0x09B0        ?R)                     ; LETTER RA
39  (0x09BC        ?n)                     ; SIGN NUKTA
40  (0x09BE        ?p)                     ; VOWEL SIGN AA
41  (0x09BF        ?m)                     ; VOWEL SIGN I
42  (0x09C0        ?p)                     ; VOWEL SIGN II
43  (0x09C1 0x09C4 ?b)                     ; VOWEL SIGN U .. RR
44  (0x09C7 0x09C8 ?m)                     ; VOWEL SIGN E .. AI
45  (0x09CD        ?H)                     ; SIGN VIRAMA
46  (0x09CE        ?T)                     ; LETTER KHANDA TA
47  (0x09D7        ?p)                     ; AU LENGTH MARK
48  (0x09DC 0x09DF ?C)                     ; LETTER RRA .. YYA
49  (0x09E0 0x09E1 ?V)                     ; LETTER VOCALIC RR, LL
50  (0x09E2 0x09E3 ?b)                     ; VOWEL SIGN L .. LL
51  (0x09F0 0x09F1 ?C)                     ; LETTER RR WITH MIDDLE/LOWER DIAGONAL
52  (0x0964 0x0965 ?X)                     ; DANDA .. DOUBLE DANDA
53  (0x200C        ?N)                     ; ZWNJ
54  (0x200D        ?J)                     ; ZWJ
55  )
56
57 ;; Preprocessing
58 (generator
59  (0
60   (cond
61    ;; Decompose two-part vowel signs.
62    ((0x09CB)
63     0x09C7 0x09BE)
64    ((0x09CC)
65     0x09C7 0x09D7)
66    ;; TA + HALANT + ZWJ -> KHANDA-TA
67    ((0x09A4 0x09CD 0x200D)
68     0x09CE)
69    ;; consonant + NUKTA
70    ((0x09A1 0x09BC)
71     0x09DC)
72    ((0x09A2 0x09BC)
73     0x09DD)
74    ((0x09AF 0x09BC)
75     0x09DF)
76    ("." =))
77   *))
78
79 ;; Syllable identification and reordering.
80 (generator
81  (0
82   (cond
83    ;; Khanda-Ta
84    ("(RH)?(T)"
85     < | (2 =) (1 otf:beng=rphf+) | >)
86
87    ;; A syllable with a pre-base vowel sign.
88    ;;1    2        3      4       5       6  7   8   9
89    ("(RH)?([CRBY]n?(HCn?)*(H[RB])?(J?HY)?)(m)(p)?(A)?(a)?"
90     < | (6 =) (2 pre-below) (1 otf:beng=rphf+) (8 =) (2 post) (7 =) (9 =) | >)
91
92    ;; A syllable with a non-pre-base vowel sign.
93    ;;1    2        3      4       5       6     78   9   10  11
94    ("(RH)?([CRBY]n?(HCn?)*(H[RB])?(J?HY)?)(N)?J?((b)|(p))(A)?(a)?"
95     < | (6 =) (2 pre-below) (8 =) (1 otf:beng=rphf+) (10 =)
96     (2 post) (9 =) (11 =) | >)
97
98    ;; A syllable with a vowel modifier and no vowel signs.
99    ;;1    2        3      4       5       67   8
100    ("(RH)?([CRBY]n?(HCn?)*(H[RB])?(J?HY)?)((A)|(a))"
101     < | (2 pre-below) (1 otf:beng=rphf+) (7 =) (2 post) (8 =) | >)
102
103    ;; A syllable ending with a halant.
104    ;;1    2        3      4       5       6
105    ("(RH)?([CRBY]n?(HCn?)*(H[RB])?(J?HY)?)(HN?)?"
106     < | (2 pre-below) (6 =) (1 otf:beng=rphf+) (2 post) | >)
107
108    ;; A syllable starting with an independent vowel.
109    ;;1  2  3  4  5    6
110    ("(V)(J?(H)(Y)(p))?(A?a?)"
111     < | (1 =) 0x0980 (4 =) (3 =) (5 =) (6 = *) | >)
112
113    ("." =))
114   *)
115
116  ;; Move a halant after the base consonant to the end.
117  ;; Put a special mark after the final belew-base consonant.
118  ;; Remove post-base parts.
119  (pre-below
120   (cond
121    ("(.+)(H)([RB])(J?HY)?$"
122     (1 = *) (3 =) (2 =) 0x0980)
123    ("([^J]+)J?HY$"
124     (1 = *) 0x0980)
125    (".+"
126     = * 0x0980)))
127
128  ;; Extract post-base parts and add a halant at the end.
129  ;; Produce nothing if there are no post-base parts.
130  (post
131   (cond
132    (".*(H)(Y)$"
133     (2 =) (1 =)))))
134
135 ;; Apply 'nukt' and 'akhn'.
136 (generator
137  (0
138   (cond
139    (" ([^Z]+)(Z[^ ]*) "
140     | (1 otf:beng=nukt,akhn+) (2 = *) |)
141    ("." =))
142   *))
143
144 ;; Apply 'blwf' and 'pstf' to the concerning parts.
145 (generator
146  (0
147   (cond
148    (" (N?m?.)([^Z]*)(Z)([^ ]*) "
149     | (1 = *) (2 otf:beng=blwf+) (3 =) (4 otf:beng=pstf+) |)
150    ("." =))
151   *))
152
153 ;; Get pre-base and below-base conjuncts.
154 (generator
155  (0
156   (cond
157    (" (N?m?)([^Z]+)(Z)([^ ]*) "
158     | (1 = *) (2 otf:beng=half,vatu,pres,blws+) (3 =) (4 = *) |)
159    ("." =))
160   *))
161
162 ;; When the number of glyphs between a pre-base vowel sign and the
163 ;; post-below mark is more than one, move the pre-base vowel sign
164 ;; before the final glyph.
165 (generator
166  (0
167   (cond
168    (" (N)?(m)([^Z]+)([^Z])Z([^ ]*) "
169     | (1 =) (3 = *) (2 =) (4 =) (5 = *) |)
170    (" ([^Z]+)Z([^ ]*) "
171     | (1 = *) (2 = *) |)
172    ("." =))
173   *))
174
175 ;; Get matra conjuncts.
176 ;; Do not apply 'blws' to syllables that begins with ZWNJ.
177 (generator
178  (0
179   (cond
180    (" N([^ ]+) "
181     (1 otf:beng=init,pres,abvs,psts,haln+abvm,blwm,dist))
182    (" ([^ ]+) "
183     (1 otf:beng=init,pres,abvs,blws,psts,haln+abvm,blwm,dist))
184    ("."
185     [ = ]))
186   *))
187
188 ;; Copyright (C) 2004, 2007
189 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
190 ;;   Registration Number H15PRO112
191
192 ;; This file is part of the m17n database; a sub-part of the m17n
193 ;; library.
194
195 ;; The m17n library is free software; you can redistribute it and/or
196 ;; modify it under the terms of the GNU Lesser General Public License
197 ;; as published by the Free Software Foundation; either version 2.1 of
198 ;; the License, or (at your option) any later version.
199
200 ;; The m17n library is distributed in the hope that it will be useful,
201 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
202 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
203 ;; Lesser General Public License for more details.
204
205 ;; You should have received a copy of the GNU Lesser General Public
206 ;; License along with the m17n library; if not, write to the Free
207 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
208 ;; Boston, MA 02110-1301, USA.
209
210 ;; Local Variables:
211 ;; mode: emacs-lisp
212 ;; End: