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