*** empty log message ***
[m17n/m17n-db.git] / MLYM-OTF.flt
1 ;; MLYM-OTF.flt -- Font Layout Table for Malayalam OpenType font
2 ;; Copyright (C) 2003, 2004, 2005
3 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
4 ;;   Registration Number H15PRO112
5
6 ;; This file is part of the m17n database; a sub-part of the m17n
7 ;; library.
8
9 ;; The m17n library is free software; you can redistribute it and/or
10 ;; modify it under the terms of the GNU Lesser General Public License
11 ;; as published by the Free Software Foundation; either version 2.1 of
12 ;; the License, or (at your option) any later version.
13
14 ;; The m17n library is distributed in the hope that it will be useful,
15 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 ;; Lesser General Public License for more details.
18
19 ;; You should have received a copy of the GNU Lesser General Public
20 ;; License along with the m17n library; if not, write to the Free
21 ;; Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 ;; 02111-1307, USA.
23
24 ;;; <li> MLYM-OTF.flt
25 ;;;
26 ;;; For Malayalam OpenType fonts to draw the reformed Malayalam script.
27
28 ;; The first stage is to extract a syllable and re-order characters.
29 (category
30  ;; C: consonant (except for BPR)
31  ;; B: consonant that is the subject of "blws" feature
32  ;; P: consonant that is the subject of "pstf" feature
33  ;; R: consonant RA
34  ;; H: HALANT (VIRAMA)
35  ;; m: MATRA (Mpre)
36  ;; p: MATRA (Mpost)
37  ;; t: MATRA (two-part: Mpre+Mpost)
38  ;; A: vowel modifier (post) (ANUSVARA and VISARGA)
39  ;; V: independent vowel
40  ;; N: ZWNJ (ZERO WIDTH NON-JOINER)
41  ;; J: ZWJ (ZERO WIDTH JOINER)
42  ;; E: else (all other independnt characters)
43  (0x0D00 0x0D7F ?E)                     ; else
44  (0x0D02 0x0D03 ?A)                     ; ANUSVARA & VISARGA
45  (0x0D05 0x0D14 ?V)                     ; independent vowel
46  (0x0D15 0x0D39 ?C)                     ; consonant
47
48  ;; Accorind to www.microsoft.com/typography/otfntdev/indicot/appen.htm,
49  ;; these must be classified into 'B' category, but at least, it
50  ;; doesn't work with this font
51  ;; http://www.supersoftweb.com/THOOLIUC.TTF
52  ;;(0x0D1F      ?B)                     ; TTA
53  ;;(0x0D23      ?B)                     ; NNA
54  ;;(0x0D26      ?B)                     ; DA
55  (0x0D2F        ?P)                     ; YA
56  (0x0D30        ?R)                     ; RA
57  (0x0D32        ?B)                     ; LA
58  (0x0D35        ?P)                     ; VA
59  (0x0D3E 0x0D43 ?p)                     ; dependent vowel (Mpost)
60  (0x0D46 0x0D48 ?m)                     ; dependent vowel (Mpre)
61  (0x0D4A 0x0D4C ?t)                     ; dependent vowel (two-part)
62  (0x0D4D        ?H)                     ; VIRAMA (HALANT)
63  (0x0D57        ?p)                     ; dependent vowel (Mpost)
64  (0x0D60        ?V)                     ; VOCALIC RR
65  (0x0D61        ?V)                     ; VOCALIC LL
66  (0x200C        ?N)                     ; ZWNJ
67  (0x200D        ?J)                     ; ZWJ
68  (0x0D7D        ?x)                     ; marker inserted before base-C
69  (0x0D7E        ?y)                     ; marker inserted after base-C
70  (0x0D7F        ?z)                     ; marker inserted before last Ra
71  )
72
73 ;; The 1st stage is to extract a syllable while moving a Halant
74 ;; following Cbase to the tail and partitioning two-part matras into
75 ;; parts.
76 (generator
77  (0
78   (cond
79    ;; If [CR]H is followed by ZWNJ/ZWJ, move ZWNJ/ZWJ) to the head so
80    ;; that the later stages find it quickly.
81    ("([CBPR]H)([NJ])"
82     < | (2 =) (1 = =) | >)
83
84    ;; A syllable starting with a consonant and ending with a vowel
85    ;; and/or a vowel modifier.
86    ("(([CBPR]H)*[CBPR])([pmt]A?|A)"
87     < | (1 move-halant) (3 partition = =) | >)
88
89    ;; A syllable starting with a consonant and ending without a vowel
90    ;; nor a vowel modifier.
91    ("(([CBPR]H)*[CBPR])(H)?"
92     < | (1 move-halant) (3 =) | >)
93
94    ;; A syllable starting with an independent vowel.
95    ("(VA?)"
96     < | (1 = *) | >)
97
98    ;; Other independent character.
99    ("." =))
100   *)
101
102  ;; Move Halant to the tail if necessary.  Insert 0x0D7D before Cbase,
103  ;; 0x0D7E after Cbase, 0x0D7F before the tailing RH (if any).  They
104  ;; work as markers in the following stages.
105  (move-halant
106   (cond
107    ;; In the first two cases, we don't have to move Halant.
108    ("[BPR]$"                            ; Single consonant.
109     0x0D7D 0x0D7E =)
110    ("(([CBPR]H)*)(C)$"                  ; Cbase is at tail.
111     (1 = *) 0x0D7D (3 =) 0x0D7E)
112    ;; In the following cases, we must move Halant to the tail.
113    ("(([CBPR]H)*)([C])H(([BR]H)*)(R)$"  ; Cbase is at head or middle.
114     (1 = *) 0x0D7D (3 =) 0x0D7E (4 = *) 0x0D7F 0x0D30 0x0D4D)
115    ("(([CBPR]H)*)([C])H(([BR]H)*[BP])$" ; Cbase is at head or middle.
116     (1 = *) 0x0D7D (3 =) 0x0D7E (4 = *) 0x0D4D)
117    ("(RH)?(.)H(.*)$"                    ; No Cbase, move the first
118                                         ; Halant to the tail.
119     (1 = *) 0x0D7D (2 = ) 0x0D7E (3 = *) 0x0D4D)))
120
121  ;; Partition two-part matras into parts.
122  (partition
123   (cond
124    ((0x0D4A)    0x0D46 0x0D3E)
125    ((0x0D4B)    0x0D47 0x0D3E)
126    ;; Unicode suggests this partitioning:
127    ((0x0D4C)    0x0D46 0x0D57)
128    ;; but it is questionable.  Perhaps, this substitution is better.
129    ;; ((0x0D4C) 0x0D57)
130    )))
131
132 ;; The 2nd stage is to apply GSUB for prebase part.
133 (generator
134  (0
135   (cond
136    ;; Originally [CBPR]H is followed by ZWNJ.  Apply no feature (just
137    ;; cmap).
138    (" N([^ ]*) "
139     (1 otf:mlym=+))
140
141    ;; Originally [CBPR]H is followed by ZWJ.  Apply only GSUB haln
142    ;; feature.
143    (" J([^ ]*) "
144     (1 otf:mlym=haln+))
145
146    ;; Syllable starting with a consonant should match this pattern.
147    (" ([^ y]*)y([^ z]*)(z..)?([^ ]*) "
148     |
149     (1 otf:mlym=~blwf,~pstf,~blws,~psts,*+) ; Prebase part.
150     0x0D7E                                 ; Preserve this marker.
151     (2 = *)                                ; Postbase part.
152     (3 = *)                                ; Optional tailing RH.
153     (4 = *)                                ; Optional Mpost.
154     |)
155
156    ;; A syllable starting with an independent vowel.
157    (" ([^ ]*) "
158     (1 otf:mlym+))
159
160    ;; Any other independent character.  Apply no feature (just cmap).
161    ("."
162     [ otf:mlym=+ ] ))
163   *))
164
165 ;; The 3rd stage is to move Mpre (if any) and tailing RH (if any)
166 ;; forward to just before the base consonant.
167 (generator
168  (0
169   (cond
170    (" ([^x]*)(.)xy([^ zm]*)(z(..))?(m)?([^ ]*) "
171     | (1 = *) (4 (5 otf:mlym=pstf+)) (6 =) 0x0D7D (2 =) (3 = *) (7 = *) |)
172    (" ([^x]*)x(.)y([^ zm]*)(z(..))?(m)?([^ ]*) "
173     | (1 = *) (4 (5 otf:mlym=pstf+)) (6 =) 0x0D7D (2 =) (3 = *) (7 = *) |)
174    (" xy([^ m]*)(m)?([^ ]*) "
175     | (2 =) 0x0D7D (1 = *) (3 = *) |)
176    ("[NJ]")
177    ("."
178     = ))
179   *))
180
181 ;; The 4th stage is to apply GSUB to postbase part.
182 (generator
183  (0
184   (cond
185    (" ([^x]*)x(.H) "
186     | (1 = *) (2 otf:mlym=haln) |)
187    (" ([^x]*)x([^ ]*) "
188     | (1 = *) (2 otf:mlym=~akhn,~haln,blwf,pstf,vatu,*+) |)
189    ("." =))
190   *))
191
192
193
194 ;; The 5th (last) stage is to apply GPOS features.
195 (generator
196  (0
197   (cond
198    (" ([^ ]*) " (1 otf:mlym=))
199    ("." =))
200   *))
201
202 ;; Local Variables:
203 ;; mode: emacs-lisp
204 ;; End: