Add ZWJ to the chillu sequence passed to the OTF driver.
[m17n/m17n-db.git] / FLT / MLYM-OTF.flt
1 ;; MLYM-OTF.flt -- Font Layout Table for Malayalam OpenType font
2 ;; Copyright (C) 2003, 2004, 2005, 2007, 2008  AIST (H15PRO112)
3 ;; See the end for copying conditions.
4
5 (font layouter mlym-otf nil
6       (font (nil nil unicode-bmp :otf=mlym=akhn)))
7
8 ;;; <li> MLYM-OTF.flt
9 ;;;
10 ;;; For Malayalam OpenType fonts to draw the reformed Malayalam script.
11
12 ;; Tested with the following fonts.  All of these fonts require Halant
13 ;; movement for syllable-final YA, LA and VA, but not for RA.
14
15 ;; AnjaliOldLipi.ttf
16 ;; Dyuthi3.ttf
17 ;; Kalyani121.ttf
18 ;; Meera_04.ttf
19 ;; Rachana_04.ttf
20 ;; RaghuMalayalamSans2.ttf
21 ;; suruma2.ttf
22
23 (category
24  ;; C: ordinary consonants (except P)
25  ;; P: consonants that have a post- or below-form
26  ;; H: HALANT
27  ;; m: vowel sign (pre)
28  ;; b: vowel sign (below)
29  ;; p: vowel sign (post)
30  ;; A: vowel modifier (post)
31  ;; V: independent vowel
32  ;; N: ZWNJ (ZERO WIDTH NON-JOINER)
33  ;; J: ZWJ (ZERO WIDTH JOINER)
34  ;; Z: internal use
35  ;; X: generic
36  (0x0D00 0x0D7F ?X)                     ; generic
37  (0x0D00        ?Z)                     ; internal use
38  (0x0D02 0x0D03 ?A)                     ; SIGN ANUSVARA .. VISARGA
39  (0x0D05 0x0D14 ?V)                     ; LETTER A .. AU
40  (0x0D15 0x0D39 ?C)                     ; LETTER KA .. HA
41  (0x0D2F        ?P)                     ; LETTER YA
42  (0x0D32        ?P)                     ; LETTER LA
43  (0x0D35        ?P)                     ; LETTER VA
44  (0x0D3E 0x0D44 ?p)                     ; VOWEL SIGN AA .. VOCALIC RR
45  (0x0D46 0x0D48 ?m)                     ; VOWEL SIGN E .. AI
46  (0x0D4D        ?H)                     ; SIGN VIRAMA
47  (0x0D57        ?p)                     ; AU LENGTH MARK
48  (0x0D60 0x0D61 ?V)                     ; LETTER VOCALIC RR .. VOCALIC LL
49  (0x0D62 0x0D63 ?b)                     ; VOWEL SIGN VOCALIC L .. LL
50  (0x0D7A 0x0D7F ?C)                     ; LETTER CHILLU NN .. K
51  (0x0964 0x0965 ?X)                     ; DANDA .. DOUBLE DANDA
52  (0x200C        ?N)                     ; ZWNJ
53  (0x200D        ?J)                     ; ZWJ
54  )
55
56 ;; Stage 0
57 ;; Decompose two-part vowels.
58 (generator
59  (0
60   (cond
61    ((0x0D4A)
62     0x0D46 0x0D3E)
63    ((0x0D4B)
64     0x0D47 0x0D3E)
65    ((0x0D4C)
66     0x0D46 0x0D57)
67    ("." =))
68   *))
69
70 ;; Stage 1
71 ;; Syllable identification and reordering.  
72 ;; Put the mark Z after the base consonant.
73 (generator
74  (0
75   (cond
76    ;; A syllable with a left vowel sign.
77    ;;1    2        3  4
78    ("([CP](H[CP])*)(m)(p?A?)"
79     < | (3 =) (1 move-h) (4 = *) | >)
80
81    ;; A syllable with a right vowel sign, a below vowel sign
82    ;; and/or a vowel modifier.
83    ;;1    2        3
84    ("([CP](H[CP])*)(bA?|pA?|A)"
85     < | (1 move-h) (3 = *) | >)
86
87    ;; Explicit Halant / forced chillu form is separated from the
88    ;; preceding characters.
89    ;;12        3
90    ("(([CP]H)*)([CP]H[NJ])"
91     (1 < | cut-off | >) (3 < | = * | >))
92
93    ;; A syllable with no vowel signs/modifiers.
94    ("[CP](H[CP])*H?"
95     < | (0 move-h) | >)
96
97    ;; Starting with an independent vowel.
98    ("VA?"
99     < | (0 = *) | >)
100
101    ("." =))
102   *)
103
104
105  ;; Move the halant that follows the base consonant to the end.
106  (move-h
107   (cond
108    ;; All consonants are P's.
109    ("(P)(H)([PH]*)$"
110     (1 =) 0x0D00 (3 = *) (2 =))
111
112    ;; One or more Non-P consonants.
113    ("([CPH]*C)(H)([PH]+)$"
114     (1 = *) 0x0D00 (3 = *) (2 =))
115
116    ;; Otherwise, final consonant is not P.  No need to move H.
117    (".+"
118     = * 0x0D00)))
119
120  ;; If there are some letters, make them a separate syllable.
121  (cut-off
122   (cond
123    ("[CP](H[CP])*H?"
124     (0 move-h))))
125  )
126
127 ;; Stage 2
128 ;; Apply 'akhn' feature.
129 (generator
130  (0
131   (cond
132    ;; Ordinary syllable.  We must avoid applying 'blwf' and 'pstf' to
133    ;; the first consonant if it is a P, but 'akhn' must be applied
134    ;; always.  Other GSUB features are applied in the following
135    ;; satges.
136
137    ;; 1   2       3  4
138    (" (m)?([CPH]*)(Z)([PHbpA]*) "
139     | (1 =) (2 otf:mlym=akhn+) (3 =) (4 otf:mlym=blwf,pstf+) |)
140
141    ("." =))
142   *))
143
144 ;; Stage 3
145 ;; Apply 'blwf' to non-initial glyphs.
146 (generator
147  (0
148   (cond
149    ;; 1       2       3
150    (" (m?[^Z])([^Z ]*)(Z[^ ]*) "
151     | (1 = *) (2 otf:mlym=blwf+) (3 = *) |)
152
153    ("." =))
154   *))
155
156 ;; Stage 4
157 ;; Apply other language forms.
158 (generator
159  (0
160   (cond
161    ;; All characters should have the 'half' form glyph, and 'pstf' is
162    ;; always applied after 'half'.  Thus we do not need to worry
163    ;; about applying 'pstf' to the first glyph.
164    ;; 1   2       3
165    (" (m)?([^Z ]*)(Z[^ ]*) "
166     | (1 = *) (2 otf:mlym=half,pstf+) (3 = *) |)
167
168    ;; Explicit Halant.
169    (" ([CP]H)N "
170     | (1 = *) |)
171
172    ;; Forced chillu form.  According to Microsoft Typography
173    ;; <http://www.microsoft.com/typography/otfntdev/malayot/features.htm>
174    ;; 'chillu' glyphs are generated with the 'haln' feature.  However,
175    ;; some fonts generate them with 'half'.
176    (" ([CP]HJ) "
177     | (1 otf:mlym=haln,half+) |)
178
179    ("." =))
180   *))
181
182 ;; Stage 5
183 ;; Second reordering.  If there are glyphs before the base, move left
184 ;; vowel sign to the left of the base.
185 (generator
186  (0
187   (cond
188    ;; 1   2       3      4
189    (" (m)?([^Z ]*)([^Z])Z([^ ]*) "
190     | (2 = *) (1 =) (3 =) (4 = *) |)
191
192    ("." =))
193   *))
194
195 ;; Stage 6
196 ;; Apply typographical forms, 'haln' and GPOS features.
197 (generator
198  (0
199   (cond
200    (" ([^ ]+) "
201     (1 otf:mlym=pres,abvs,blws,psts,haln+abvm,blwm,dist))
202    ("."
203     [ = ]))
204   *))
205
206 ;; Copyright (C) 2003, 2004, 2005, 2007, 2008
207 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
208 ;;   Registration Number H15PRO112
209
210 ;; This file is part of the m17n database; a sub-part of the m17n
211 ;; library.
212
213 ;; The m17n library is free software; you can redistribute it and/or
214 ;; modify it under the terms of the GNU Lesser General Public License
215 ;; as published by the Free Software Foundation; either version 2.1 of
216 ;; the License, or (at your option) any later version.
217
218 ;; The m17n library is distributed in the hope that it will be useful,
219 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
220 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
221 ;; Lesser General Public License for more details.
222
223 ;; You should have received a copy of the GNU Lesser General Public
224 ;; License along with the m17n library; if not, write to the Free
225 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
226 ;; Boston, MA 02110-1301, USA.
227
228 ;; Local Variables:
229 ;; mode: emacs-lisp
230 ;; End: