New file.
[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    56            7  8    9
86    ("([CR](r|N?c)?(HCr?)*)(HR)?((HCr?)*[NJ]?)(m)(s*S?(H[CR])?)"
87     < |
88     (7 =)
89     (4 = =)
90     (1 = *)
91     (5 = *)
92     (8 = *)
93     | > )
94
95    ;; two-part above vowel sign
96    ;;1    2       3       4    56                7
97    ("([CR](r|N?c)?(HCr?)*)(HR)?((HCr?)*[NJ]?As*S?(H[CR])?)"
98     < |
99     0x17C1
100     (4 = =)
101     (1 = *)
102     (5 = *)
103     | > )
104
105    ;; post vowel sign
106    ;;1    2       3       4    56            7  8   9  10
107    ("([CR](r|N?c)?(HCr?)*)(HR)?((HCr?)*[NJ]?)(p)(s*)(S?(H[CR])?)"
108     < |
109     (4 = =)
110     (1 = *)
111     (5 = *)
112     (8 = *)
113     (7 =)
114     (9 = *)
115     | > )
116
117    ;; two-part post vowel sign
118    ;;1    2       3       4    56            7  8   9  10
119    ("([CR](r|N?c)?(HCr?)*)(HR)?((HCr?)*[NJ]?)(P)(s*)(S?(H[CR])?)"
120     < |
121     0x17C1
122     (4 = =)
123     (1 = *)
124     (5 = *)
125     (8 = *)
126     (7 =)
127     (9 = *)
128     | > )
129
130    ;; other vowel signs or no vowel sign
131    ;;1    2       3       4    56                     7
132    ("([CR](r|N?c)?(HCr?)*)(HR)?((HCr?)*[NJ]?[b|a]?s*S?(H[CR])?)"
133     < |
134     (4 = =)
135     (1 = *)
136     (5 = *)
137     | > )
138
139    ("." =))
140   *))
141
142 ;; Now a syllable looks like below.
143 ;; m?(HR)?[CR](r|N?c)?(HCr?)*[NJ]?(b|a|A)?s*(p|P)?S?(H[CR])?
144
145 ;; Step 1.
146 ;; Set the form of consonant shifter.
147
148 (generator
149  (0
150   (cond
151    ;; shifter + above vowel sign without ZWNJ
152    ;; Shifter take blwf.  HR takes pref.  HC's take blwf or pstf.
153    ;; 1   2    3     4      5     6     7     8
154    (" (m)?(HR)?([CR]c(HCr?)*(N|J)?(a|A))(s*S?)(H[CR])? "
155     |
156     (1 =)
157     (2 otf:khmr=pref+)
158     (3 otf:khmr=blwf,abvf,pstf+)
159     (7 = *)
160     (8 otf:khmr=blwf,pstf+)
161     | )
162
163    ;; shifter + ZWNJ + above vowel sign, or, shifter without above vowel sign
164    ;; Shifter stays above.  HR takes pref.  HC's take blwf or pstf.
165    ;; 1   2    3        45       6           7   8     9   10  11
166    (" (m)?(HR)?([CR]N?c)((HCr?)*)([NJ]?[ba]?)(A)?(s*p?)(P)?(S)?(H[CR])? "
167     |
168     (1 =)
169     (2 otf:khmr=pref+)
170     (3 = *)
171     (4 otf:khmr=blwf,pstf+)
172     (6 = *)
173     (7 otf:khmr=abvf+)
174     (8 = *)
175     (9 otf:khmr=pstf+)
176     (10 =)
177     (11 otf:khmr=blwf,pstf+)
178     | )
179
180    ;; no shifter
181    ;; 1   2    3       45       6           7   8     9   10  11
182    (" (m)?(HR)?([CR]r?)((HCr?)*)([NJ]?[ba]?)(A)?(s*p?)(P)?(S)?(H[CR])? "
183     |
184     (1 =)
185     (2 otf:khmr=pref+)
186     (3 = *)
187     (4 otf:khmr=blwf,pstf+)
188     (6 = *)
189     (7 otf:khmr=abvf+)
190     (8 = *)
191     (9 otf:khmr=pstf+)
192     (10 =)
193     (11 otf:khmr=blwf,pstf+)
194     | )
195
196    ("." =))
197   *))
198
199 ;; Now a syllable looks like below.  ~ characters are OTF feature applied.
200 ;; m?(HR)?[CR](r|c)?(HCr?)*[NJ]?(b|a|A)?s*(p|P)?S?(H[CR])?
201 ;;    ~~   ~~    ~   ~~~~            ~       ~     ~~~~~
202
203 ;; Step 2.
204 ;; Concatenate adjacent Khmer syllables.
205 ;; Remove J.  Retain N to prevent ligature.
206
207 (generator
208  (0
209   (cond
210    ("  ")
211    ("J")
212    ("." =))
213   *))
214
215 ;; Step 3.
216 ;; Apply other OTF features.
217
218 (generator
219  (0
220   (cond
221    (" ([^ ]*) "
222     (1 otf:khmr=pres,blws,abvs,psts,clig))
223    ("."
224     [ otf:sinh=+ ]))
225   *))
226
227 ;; Step 4.
228 ;; Remove N to clean up.
229 (generator
230  (0
231   (cond
232    ("N")
233    ("." =))
234   *))
235
236 ;; Local Variables:
237 ;; mode: emacs-lisp
238 ;; End: