Versions changed to 1.6.1.
[m17n/m17n-db.git] / FLT / MLM2-OTF.flt
1 ;; MLM2-OTF.flt -- Font Layout Table for mlm2 OpenType fonts
2 ;; Copyright (C) 2010 AIST (H15PRO112)
3 ;; See the end for copying conditions.
4
5 (font layouter mlm2-otf nil
6       (version "1.6.0")
7       (font (nil nil unicode-bmp :otf=mlm2)))
8
9 ;;; <li> MLM2-OTF.flt
10 ;;;
11 ;;; For mlm2 OpenType fonts to draw the Malayalam script.  
12
13 ;; Observed behaviour of Uniscribe in combination with kartika.ttf:
14
15 ;; 1. Only the last RA can take the pref form.  This last RA can come
16 ;;  a) just before blwf consonants
17 ;;  b) between blwf consonants and pstf consonants, or
18 ;;  c) after pstf consonants.
19
20 ;; 2. Multiple blwf forms are allowed anywhere in a syllable as long
21 ;; as the context (the combination of the preceding consonant and the
22 ;; blwf consonant) permits.
23
24 ;; 3. Multiple pstf forms are allowed as long as they are the last
25 ;; consonants, optionally followed by a RA.
26
27 ;; About chillu letters:
28
29 ;; The sequence "consonant + VIRAMA + ZWJ" represents a chillu letter,
30 ;; which makes an independent syllable.  The only exception is "CHILLU
31 ;; N + RRA" (0D7B 0D31) and its equivalent "NA + VIRAMA + ZWJ + RRA"
32 ;; (0D28 0D4D 200D 0D31), which make a ligature.
33
34 (category
35  (0x0D00 0x0D7F ?X)                     ; generic
36  (0x0D02 0x0D03 ?A)                     ; SIGN ANUSVARA .. VISARGA
37  (0x0D05 0x0D14 ?V)                     ; LETTER A .. AU
38  (0x0D15 0x0D39 ?C)                     ; LETTER KA .. HA
39  (0x0D3E 0x0D44 ?p)                     ; VOWEL SIGN AA .. VOCALIC RR
40  (0x0D46 0x0D48 ?m)                     ; VOWEL SIGN E .. AI
41  (0x0D4D        ?H)                     ; SIGN VIRAMA
42  (0x0D57        ?p)                     ; AU LENGTH MARK
43  (0x0D60 0x0D61 ?V)                     ; LETTER VOCALIC RR .. VOCALIC LL
44  (0x0D62 0x0D63 ?b)                     ; VOWEL SIGN VOCALIC L .. LL
45
46  (0x200C        ?N)                     ; ZWNJ
47  (0x200D        ?J)                     ; ZWJ
48  (0x25CC        ?X)                     ; DOTTED CIRCLE
49
50  (akhn          ?C)
51  (blwf          ?B)
52  (pstf          ?P)
53  (pref          ?R)
54  )
55
56 ;; Stage 0
57 ;; Preprocessing
58 (generator
59  (0
60   (cond
61    ;; Decompose two-part vowel signs
62    ((0x0D4A) 0x0D46 0x0D3E)
63    ((0x0D4B) 0x0D47 0x0D3E)
64    ((0x0D4C) 0x0D46 0x0D57)
65
66    ;; Replace CHILLU N + RRA with a pseudo-consonant
67    ((0x0D7B 0x0D31) :otf=mlm2=akhn+)
68    ((0x0D28 0x0D4D 0x200D 0x0D31) :otf=mlm2=akhn+)
69
70    ;; Other chillu letters
71    ((0x0D23 0x0D4D 0x200D) 0x0D7A)
72    ((0x0D28 0x0D4D 0x200D) 0x0D7B)
73    ((0x0D30 0x0D4D 0x200D) 0x0D7C)
74    ((0x0D32 0x0D4D 0x200D) 0x0D7D)
75    ((0x0D33 0x0D4D 0x200D) 0x0D7E)
76    ((0x0D15 0x0D4D 0x200D) 0x0D7F)
77
78    ("." =))
79   *))
80
81 ;; Stage 1
82 ;; Syllable identification
83 (generator
84  (0
85   (cond
86    ;; Consonant-based syllables
87    ("(CJ?HJ?)*C(H[NJ]?|m?b?p?)A?"
88     < | = * | >)
89
90    ;; Syllables with an independent vowel
91    ("V(J?HC)?m?b?p?A?"
92     < | = * | >)
93
94    ;; Two-part vowel signs
95    ((0x0D46 0x0D3E)
96     (cond
97      ((font-facility 0x25CC) < 0x0D46 0x25CC 0x0D3E >)
98      (".+" < 0x0D4A >)))
99    ((0x0D47 0x0D3E)
100     (cond
101      ((font-facility 0x25CC) < 0x0D47 0x25CC 0x0D3E >)
102      (".+" < 0x0D4B >)))
103    ((0x0D46 0x0D57)
104     (cond
105      ((font-facility 0x25CC) < 0x0D46 0x25CC 0x0D57 >)
106      (".+" < 0x0D4C >)))
107
108    ;; Combining marks are displayed with a DOTTED CIRCLE.
109    ("m"
110     (cond
111      ((font-facility 0x25CC) < = 0x25CC >)
112      ("." [ = ])))
113    ("[HbpA]"
114     (cond
115      ((font-facility 0x25CC) < 0x25CC = >)
116      ("." [ = ])))
117    ((0x200D 0x0D4D 0x0D30)
118     (cond
119      ((font-facility 0x25CC) < :otf=mlm2=pref+ 0x25CC >)
120      (".+" [ :otf=mlm2=pref+ ])))
121    ("JHC"
122     (cond
123      ((font-facility 0x25CC) < 0x25CC :otf=mlm2=blwf,pstf+ >)
124      (".+" [ :otf=mlm2=blwf,pstf+ ])))
125
126    ("." =))
127   *))
128
129 ;; Stage 2
130 ;; Basic shaping forms and matra reordering
131 (generator
132  (0
133   :otf?mlm2=locl,akhn,pref,blwf,pstf+
134
135   (cond
136    ;; pref after pstf
137    ;; 1                23         4   5        6   7
138    (" ([CRBPHJ]*[CRBV])((J?PP)*)J?(RR)(H[NJ]?)?(m)?(b?p?A?) "
139     | (6 =) (4 :otf=mlm2=pref+) (1 :otf=mlm2=locl,akhn,blwf,half,cjct+)
140     (2 :otf=mlm2=pstf+) (5 = *) (7 = *) |)
141
142    ;; pref between blwf and pstf
143    ;; 1           2   34       5        6   7
144    (" ([CRBPHJV]+)(RR)((J?PP)+)(H[NJ]?)?(m)?(b?p?A?) "
145     | (6 =) (2 :otf=mlm2=pref+) (1 :otf=mlm2=locl,akhn,blwf,half,cjct+)
146     (3 :otf=mlm2=pstf+) (5 = *) (7 = *) |)
147
148    ;; pref before blwf
149    ;; 1           2   34       56       7        8   9
150    (" ([CRBPHJV]+)(RR)((J?BB)+)((J?PP)*)(H[NJ]?)?(m)?(b?p?A?) "
151     | (8 =) (2 :otf=mlm2=pref+) (1 :otf=mlm2=locl,akhn,blwf,half,cjct+)
152     (3 :otf=mlm2=blwf+) (5 :otf=mlm2=pstf+) (7 = *) (9 = *) |)
153
154    ;; no pref
155    ;; 1                23       4        5   6
156    (" ([CRBPHJ]*[CRBV])((J?PP)*)(H[NJ]?)?(m)?(b?p?A?) "
157     | (5 =) (1 :otf=mlm2=locl,akhn,blwf,half,cjct+) (2 :otf=mlm2=pstf+)
158     (4 = *) (6 = *) |)
159
160    ("." =))
161   *))
162
163 ;; Stage 3
164 ;; Final reordering (Move pre-base matra and pre-base RA after the last halant)
165 (generator
166  (0
167   (cond
168    ;; 1     2       3
169    (" (m?R?)([^ ]+H)([^H ]+) "
170     | (2 = *) (1 = *) (3 = *) |)
171
172    ("." =))
173   *))
174
175 ;; Stage 4
176 ;; Presentation forms
177 (generator
178  (0
179   (cond
180    (" ([^ ]+) "
181     | (1 :otf=mlm2=pres,abvs,blws,psts,haln,calt+) |)
182
183    ("." =))
184   *))
185
186 ;; Stage 5
187 ;; Remove ZWNJ/ZWJ
188 (generator
189  (0
190   (cond
191    ("[NJ]")
192
193    ("." =))
194   *))
195
196 ;; Stage 6
197 ;; GPOS processing
198 (generator
199  (0
200   (cond
201    (" ([^ ]+) "
202     (1 :otf=mlm2=+kern,dist,abvm,blwm))
203
204    ("." =))
205   *))
206
207 ;; Copyright (C) 2010
208 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
209 ;;   Registration Number H15PRO112
210
211 ;; This file is part of the m17n database; a sub-part of the m17n
212 ;; library.
213
214 ;; The m17n library is free software; you can redistribute it and/or
215 ;; modify it under the terms of the GNU Lesser General Public License
216 ;; as published by the Free Software Foundation; either version 2.1 of
217 ;; the License, or (at your option) any later version.
218
219 ;; The m17n library is distributed in the hope that it will be useful,
220 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
221 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
222 ;; Lesser General Public License for more details.
223
224 ;; You should have received a copy of the GNU Lesser General Public
225 ;; License along with the m17n library; if not, write to the Free
226 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
227 ;; Boston, MA 02110-1301, USA.
228
229 ;; Local Variables:
230 ;; mode: emacs-lisp
231 ;; End: