Interpret CHCHJ as CHCH J rather than CH CHJ.
[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 and VA, but not for RA and LA.
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 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  (0x0D35        ?P)                     ; LETTER VA
43  (0x0D3E 0x0D44 ?p)                     ; VOWEL SIGN AA .. VOCALIC RR
44  (0x0D46 0x0D48 ?m)                     ; VOWEL SIGN E .. AI
45  (0x0D4D        ?H)                     ; SIGN VIRAMA
46  (0x0D57        ?p)                     ; AU LENGTH MARK
47  (0x0D60 0x0D61 ?V)                     ; LETTER VOCALIC RR .. VOCALIC LL
48  (0x0D62 0x0D63 ?b)                     ; VOWEL SIGN VOCALIC L .. LL
49  (0x0964 0x0965 ?X)                     ; DANDA .. DOUBLE DANDA
50  (0x200C        ?N)                     ; ZWNJ
51  (0x200D        ?J)                     ; ZWJ
52  )
53
54 ;; Stage 0
55 ;; Decompose two-part vowels.
56 (generator
57  (0
58   (cond
59    ((0x0D4A)
60     0x0D46 0x0D3E)
61    ((0x0D4B)
62     0x0D47 0x0D3E)
63    ((0x0D4C)
64     0x0D46 0x0D57)
65    ("." =))
66   *))
67
68 ;; Stage 1
69 ;; Syllable identification and reordering.  
70 ;; Put the mark Z after the base consonant.
71 (generator
72  (0
73   (cond
74    ;; A syllable with a left vowel sign.
75    ;;1    2        3  4
76    ("([CP](H[CP])*)(m)(p?A?)"
77     < | (3 =) (1 move-h) (4 = *) | >)
78
79    ;; A syllable with a right vowel sign, a below vowel sign
80    ;; and/or a vowel modifier.
81    ;;1    2        3
82    ("([CP](H[CP])*)(bA?|pA?|A)"
83     < | (1 move-h) (3 = *) | >)
84
85    ;; Forced chillu form.
86    ;;1    2        3
87    ("([CP](H[CP])*)(HJ)"
88     < | (1 move-h) (3 = =) | >)
89
90    ;; A syllable with no vowel signs/modifiers, optionally followed by
91    ;; an H or an HN.
92    ;;1    2        3
93    ("([CP](H[CP])*)(H|HN)?"
94     < | (1 move-h) (3 0x0D4D) | >)
95
96    ;; Starting with an independent vowel.
97    ("VA?"
98     < | (0 = *) | >)
99
100    ("." =))
101   *)
102
103
104  ;; Move the halant that follows the base consonant to the end.
105  (move-h
106   (cond
107    ;; All consonants are P's.
108    ("(P)(H)([PH]*)$"
109     (1 =) 0x0D00 (3 = *) (2 =))
110
111    ;; One or more Non-P consonants.
112    ("([CPH]*C)(H)([PH]+)$"
113     (1 = *) 0x0D00 (3 = *) (2 =))
114
115    ;; Otherwise, final consonant is not P.  No need to move H.
116    (".+"
117     = * 0x0D00)))
118  )
119
120 ;; Stage 2
121 ;; Apply GSUB features.
122 (generator
123  (0
124   (cond
125    ;; The tested fonts make LA's below form with 1. 'half' + 'blws',
126    ;; 2. 'half' + 'pres' or 3. 'akhn'.
127    ;; 1   2       3  4
128    (" (m)?([CPH]*)(Z)([PHbpAJ]*) "
129     | (1 =) (2 otf:mlym=akhn,half,pstf,pres,abvs,blws+) (3 =)
130     (4 otf:mlym=pstf+) |)
131
132    ("." =))
133   *))
134
135 ;; Stage 3
136 ;; Second reordering.  If there are glyphs before the base, move left
137 ;; vowel sign to the left of the base.
138 (generator
139  (0
140   (cond
141    ;; 1   2       3      4
142    (" (m)?([^Z ]*)([^Z])Z([^ ]*) "
143     | (2 = *) (1 =) (3 =) (4 = *) |)
144
145    ("." =))
146   *))
147
148 ;; Stage 4
149 ;; Apply remaining GSUB and GPOS features to all syllables.  To get
150 ;; correct Y.YA and V.VA conjunctions, we must apply 'psts' to the
151 ;; entire syllable.
152 (generator
153  (0
154   (cond
155    (" ([^ ]+) "
156     (1 otf:mlym=psts,haln+abvm,blwm,dist))
157    ("."
158     [ = ]))
159   *))
160
161 ;; Copyright (C) 2003, 2004, 2005, 2007, 2008
162 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
163 ;;   Registration Number H15PRO112
164
165 ;; This file is part of the m17n database; a sub-part of the m17n
166 ;; library.
167
168 ;; The m17n library is free software; you can redistribute it and/or
169 ;; modify it under the terms of the GNU Lesser General Public License
170 ;; as published by the Free Software Foundation; either version 2.1 of
171 ;; the License, or (at your option) any later version.
172
173 ;; The m17n library is distributed in the hope that it will be useful,
174 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
175 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
176 ;; Lesser General Public License for more details.
177
178 ;; You should have received a copy of the GNU Lesser General Public
179 ;; License along with the m17n library; if not, write to the Free
180 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
181 ;; Boston, MA 02110-1301, USA.
182
183 ;; Local Variables:
184 ;; mode: emacs-lisp
185 ;; End: