Include syllable final HJ to otf part.
[m17n/m17n-db.git] / FLT / MLYM-OTF.flt
1 ;; MLYM-OTF.flt -- Font Layout Table for Malayalam OpenType fonts
2 ;; Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009, 2010 AIST (H15PRO112)
3 ;; See the end for copying conditions.
4
5 (font layouter mlym-otf nil
6       (version "1.6.0")
7       (font (nil nil unicode-bmp :otf=mlym)))
8
9 ;;; <li> MLYM-OTF.flt
10 ;;;
11 ;;; For Malayalam OpenType fonts to draw the reformed Malayalam script.
12
13 ;; AnjaliOldLipi.ttf, Dyuthi3.ttf, Meera_04.ttf, Rachana_04.ttf, suruma2.ttf
14 ;; blwf: 0d32
15 ;; pstf: 0d2f 0d30 0d35
16
17 ;; RaghuMalayalamSans2.ttf
18 ;; blwf: 0d32
19 ;; pstf: 0d2f 0d30 0d35 0d41
20
21 ;; lohit_ml.ttf
22 ;; blwf: 0d32
23 ;; pstf: 0d2f 0d30 0d31 0d35 0d41
24
25 ;; Kalyani121.ttf
26 ;; blwf: N/A
27 ;; pstf: 0d2f 0d30 0d32 0d35 0d41
28
29 (category
30  (0x0D00 0x0D7F ?X)                     ; generic
31  (0x0D02 0x0D03 ?A)                     ; SIGN ANUSVARA .. VISARGA
32  (0x0D05 0x0D14 ?V)                     ; LETTER A .. AU
33  (0x0D15 0x0D39 ?C)                     ; LETTER KA .. HA
34  (0x0D2F        ?P)                     ; LETTER YA
35  (0x0D30        ?R)                     ; LETTER RA
36  (0x0D32        ?B)                     ; LETTER LA
37  (0x0D35        ?P)                     ; LETTER VA
38  (0x0D3E 0x0D44 ?p)                     ; VOWEL SIGN AA .. VOCALIC RR
39  (0x0D46 0x0D48 ?m)                     ; VOWEL SIGN E .. AI
40  (0x0D4D        ?H)                     ; SIGN VIRAMA
41  (0x0D57        ?p)                     ; AU LENGTH MARK
42  (0x0D60 0x0D61 ?V)                     ; LETTER VOCALIC RR .. VOCALIC LL
43  (0x0D62 0x0D63 ?b)                     ; VOWEL SIGN VOCALIC L .. LL
44
45  (0x200C        ?N)                     ; ZWNJ
46  (0x200D        ?J)                     ; ZWJ
47  (0x25CC        ?X)                     ; DOTTED CIRCLE
48
49  (pstf          ?r)
50  )
51
52 ;; Stage 0
53 ;; Preprocessing
54 (generator
55  (0
56   (cond
57    ;; Decompose two-part vowel signs
58    ((0x0D4A) 0x0D46 0x0D3E)
59    ((0x0D4B) 0x0D47 0x0D3E)
60    ((0x0D4C) 0x0D46 0x0D57)
61
62    ;; Chillu letters
63    ((0x0D23 0x0D4D 0x200D) :otf=mlym=akhn,half,haln+)
64    ((0x0D28 0x0D4D 0x200D) :otf=mlym=akhn,half,haln+)
65    ((0x0D30 0x0D4D 0x200D) :otf=mlym=akhn,half,haln+)
66    ((0x0D32 0x0D4D 0x200D) :otf=mlym=akhn,half,haln+)
67    ((0x0D33 0x0D4D 0x200D) :otf=mlym=akhn,half,haln+)
68    ((0x0D15 0x0D4D 0x200D) :otf=mlym=akhn,half,haln+)
69
70    ("." =))
71   *))
72
73 ;; Stage 1
74 ;; Syllable identification
75 (generator
76  (0
77   (cond
78    ;; Consonant-based syllables
79    ;;1      23                 4
80    ("([CBPR]((J?H|HJ?)[CBPR])*)(H[NJ]?|m?p?A?)"
81     < | (1 :otf=mlym=akhn+)
82     (4 (cond ("HJ" = =)
83              ("(H)N?" (1 =) 0x200C)
84              (".+" = *))) | >)
85
86    ;; Syllables with an independent vowel
87    ("V(J?H[BPR])?m?p?A?"
88     < | = * | >)
89
90    ;; Two-part vowel signs
91    ((0x0D46 0x0D3E)
92     (cond
93      ((font-facility 0x25CC) < = 0x25CC = >)
94      (".+" < 0x0D4A >)))
95    ((0x0D47 0x0D3E)
96     (cond
97      ((font-facility 0x25CC) < = 0x25CC = >)
98      (".+" < 0x0D4B >)))
99    ((0x0D46 0x0D57)
100     (cond
101      ((font-facility 0x25CC) < = 0x25CC = >)
102      (".+" < 0x0D4C >)))
103
104    ;; Combining marks are displayed with a DOTTED CIRCLE.
105    ("m"
106     (cond
107      ((font-facility 0x25CC) < = 0x25CC >)
108      ("." [ = ])))
109    ("[HbpA]"
110     (cond
111      ((font-facility 0x25CC) < 0x25CC = >)
112      ("." [ = ])))
113
114    ;; Isolated blwf and pstf are displayed with a DOTTED CIRCLE in the
115    ;; next stage.
116    ("(J)(H)([BPR])"
117     < | (1 =) (3 =) (2 =) | >)
118
119    ("." =))
120   *))
121
122 ;; Stage 2
123 ;; Reorder halant for blwf and pstf
124 (generator
125  (0
126   (cond
127    ;; Isolated blwf and pstf
128    (" J([BP]H) "
129     (cond
130      ((font-facility 0x25CC) < 0x25CC (1 :otf=mlym=blwf,pstf+) >)
131      (" J([BP]H) " [ (1 :otf=mlym=blwf,pstf+) ])))
132
133    ;; Isolated pref
134    (" J(RH) "
135     (cond
136      ((font-facility 0x25CC) < (1 :otf=mlym=pstf+) 0x25CC >)
137      (" J(RH) " [ (1 :otf=mlym=pstf+) ])))
138
139    ;; Overt halnt forms
140    (" ([^ ]+)(HN) "
141     | (1 reorder) (2 = =) |)
142
143    ;; Ordinary syllables
144    (" ([^mbpA ]+)(m?p?A?) "
145     | (1 reorder) (2 = *) |)
146
147    ("." =))
148   *)
149
150  (reorder
151   (cond
152    ;; pref after pstf
153    ("(.|.+([^PJ]|JP))((J?HP)*J?HR)$"
154     (1 reorder-B *) (3 reorder-any *))
155    ;; pref between blwf and pstf
156    ("(.*[^J])(J?HR(J?HP)+)$"
157     (1 reorder-B *) (2 reorder-any *))
158    ;; pref before blwf
159    ("(.*[^J])(J?HR(J?HB)+(J?HP)*)$"
160     (1 reorder-B *) (2 reorder-any *))
161    ;; no pref
162    ("(.|.+([^PJ]|JP|HJ))((J?HP)*)$"
163     (1 reorder-B *) (3 reorder-any *))
164    (".+" = *)))    
165
166  (reorder-B
167   (cond
168    ("J?(H)(B)"
169     (2 =) (1 =))
170    ("." =)))
171
172  (reorder-any
173   ("J?(H)(.)"
174    (2 =) (1 =)))
175  )
176
177 ;; Stage 3
178 ;; Language forms and matra reordering
179 (generator
180  (0
181   (cond
182    ;; Overt halant forms
183    (" ([^ ]+)(HN) "
184     | (1 blwf-pstf) (2 = =) |)
185
186    ;; Other syllables
187    ;; 1          2   3
188    (" ([^mpA ]+)(m)?(p?A?) "
189     | (2 =) (1 blwf-pstf) (3 = *) |)
190
191    ("." =))
192   *)
193
194  (blwf-pstf
195   (cond
196    ;;1              23     4
197    ("(.|.+BH|.+[^H])((PH)*)(RH)$"
198     (4 :otf=mlym=pstf) (1 :otf=mlym=blwf+) (2 :otf=mlym=pstf+))
199    ;;1   2   3
200    ("(.*)(RH)((PH)+)$"
201     (2 :otf=mlym=pstf+) (1 :otf=mlym=blwf+) (3 :otf=mlym=pstf+))
202    ;;1   2   34     5
203    ("(.*)(RH)((BH)+)((PH)*)$"
204     (2 :otf=mlym=pstf+) (1 :otf=mlym=blwf+) (3 :otf=mlym=blwf+)
205     (5 :otf=mlym=pstf+))
206    ;;1              2
207    ("(.|.+BH|.+[^H])((PH)*)$"
208     (1 :otf=mlym=blwf+) (2 :otf=mlym=pstf+))))
209  )
210
211 ;; Stage 4
212 ;; Final reordering (Move pre-base matra and pref after the last halant)
213 (generator
214  (0
215   (cond
216    ;; With a pref, one or more intermediate-  and a final overt halant forms.
217    ;; 1  2         3
218    (" (r)([^ ]+HJ?)([^H ]+HN) "
219     | (2 = *) (1 =) (3 = *) |)
220
221    ;; With a pref and a final overt halant form.  Don't move the pref.
222    (" r[^H ]+HN "
223     = *)
224
225    ;; 1     2         3
226    (" (m?r?)([^ ]+HJ?)([^H ]+) "
227     | (2 = *) (1 = *) (3 = *) |)
228
229    ("." =))
230   *))
231
232 ;; Stage 5
233 ;; Remove ZWNJ/ZWJ
234 (generator
235  (0
236   (cond
237    ("[NJ]")
238
239    ("." =))
240   *))
241
242 ;; Stage 6
243 ;; GPOS processing
244 (generator
245  (0
246   (cond
247    (" ([^ ]+) "
248     (1 :otf=mlym=+abvm,blwm,dist))
249
250    ("." =))
251   *))
252
253 ;; Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009, 2010
254 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
255 ;;   Registration Number H15PRO112
256
257 ;; This file is part of the m17n database; a sub-part of the m17n
258 ;; library.
259
260 ;; The m17n library is free software; you can redistribute it and/or
261 ;; modify it under the terms of the GNU Lesser General Public License
262 ;; as published by the Free Software Foundation; either version 2.1 of
263 ;; the License, or (at your option) any later version.
264
265 ;; The m17n library is distributed in the hope that it will be useful,
266 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
267 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
268 ;; Lesser General Public License for more details.
269
270 ;; You should have received a copy of the GNU Lesser General Public
271 ;; License along with the m17n library; if not, write to the Free
272 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
273 ;; Boston, MA 02110-1301, USA.
274
275 ;; Local Variables:
276 ;; mode: emacs-lisp
277 ;; End: