Add si-wijesekera.mim.
[m17n/m17n-db.git] / KHMR-OTF.flt
1 ;; KHMR-OTF.flt -- Font Layout Table for Khmer OpenType fonts
2 ;; Copyright (C) 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> KHMR-OTF.flt
25 ;;;
26 ;;; For Khmer OpenType fonts to draw Khmer.
27 ;;; A Font is available from 
28 ;;; <http://www.khmeros.info/drupal/?q=en/download/fonts>.
29
30 (category
31  ;; E : else
32  ;; C : consonant & independent vowel
33  ;; R : RO
34  ;; r : ROBAT
35  ;; m : vowel sign (pre)
36  ;; b : vowel sign (below)
37  ;; a : vowel sign (above)
38  ;; A : vowel sign (two-part, above)
39  ;; p : vowel sign (post)
40  ;; P : vowel sign (two-part, post)
41  ;; s : sign (above)
42  ;; S : sign (post)
43  ;; c : consonant shifter
44  ;; H : COENG
45  ;; N : ZERO WIDTH NON-JOINER
46  ;; J : ZERO WIDTH JOINER
47  (0x1780 0x17FF ?E)
48  (0x19E0 0x19FF ?E)
49  (0x1780 0x17B3 ?C)
50  (0x179A        ?R)
51 ;; (0x17A3 0x17B3 ?V)
52  (0x17B6        ?p)
53  (0x17B7 0x17BA ?a)
54  (0x17BB 0x17BD ?b)
55  (0x17BE        ?A)
56  (0x17BF 0x17C0 ?P)
57  (0x17C1 0x17C3 ?m)
58  (0x17C4 0x17C5 ?P)
59  (0x17C6        ?s)
60  (0x17C7 0x17C8 ?S)
61  (0x17C9 0x17CA ?c)
62  (0x17CB 0x17D1 ?s)
63  (0x17CC        ?r)
64  (0x17D2        ?H)
65  (0x17D3        ?s)
66  (0x17DD        ?s)
67  (0x200C        ?N)
68  (0x200D        ?J)
69  )
70
71 ;; Generic syllable pattern is as follows.
72 ;; [CR](r|N?c)?(HCr?)*(HR)?(HCr?)*[NJ]?(m|b|a|A|p|P)?s*S?(H[CR])?
73
74 ;; Step 0.
75 ;; Move m to the beginning.
76 ;; Split A and P.
77 ;; Exchange the order of pP and s.
78 ;; Move HR before the base.
79
80 (generator
81  (0
82   (cond
83
84    ;; pre vowel sign
85    ;;1    2       3       4  5     67            8  9    10
86    ("([CR](r|N?c)?(HCr?)*)(HR(r)?)?((HCr?)*[NJ]?)(m)(s*S?(H[CR])?)"
87     < |
88     (8 =)
89     (4 = =)
90     (1 = *)
91     (5 =)
92     (6 = *)
93     (9 = *)
94     | > )
95
96    ;; two-part above vowel sign
97    ;;1    2       3       4  5     67                8
98    ("([CR](r|N?c)?(HCr?)*)(HR(r)?)?((HCr?)*[NJ]?As*S?(H[CR])?)"
99     < |
100     0x17C1
101     (4 = =)
102     (1 = *)
103     (5 =)
104     (6 = *)
105     | > )
106
107    ;; post vowel sign
108    ;;1    2       3       4  5     67            8  9   10 11
109    ("([CR](r|N?c)?(HCr?)*)(HR(r)?)?((HCr?)*[NJ]?)(p)(s*)(S?(H[CR])?)"
110     < |
111     (4 = =)
112     (1 = *)
113     (5 =)
114     (6 = *)
115     (9 = *)
116     (8 =)
117     (10 = *)
118     | > )
119
120    ;; two-part post vowel sign
121    ;;1    2       3       4  5     67            8  9   10 11
122    ("([CR](r|N?c)?(HCr?)*)(HR(r)?)?((HCr?)*[NJ]?)(P)(s*)(S?(H[CR])?)"
123     < |
124     0x17C1
125     (4 = =)
126     (1 = *)
127     (5 =)
128     (6 = *)
129     (9 = *)
130     (8 =)
131     (10 = *)
132     | > )
133
134    ;; other vowel signs or no vowel sign
135    ;;1    2       3       4  5     67                     8
136    ("([CR](r|N?c)?(HCr?)*)(HR(r)?)?((HCr?)*[NJ]?[b|a]?s*S?(H[CR])?)"
137     < |
138     (4 = =)
139     (1 = *)
140     (5 =)
141     (6 = *)
142     | > )
143
144    ("." =))
145   *))
146
147 ;; Now a syllable looks like below.
148 ;; m?(HR)?[CR](r|N?c)?(HCr?)*[NJ]?(b|a|A)?s*(p|P)?S?(H[CR])?
149
150 ;; Step 1.
151 ;; Set the form of consonant shifter.
152
153 (generator
154  (0
155   (cond
156    ;; shifter + above vowel sign without ZWNJ
157    ;; Shifter take blwf.  HR takes pref.  HC's take blwf or pstf.
158    ;; 1   2    3     4      5     6     7     8
159    (" (m)?(HR)?([CR]c(HCr?)*(N|J)?(a|A))(s*S?)(H[CR])? "
160     |
161     (1 =)
162     (2 otf:khmr=pref+)
163     (3 otf:khmr=blwf,abvf,pstf+)
164     (7 = *)
165     (8 otf:khmr=blwf,pstf+)
166     | )
167
168    ;; shifter + ZWNJ + above vowel sign, or, shifter without above vowel sign
169    ;; Shifter stays above.  HR takes pref.  HC's take blwf or pstf.
170    ;; 1   2    3        45       6           7   8     9   10  11
171    (" (m)?(HR)?([CR]N?c)((HCr?)*)([NJ]?[ba]?)(A)?(s*p?)(P)?(S)?(H[CR])? "
172     |
173     (1 =)
174     (2 otf:khmr=pref+)
175     (3 = *)
176     (4 otf:khmr=blwf,pstf+)
177     (6 = *)
178     (7 otf:khmr=abvf+)
179     (8 = *)
180     (9 otf:khmr=pstf+)
181     (10 =)
182     (11 otf:khmr=blwf,pstf+)
183     | )
184
185    ;; no shifter
186    ;; 1   2    3       45       6           7   8     9   10  11
187    (" (m)?(HR)?([CR]r?)((HCr?)*)([NJ]?[ba]?)(A)?(s*p?)(P)?(S)?(H[CR])? "
188     |
189     (1 =)
190     (2 otf:khmr=pref+)
191     (3 = *)
192     (4 otf:khmr=blwf,pstf+)
193     (6 = *)
194     (7 otf:khmr=abvf+)
195     (8 = *)
196     (9 otf:khmr=pstf+)
197     (10 =)
198     (11 otf:khmr=blwf,pstf+)
199     | )
200
201    ("." =))
202   *))
203
204 ;; Now a syllable looks like below.  ~ characters are OTF feature applied.
205 ;; m?(HR)?[CR](r|c)?(HCr?)*[NJ]?(b|a|A)?s*(p|P)?S?(H[CR])?
206 ;;    ~~   ~~    ~   ~~~~            ~       ~     ~~~~~
207
208 ;; Step 2.
209 ;; Concatenate adjacent Khmer syllables.
210 ;; Remove J.  Retain N to prevent ligature.
211
212 (generator
213  (0
214   (cond
215    ("  ")
216    ("J")
217    ("." =))
218   *))
219
220 ;; Step 3.
221 ;; Apply other OTF features.
222
223 (generator
224  (0
225   (cond
226    (" ([^ ]*) "
227     (1 otf:khmr=pres,blws,abvs,psts,clig))
228    ("."
229     [ otf:sinh=+ ]))
230   *))
231
232 ;; Step 4.
233 ;; Remove N to clean up.
234 (generator
235  (0
236   (cond
237    ("N")
238    ("." =))
239   *))
240
241 ;; Local Variables:
242 ;; mode: emacs-lisp
243 ;; End: