Move copying condition to the end.
[m17n/m17n-db.git] / FLT / KHMR-OTF.flt
1 ;; KHMR-OTF.flt -- Font Layout Table for Khmer OpenType fonts
2 ;; Copyright (C) 2005, 2007  AIST (H15PRO112)
3 ;; See the end for copying conditions.
4
5 (font layouter khmr-otf nil
6       (font (nil nil unicode-bmp :otf=khmr=pres)))
7
8 ;;; <li> KHMR-OTF.flt
9 ;;;
10 ;;; For Khmer OpenType fonts to draw Khmer.
11 ;;; A Font is available from 
12 ;;; <http://www.khmeros.info/drupal/?q=en/download/fonts>.
13
14 (category
15  (0x1780 0x17FF ?E)                     ; E: else
16  (0x19E0 0x19FF ?E)
17  (0x1780 0x17B3 ?C)                     ; C: consonant & independent vowel
18  (0x179A        ?R)                     ; R: RO
19  (0x17B6        ?p)                     ; p: vowel sign (post)
20  (0x17B7 0x17BA ?a)                     ; a: vowel sign (above)
21  (0x17BB 0x17BD ?b)                     ; b: vowel sign (below)
22  (0x17BE        ?A)                     ; A: vowel sign (two-part, above)
23  (0x17BF 0x17C0 ?P)                     ; P: vowel sign (two-part, post)
24  (0x17C1 0x17C3 ?m)                     ; m: vowel sign (pre)
25  (0x17C4 0x17C5 ?P)
26  (0x17C6        ?s)                     ; s: sign (above)
27  (0x17C7 0x17C8 ?S)                     ; S: sign (post)
28  (0x17C9 0x17CA ?c)                     ; c: consonant shifter
29  (0x17CB 0x17D1 ?s)
30  (0x17CC        ?r)                     ; r: ROBAT
31  (0x17D2        ?H)                     ; H: COENG
32  (0x17D3        ?s)
33  (0x17DD        ?s)
34  (0x200C        ?N)                     ; N: ZERO WIDTH NON-JOINER
35  (0x200D        ?J)                     ; J: ZERO WIDTH JOINER
36  )
37
38 ;; Generic syllable pattern is as follows.
39 ;; [CR](r|N?c)?(HCr?)*(HR)?(HCr?)*[NJ]?(m|b|a|A|p|P)?s*S?(H[CR])?
40
41 ;; Step 0.
42 ;; Move m to the beginning.
43 ;; Split A and P.
44 ;; Exchange the order of pP and s.
45 ;; Move HR before the base.
46
47 (generator
48  (0
49   (cond
50
51    ;; pre vowel sign
52    ;;1    2       3       4  5     67            8  9    10
53    ("([CR](r|N?c)?(HCr?)*)(HR(r)?)?((HCr?)*[NJ]?)(m)(s*S?(H[CR])?)"
54     < | (8 =) (4 = =) (1 = *) (5 =) (6 = *) (9 = *) | > )
55
56    ;; two-part above vowel sign
57    ;;1    2       3       4  5     67                8
58    ("([CR](r|N?c)?(HCr?)*)(HR(r)?)?((HCr?)*[NJ]?As*S?(H[CR])?)"
59     < | 0x17C1 (4 = =) (1 = *) (5 =) (6 = *) | > )
60
61    ;; post vowel sign
62    ;;1    2       3       4  5     67            8  9   10 11
63    ("([CR](r|N?c)?(HCr?)*)(HR(r)?)?((HCr?)*[NJ]?)(p)(s*)(S?(H[CR])?)"
64     < | (4 = =) (1 = *) (5 =) (6 = *) (9 = *) (8 =) (10 = *) | > )
65
66    ;; two-part post vowel sign
67    ;;1    2       3       4  5     67            8  9   10 11
68    ("([CR](r|N?c)?(HCr?)*)(HR(r)?)?((HCr?)*[NJ]?)(P)(s*)(S?(H[CR])?)"
69     < | 0x17C1 (4 = =) (1 = *) (5 =) (6 = *) (9 = *) (8 =) (10 = *) | > )
70
71    ;; other vowel signs or no vowel sign
72    ;;1    2       3       4  5     67                     8
73    ("([CR](r|N?c)?(HCr?)*)(HR(r)?)?((HCr?)*[NJ]?[b|a]?s*S?(H[CR])?)"
74     < | (4 = =) (1 = *) (5 =) (6 = *) | > )
75
76    ("." =))
77   *))
78
79 ;; Now a syllable looks like below.
80 ;; m?(HR)?[CR](r|N?c)?(HCr?)*[NJ]?(b|a|A)?s*(p|P)?S?(H[CR])?
81
82 ;; Step 1.
83 ;; Set the form of consonant shifter.
84
85 (generator
86  (0
87   (cond
88    ;; shifter + above vowel sign without ZWNJ
89    ;; Shifter take blwf.  HR takes pref.  HC's take blwf or pstf.
90    ;; 1   2    3     4      5     6     7     8
91    (" (m)?(HR)?([CR]c(HCr?)*(N|J)?(a|A))(s*S?)(H[CR])? "
92     |
93     (1 =)
94     (2 otf:khmr=pref+)
95     (3 otf:khmr=blwf,abvf,pstf+)
96     (7 = *)
97     (8 otf:khmr=blwf,pstf+)
98     | )
99
100    ;; shifter + ZWNJ + above vowel sign, or, shifter without above vowel sign
101    ;; Shifter stays above.  HR takes pref.  HC's take blwf or pstf.
102    ;; 1   2    3        45       6           7   8     9   10  11
103    (" (m)?(HR)?([CR]N?c)((HCr?)*)([NJ]?[ba]?)(A)?(s*p?)(P)?(S)?(H[CR])? "
104     |
105     (1 =)
106     (2 otf:khmr=pref+)
107     (3 = *)
108     (4 otf:khmr=blwf,pstf+)
109     (6 = *)
110     (7 otf:khmr=abvf+)
111     (8 = *)
112     (9 otf:khmr=pstf+)
113     (10 =)
114     (11 otf:khmr=blwf,pstf+)
115     | )
116
117    ;; no shifter
118    ;; 1   2    3       45       6           7   8     9   10  11
119    (" (m)?(HR)?([CR]r?)((HCr?)*)([NJ]?[ba]?)(A)?(s*p?)(P)?(S)?(H[CR])? "
120     |
121     (1 =)
122     (2 otf:khmr=pref+)
123     (3 = *)
124     (4 otf:khmr=blwf,pstf+)
125     (6 = *)
126     (7 otf:khmr=abvf+)
127     (8 = *)
128     (9 otf:khmr=pstf+)
129     (10 =)
130     (11 otf:khmr=blwf,pstf+)
131     | )
132
133    ("." =))
134   *))
135
136 ;; Now a syllable looks like below.  ~ characters are OTF feature applied.
137 ;; m?(HR)?[CR](r|c)?(HCr?)*[NJ]?(b|a|A)?s*(p|P)?S?(H[CR])?
138 ;;    ~~   ~~    ~   ~~~~            ~       ~     ~~~~~
139
140 ;; Step 2.
141 ;; Concatenate adjacent Khmer syllables.
142 ;; Remove J.  Retain N to prevent ligature.
143
144 (generator
145  (0
146   (cond
147    ("  ")
148    ("J")
149    ("." =))
150   *))
151
152 ;; Step 3.
153 ;; Apply other OTF features.
154
155 (generator
156  (0
157   (cond
158    (" ([^ ]*) "
159     (1 otf:khmr=pres,blws,abvs,psts,clig))
160    ("."
161     [ = ]))
162   *))
163
164 ;; Step 4.
165 ;; Remove N to clean up.
166 (generator
167  (0
168   (cond
169    ("N")
170    ("." =))
171   *))
172
173 ;; Copyright (C) 2005, 2007
174 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
175 ;;   Registration Number H15PRO112
176
177 ;; This file is part of the m17n database; a sub-part of the m17n
178 ;; library.
179
180 ;; The m17n library is free software; you can redistribute it and/or
181 ;; modify it under the terms of the GNU Lesser General Public License
182 ;; as published by the Free Software Foundation; either version 2.1 of
183 ;; the License, or (at your option) any later version.
184
185 ;; The m17n library is distributed in the hope that it will be useful,
186 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
187 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
188 ;; Lesser General Public License for more details.
189
190 ;; You should have received a copy of the GNU Lesser General Public
191 ;; License along with the m17n library; if not, write to the Free
192 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
193 ;; Boston, MA 02110-1301, USA.
194
195 ;; Local Variables:
196 ;; mode: emacs-lisp
197 ;; End: