Rewritten to emulate the new OTF behaviour by using old fonts.
[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) < 0x0D46 0x25CC 0x0D3E >)
94      (".+" < 0x0D4A >)))
95    ((0x0D47 0x0D3E)
96     (cond
97      ((font-facility 0x25CC) < 0x0D47 0x25CC 0x0D3E >)
98      (".+" < 0x0D4B >)))
99    ((0x0D46 0x0D57)
100     (cond
101      ((font-facility 0x25CC) < 0x0D46 0x25CC 0x0D57 >)
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])((J?HP)*J?HR)$"
154     (1 reorder-B) (2 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])((J?HP)*)$"
163     (1 reorder-B) (2 reorder-any))
164    (".+" = *)))    
165
166  (reorder-B
167   (cond
168    ("J?(H)(B)(.*)"
169     (2 =) (1 =) (3 reorder-B))
170    ("(.)(.*)"
171     (1 =) (2 reorder-B))))
172
173  (reorder-any
174   ("J?(H)(.)(.*)"
175    (2 =) (1 =) (3 reorder-any)))
176  )
177
178 ;; Stage 3
179 ;; Language forms and matra reordering
180 (generator
181  (0
182   (cond
183    ;; Overt halant forms
184    (" ([^ ]+)(HN) "
185     | (1 blwf-pstf) (2 = =) |)
186
187    ;; Other syllables
188    ;; 1          2   3
189    (" ([^mpA ]+)(m)?(p?A?) "
190     | (2 =) (1 blwf-pstf) (3 = *) |)
191
192    ("." =))
193   *)
194
195  (blwf-pstf
196   (cond
197    ;;1              23     4
198    ("(.|.+BH|.+[^H])((PH)*)(RH)$"
199     (4 :otf=mlym=pstf) (1 :otf=mlym=blwf+) (2 :otf=mlym=pstf+))
200    ;;1   2   3
201    ("(.*)(RH)((PH)+)$"
202     (2 :otf=mlym=pstf+) (1 :otf=mlym=blwf+) (3 :otf=mlym=pstf+))
203    ;;1   2   34     5
204    ("(.*)(RH)((BH)+)((PH)*)$"
205     (2 :otf=mlym=pstf+) (1 :otf=mlym=blwf+) (3 :otf=mlym=blwf+)
206     (5 :otf=mlym=pstf+))
207    ;;1              2
208    ("(.|.+BH|.+[^H])((PH)*)$"
209     (1 :otf=mlym=blwf+) (2 :otf=mlym=pstf+))))
210  )
211
212 ;; Stage 4
213 ;; Final reordering (Move pre-base matra and pref after the last halant)
214 (generator
215  (0
216   (cond
217    ;; With a pref, one or more intermediate-  and a final overt halant forms.
218    ;; 1  2         3
219    (" (r)([^ ]+HJ?)([^H ]+HN) "
220     | (2 = *) (1 =) (3 = *) |)
221
222    ;; With a pref and a final overt halant form.  Don't move the pref.
223    (" r[^H ]+HN "
224     = *)
225
226    ;; 1     2         3
227    (" (m?r?)([^ ]+HJ?)([^H ]+) "
228     | (2 = *) (1 = *) (3 = *) |)
229
230    ("." =))
231   *))
232
233 ;; Stage 5
234 ;; Remove ZWNJ/ZWJ
235 (generator
236  (0
237   (cond
238    ("[NJ]")
239
240    ("." =))
241   *))
242
243 ;; Stage 6
244 ;; GPOS processing
245 (generator
246  (0
247   (cond
248    (" ([^ ]+) "
249     (1 :otf=mlym=+abvm,blwm,dist))
250
251    ("." =))
252   *))
253
254 ;; Copyright (C) 2003, 2004, 2005, 2007, 2008, 2009, 2010
255 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
256 ;;   Registration Number H15PRO112
257
258 ;; This file is part of the m17n database; a sub-part of the m17n
259 ;; library.
260
261 ;; The m17n library is free software; you can redistribute it and/or
262 ;; modify it under the terms of the GNU Lesser General Public License
263 ;; as published by the Free Software Foundation; either version 2.1 of
264 ;; the License, or (at your option) any later version.
265
266 ;; The m17n library is distributed in the hope that it will be useful,
267 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
268 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
269 ;; Lesser General Public License for more details.
270
271 ;; You should have received a copy of the GNU Lesser General Public
272 ;; License along with the m17n library; if not, write to the Free
273 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
274 ;; Boston, MA 02110-1301, USA.
275
276 ;; Local Variables:
277 ;; mode: emacs-lisp
278 ;; End: