Add new characters for Unicode 5.1.
[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 (category
13  ;; C: consonant (except for R, B, and P)
14  ;; R: consonant RA
15  ;; B: consonant (below)
16  ;; P: consonant (post)
17  ;; H: HALANT
18  ;; m: vowel sign (pre)
19  ;; b: vowel sign (below)
20  ;; p: vowel sign (post)
21  ;; A: vowel modifier (post)
22  ;; V: independent vowel
23  ;; N: ZWNJ (ZERO WIDTH NON-JOINER)
24  ;; J: ZWJ (ZERO WIDTH JOINER)
25  ;; X: generic
26  ;; Z: internal use
27  (0x0D00 0x0D7F ?X)                     ; generic
28  (0x0D00        ?Z)                     ; internal use
29  (0x0D02 0x0D03 ?A)                     ; SIGN ANUSVARA .. VISARGA
30  (0x0D05 0x0D14 ?V)                     ; LETTER A .. AU
31  (0x0D15 0x0D39 ?C)                     ; LETTER KA .. HA
32  (0x0D2F        ?P)                     ; LETTER YA
33  (0x0D30        ?R)                     ; LETTER RA
34  (0x0D32        ?B)                     ; LETTER LA
35  (0x0D35        ?P)                     ; LETTER VA
36  (0x0D3E 0x0D44 ?p)                     ; VOWEL SIGN AA .. VOCALIC RR
37  (0x0D46 0x0D48 ?m)                     ; VOWEL SIGN E .. AI
38  (0x0D4D        ?H)                     ; SIGN VIRAMA
39  (0x0D57        ?p)                     ; AU LENGTH MARK
40  (0x0D60 0x0D61 ?V)                     ; LETTER VOCALIC RR .. VOCALIC LL
41  (0x0D62 0x0D63 ?b)                     ; VOWEL SIGN VOCALIC L .. LL
42  (0x0D7A 0x0D7F ?C)                     ; LETTER CHILLU NN .. K
43  (0x0964 0x0965 ?X)                     ; DANDA .. DOUBLE DANDA
44  (0x200C        ?N)                     ; ZWNJ
45  (0x200D        ?J)                     ; ZWJ
46  )
47
48 ;; Decompose two-part vowels.
49 (generator
50  (0
51   (cond
52    ((0x0D4A)
53     0x0D46 0x0D3E)
54    ((0x0D4B)
55     0x0D47 0x0D3E)
56    ((0x0D4C)
57     0x0D46 0x0D57)
58    ("." =))
59   *))
60
61 ;; Syllable identification and reordering.  
62 ;; Put the mark 0x0D00 before the first pre-base consonant and after
63 ;; the base consonant.
64 (generator
65  (0
66   (cond
67    ;; A syllable with a left vowel sign.
68    ;;1      2          3  4
69    ("([CRBP](H[CRBP])*)(m)(p?A?)"
70     < | (3 =) (1 get-rh) 0x0D00 (1 move-h) (4 = *) | >)
71
72    ;; A syllable with a right vowel sign, a below vowel sign
73    ;; and/or a vowel modifier.
74    ;;1      2          3
75    ("([CRBP](H[CRBP])*)(bA?|pA?|A)"
76     < | (1 get-rh) 0x0D00 (1 move-h) (3 = *) | >)
77
78    ;; Explicit Halant / forced chillu form is cut off from the preceders.
79    ("(([CRBP]H)*)([CRBP]H[NJ])"
80     (1 cut-off) (3 < | = * | >))
81
82    ;; A syllable with no vowel signs/modifiers.
83    ("([CRBP](H[CRBP])*H?)"
84     < | (1 get-rh) 0x0D00 (1 move-h) | >)
85
86    ;; Starting with an independent vowel.
87    ("(VA?)"
88     < | (1 = *) | >)
89
90    ("." =))
91   *)
92
93  ;; Extract RH that will be moved to the left.
94  (get-rh
95   (cond
96    (".+HR$"
97     0x0D30 0x0D4D)))
98
99  ;; Move the halant after the base consonant to the end.
100  ;; Fill the resulting gap with 0x0D00.
101  ;; Remove final RH if any.
102  (move-h
103   (cond
104    ;; There is a C and the syllable ends with an R.  Remove final RH.
105    ("([CRBPH]*C)H([RBPH]*)R$"
106     (1 = *) 0x0D00 (2 = *))
107
108    ;; The syllable ends other than R.  Move H.
109    ("([CRBPH]*C)(H)([RBPH]+)$"
110     (1 = *) 0x0D00 (3 = *) (2 =))
111
112    ;; No C and end with R.  The first consonant will be the base.  Remove RH.
113    ("([RBP])H([RBPH]*)R$"
114     (1 =) 0x0D00 (2 = *))
115
116    ;; No C and not end with R.  Move H.
117    ("([RBP])(H)([RBPH]+)$"
118     (1 =) 0x0D00 (3 = *) (2 =))
119
120    ;; Otherwise, no need to move H.
121    (".+"
122     = * 0x0D00)))
123
124  ;; If there are some letters make them a separate syllable.
125  (cut-off
126   (cond
127    (".+"
128     < | = * | >)))
129  )
130
131 ;; Apply GSUB features.
132 ;; According to Microsoft Typography
133 ;; <http://www.microsoft.com/typography/otfntdev/malayot/features.htm>
134 ;; 'chillu' are generated with the 'haln' feature.  However, some
135 ;; fonts generate them with 'half'.
136 (generator
137  (0
138   (cond
139    ;; Ordinary syllable.  We must avoid applying 'blwf' and 'pstf' to
140    ;; the first consonant.  Also 'haln' and 'half' must be avoided
141    ;; because chillu does not appear at the beginning of a word.  Thus
142    ;; we apply only 'akhn' here and postpone applying other features
143    ;; to the next stage.
144    ;; 1  2      3         4  5
145    (" (m?(RH)?Z)([CRBPH]+)(Z)([RBPHbpA]*) "
146     | (1 = *) (3 otf:mlym=akhn+) (4 =) (5 otf:mlym=blwf,pstf+) |)
147
148    ;; Explicit Halant.
149    (" [CRBP]HN "
150     = *)
151
152    ;; Forced chillu form.
153    (" ([CRBP]H)(J) "
154     | (1 otf:mlym=haln,half+) (2 =) |)
155
156    ;; Sequence that was cut off from a forced form.  Again we apply
157    ;; only 'akhn' here.
158    (" ([CRBPH]+) "
159     | (1 otf:mlym=akhn+) |)
160
161    ("." =))
162   *))
163
164 ;; Apply postoponed GSUB features to ordinary syllables.
165 (generator
166  (0
167   (cond
168    ;; Ordinary syllable.
169    ;; 1  2          3      4 
170    (" (m?(RH)?Z[^Z])([^Z]*)(Z[^ ]*) "
171     | (1 = *) (3 otf:mlym=blwf,half,pstf,haln+) (4 = *) |)
172
173    ;; Explicit Halant / Forced chillu must not change to others.
174    (" ([^ ]+)[NJ] "
175     | (1 = *) |)
176
177    ;; Cut off sequence.
178    (" ([^ ])([^ ]*) "
179     | (1 =) (2 otf:mlym=blwf,half,pstf,haln+) |)
180
181    ("." =))
182   *))
183
184 ;; Second reordering.  If there are glyphs before the base, move left
185 ;; vowel sign and RH to the left of the base.
186 (generator
187  (0
188   (cond
189    ;; 1   2     3      4      5
190    (" (m)?(RH)?Z([^Z]*)([^Z])Z([^ ]*) "
191     | (3 = *) (1 =) (2 otf:mlym=pstf+) (4 =) (5 = *) |)
192
193    ("." =))
194   *))
195
196 ;; Apply substitutions and GPOS features.
197 (generator
198  (0
199   (cond
200    (" ([^ ]+) "
201     (1 otf:mlym=pres,abvs,blws,psts+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: