*** empty log message ***
[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     < | = * | >)
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     < | = * | >)
112
113    ;; Two-part vowel signs
114    ((0x09C7 0x09BE)
115     (cond
116      ((font-facility 0x25CC) < 0x09C7 0x25CC 0x09BE >)
117      (".+" < 0x09CB >)))
118    ((0x09C7 0x09D7)
119     (cond
120      ((font-facility 0x25CC) < 0x09C7 0x25CC 0x09D7 >)
121      (".+" < 0x09CC >)))
122
123    ;; Combining marks are displayed with a DOTTED CIRCLE.
124    ("m"
125     (cond
126      ((font-facility 0x25CC) < = 0x25CC >)
127      ("." [ = ])))
128    ("[nHbpaA]"
129     (cond
130      ((font-facility 0x25CC) < 0x25CC = >)
131      ("." [ = ])))
132    ("JH[CR]"
133     (cond
134      ((font-facility 0x25CC) < 0x25CC :otf=bng2=blwf,pstf+ >)
135      (".+" [ :otf=bng2=blwf,pstf+ ])))
136
137    ("." =))
138   *))
139
140 ;; Stage 2
141 ;; Basic shaping forms and matra reordering
142 (generator
143  (0
144   (cond
145    ;; Explicit halant form starting with RA + H + ZWJ
146    (" (RHJ[CRnHJ]+)(HN?a?A?) "
147     (1 :otf?bng2=locl,nukt,akhn,blwf,pstf+)
148     | (1 b4post) (1 post) (2 = *) |)
149
150    ;; Explicit halant form starting with a reph
151    (" (RH)([CRnHJ]+)(HN?a?A?) "
152     (2 :otf?bng2=locl,nukt,akhn,blwf,pstf+)
153     | (1 :otf=bng2=rphf+) (2 b4post) (2 post) (3 = *) |)
154
155    ;; Other explicit halant forms
156    (" ([CRnHJ]+)(HN?a?A?) "
157     (1 :otf?bng2=locl,nukt,akhn,blwf,pstf+)
158     | (1 b4post) (1 post) (2 = *) |)
159
160    ;; Ordinary syllables starting with RA + H + ZWJ
161    ;; 1             2     3     45
162    (" (RHJ[CRnHJN]*)(mn?)?(bn?)?((pn?)?a?A?) "
163     ;;            |
164     ;; This is an asterisk.  (See DEV2-OTF.flt)
165     (1 :otf?bng2=locl,nukt,akhn,blwf,pstf+)
166     | (2 = *) (1 b4post) (3 = *) (1 post) (4 = *) |)
167
168    ;; Ordinary syllables starting with a reph
169    ;; 1   2           3     4     56
170    (" (RH)([CRnHJVN]+)(mn?)?(bn?)?((pn?)?a?A?) "
171     (2 :otf?bng2=locl,nukt,akhn,blwf,pstf+)
172     | (3 = *) (1 :otf=bng2=rphf+) (2 b4post) (4 = *) (2 post) (5 = *) |)
173
174    ;; Other ordinary syllables
175    ;; 1           2     3     45
176    (" ([CRnHJVN]+)(mn?)?(bn?)?((pn?)?a?A?) "
177     (1 :otf?bng2=locl,nukt,akhn,blwf,pstf+)
178     | (2 = *) (1 b4post) (3 = *) (1 post) (4 = *) |)
179
180    ("." =))
181   *)
182
183  (b4post
184   (cond
185    ;;1                 23       4
186    ("([CRnHJP]*[CRV]n?)((J?PP)+)([NJ])?$"
187     (1 :otf=bng2=locl,nukt,akhn,blwf,half,vatu,cjct+) (4 =))
188    (".+"
189     (0 :otf=bng2=locl,nukt,akhn,blwf,half,vatu,cjct+) (4 =))))
190
191  (post
192   (cond
193    ("[CRnHJP]*[CRV]n?((J?PP)+)([NJ])?$"
194     (1 :otf=bng2=pstf+))))
195  )
196
197 ;; Stage 3
198 ;; Final reordering #1 (Move pre-base matra after the last halant)
199 (generator
200  (0
201   (cond
202    ;; 1    2         3
203    (" (mn?)([^ ]+HJ?)([^H ]+) "
204     | (2 = *) (1 = *) (3 = *) |)
205
206    ("." =))
207   *))
208
209 ;; Stage 4
210 ;; Final reordering #2 (Move reph after the first halant)
211 (generator
212  (0
213   (cond
214    ;; Syllables with a reph and an explicit halant
215    ;; 1     2  3           4
216    (" (mn?)?(r)([^HP ]+HJ?)([^ ]*) "
217     | (1 = *) (3 = *) (2 =) (4 = *) |)
218
219    ;; A reph without explicit halant
220    ;; 1     2  3          4
221    (" (mn?)?(r)([^PpaA ]+)(P*H?p?n?a?A?) "
222     | (1 = *) (3 = *) (2 =) (4 = *) |)
223
224    ("." =))
225   *))
226
227 ;; Stage 5
228 ;; Nukta for matra and Presentation forms
229 (generator
230  (0
231   (cond
232    (" (mn?)?([^ ]+) "
233     | (1 :otf=bng2=nukt,init+)
234     (2 :otf=bng2=nukt,pres,abvs,blws,psts,haln,calt+) |)
235
236    ("." =))
237   *))
238
239 ;; Stage 6
240 ;; Remove ZWNJ/ZWJ
241 (generator
242  (0
243   (cond
244    ("[NJ]")
245
246    ("." =))
247   *))
248
249 ;; Stage 7
250 ;; GPOS processing
251 (generator
252  (0
253   (cond
254    (" ([^ ]+) "
255     (1 :otf=bng2=+kern,dist,abvm,blwm))
256
257    ("." =))
258   *))
259
260 ;; Copyright (C) 2010
261 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
262 ;;   Registration Number H15PRO112
263
264 ;; This file is part of the m17n database; a sub-part of the m17n
265 ;; library.
266
267 ;; The m17n library is free software; you can redistribute it and/or
268 ;; modify it under the terms of the GNU Lesser General Public License
269 ;; as published by the Free Software Foundation; either version 2.1 of
270 ;; the License, or (at your option) any later version.
271
272 ;; The m17n library is distributed in the hope that it will be useful,
273 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
274 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
275 ;; Lesser General Public License for more details.
276
277 ;; You should have received a copy of the GNU Lesser General Public
278 ;; License along with the m17n library; if not, write to the Free
279 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
280 ;; Boston, MA 02110-1301, USA.
281
282 ;; Local Variables:
283 ;; mode: emacs-lisp
284 ;; End: