Rewritten with new algorithm for Unicode 5.0.
[m17n/m17n-db.git] / FLT / ORYA-OTF.flt
1 ;; ORYA-OTF.flt -- Font Layout Table for Oriya OpenType font
2 ;; Copyright (C) 2004, 2007
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., 51 Franklin Street, Fifth Floor,
22 ;; Boston, MA 02110-1301, USA.
23
24 ;;; <li> ORYA-OTF.flt
25 ;;;
26 ;;; For Oriya OpenType fonts to draw the Oriya script.  Tested with
27 ;;; utkalm.ttf <http://oriya.sarovar.org/download/utkalm.ttf.gz>
28
29 (font layouter orya-otf nil
30       (font (nil nil unicode-bmp :otf=orya=rphf)))
31
32 (category
33  ;; C: consonant (except for R, B and Y)
34  ;; R: consonant RA
35  ;; B: consonant (below)
36  ;; Y: consonant (post)
37  ;; n: NUKTA
38  ;; H: HALANT
39  ;; m: vowel sign (pre)
40  ;; u: vowel sign (above)
41  ;; b: vowel sign (below)
42  ;; p: vowel sign (post)
43  ;; t: vowel sign (two-part)
44  ;; A: vowel modifier (above)
45  ;; a: vowel modifier (post)
46  ;; V: independent vowel
47  ;; N: ZWNJ (ZERO WIDTH NON-JOINER)
48  ;; J: ZWJ (ZERO WIDTH JOINER)
49  ;; X: generic
50  ;; Z: internal use
51  (0x0B00 0x0B7F ?X)                     ; generic
52  (0x0B00        ?Z)                     ; internal use
53  (0x0B01 0x0B03 ?a)                     ; SIGN CANDRABINDU .. VISARGA
54  (0x0B05 0x0B14 ?V)                     ; LETTER A .. VOCALIC AU
55  (0x0B15 0x0B39 ?C)                     ; LETTER KA .. HA
56  (0x0B24        ?B)                     ; LETTER TA
57  (0x0B28        ?B)                     ; LETTER NA
58  (0x0B2C 0x0B2E ?B)                     ; LETTER BA .. MA
59  (0x0B2F        ?Y)                     ; LETTER YA
60  (0x0B30        ?R)                     ; LETTER RA
61  (0x0B32 0x0B33 ?B)                     ; LETTER LA
62  (0x0B33        ?B)                     ; LETTER LLA
63  (0x0B3C        ?n)                     ; SIGN NUKTA
64  (0x0B3E        ?p)                     ; VOWEL SIGN AA
65  (0x0B3F        ?u)                     ; VOWEL SIGN I
66  (0x0B40        ?p)                     ; VOWEL SIGN II
67  (0x0B41 0x0B43 ?b)                     ; VOWEL SIGN U .. VOCALIC R
68  (0x0B47        ?m)                     ; VOWEL SIGN E
69  (0x0B48 0x0B4C ?t)                     ; VOWEL SIGN AI .. AU
70  (0x0B4D        ?H)                     ; SIGN VIRAMA
71  (0x0B56        ?u)                     ; AI LENGTH MARK
72  (0x0B57        ?p)                     ; AU LENGTH MARK
73  (0x0B5C 0x0B5D ?C)                     ; LETTER RRA .. RHA
74  (0x0B5F        ?Y)                     ; LETTER YYA
75  (0x0B60 0x0B61 ?V)                     ; LETTER VOCALIC RR .. LL
76  (0x0B71        ?C)                     ; LETTER WA
77  (0x0B64 0x0B65 ?X)                     ; DANDA .. DOUBLE DANDA
78  (0x200C        ?N)                     ; ZWNJ
79  (0x200D        ?J)                     ; ZWJ
80  )
81
82 ;; Decompose two-part vowel signs.
83 ;; Move ZWJ before the consonant.
84 (generator
85  (0
86   (cond
87    ((0x0B48)
88     0x0B47 0x0B56)
89    ((0x0B4B)
90     0x0B47 0x0B3E)
91    ((0x0B4C)
92     0x0B47 0x0B57)
93    ("(Cn?)(J)"
94     (2 =) (1 = *))
95    ("." =))
96   *))
97
98 ;; Syllable identification and reordering.
99 ;; Do not apply 'rphf' if a syllable begins with ZWJ.
100 (generator
101  (0
102   (cond
103    ;; A syllable with ZWJ and a pre-base vowel sign.
104    ;;1  23                    4  5   6   7
105    ("(J)(([CRBY]n?H)*[CRBY]n?)(m)(u)?(p)?(a)?"
106     < | (1 =) (4 =) (2 pre-below) (5 =) (2 post) (6 =) (7 =) | >)
107
108    ;; A syllable with ZWJ and a non-pre-base vowel sign.
109    ;;1  23                    45      6   7
110    ("(J)(([CRBY]n?H)*[CRBY]n?)(([bu])|(p))(a)?"
111     < | (1 =) (2 pre-below) (5 =) (2 post) (6 =) (7 =) | >)
112
113    ;; A syllable with ZWJ and a vowel modifier, but without vowel signs.
114    ;;1  23                    4
115    ("(J)(([CRBY]n?H)*[CRBY]n?)(a)"
116     < | (1 =) (2 pre-below) (2 post) (4 =) | >)
117
118    ;; Add a ZWNJ explicitly when a syllable ends with a halant.
119    ;;1  23                    4   5
120    ("(J)(([CRBY]n?H)*[CRBY]n?)(H)?(N)?"
121     < | (1 =) (2 pre-below) (4 = 0x200C) (2 post) | >)
122
123    ;; With a pre-base vowel sign, without a ZWJ.
124    ;;1    23                    4  5   6   7
125    ("(RH)?(([CRBY]n?H)*[CRBY]n?)(m)(u)?(p)?(a)?"
126     < |
127     (4 =) (2 pre-below) (5 =) (1 otf:orya=rphf) (2 post) (6 =) (7 =)
128     | >)
129
130    ;; With a non-pre-base vowel sign, without a ZWJ.
131    ;; 1   23                    45      6   7
132    ("(RH)?(([CRBY]n?H)*[CRBY]n?)(([bu])|(p))(a)?"
133     < | (2 pre-below) (5 =) (1 otf:orya=rphf) (2 post) (6 =) (7 =) | >)
134
135    ;; With a vowel modifier, without vowel signs and a ZWJ.
136    ;;1    23                    4
137    ("(RH)?(([CRBY]n?H)*[CRBY]n?)(a)"
138     < | (2 pre-below) (1 otf:orya=rphf) (2 post) (4 =) | >)
139
140    ;; Add a ZWNJ explicitly when a syllable ends with a halant.
141    ;;1    23                    4   5
142    ("(RH)?(([CRBY]n?H)*[CRBY]n?)(H)?(N)?"
143     < | (2 pre-below) (1 otf:orya=rphf) (4 = 0x200C) (2 post) | >)
144
145    ;; A syllable starting with an independent vowel.
146    ("Va?"
147     < | = * | >)
148
149    ("." =))
150   *)
151
152  ;; Move a halant after the base consonant to the end.
153  ;; Fill the resulting gap with a special mark.
154  ;; Remove post-base parts.
155  (pre-below
156   (cond
157    ("([CRBYnH]*[CYn])H([RBH]+)[YH]+$"
158     (1 = *) 0x0B00 (2 = *))
159    ("([CRBYnH]*[CYn])(H)([RBH]+)$"
160     (1 = *) 0x0B00 (3 = *) (2 =))
161    ("([CRBYnH]*[Cn])[YH]*$"
162     (1 = *) 0x0B00)
163    ("([RB]n?)H([RBH]*)[YH]+$"
164     (1 = *) 0x0B00 (2 = *))
165    ("([RB]n?)(H)([RBH]*)$"
166     (1 = *) 0x0B00 (3 = *) (2 =))
167    ("([RBY]n?)[YH]*$"
168     (1 = *) 0x0B00)))
169
170  ;; Extract post-base parts and add a halant at the end.
171  ;; Produce nothing if there are no post-base parts.
172  (post
173   (cond
174    ("[CRBYnH]*[CRBn]H([YH]+)$"
175     (1 = *) 0x0B4D)
176    ("Yn?H(YH)+$"
177     (1 = *) 0x0B4D)
178    (".+"
179     )))
180  )
181
182 ;; Apply language forms to concerning segments.
183 (generator
184  (0
185   (cond
186    ;; If a syllable contains a ZWNJ, render the preceding halant explicitly.
187    (" ([^Z]+)(Z)([^N]*)(HN)([^ ]*) "
188     | (1 otf:orya=nukt,akhn,half+) (2 =) (3 otf:orya=blwf+) (4 = =)
189     (5 otf:orya=pstf+) |)
190
191    (" (J?m?)([^Z]+)(Z)([^ ]*) "
192     | (1 = *) (2 otf:orya=nukt,akhn,half+) (3 =) (4 otf:orya=blwf,pstf+) |)
193
194    ("." =))
195   *))
196
197 ;; Apply 'pres' to get pre-base conjuncts.
198 (generator
199  (0
200   (cond
201    (" (J?m?)([^Z]+)(Z)([^ ]*) "
202     | (1 = *) (2 otf:orya=pres+) (3 =) (4 = *) |)
203    ("." =))
204   *))
205
206 ;; When the number of glyphs between a pre-base vowel sign and the
207 ;; post-base mark is more than one, move the pre-base vowel sign
208 ;; before the base glyph.
209 (generator
210  (0
211   (cond
212    (" (J)?(m)([^Z]+)([^Z])Z([^N ]*)N?([^ ]*) "
213     | (1 =) (3 = *) (2 =) (4 =) (5 = *) (6 = *)|)
214    (" ([^Z]+)Z([^N ]*)N?([^ ]*) "
215     | (1 = *) (2 = *) (3 = *) |)
216    ("." =))
217   *))
218
219 ;; Apply other features.
220 ;; Do not apply 'vatu' and 'blws' if there is a ZWJ.
221 ;; The 'pres' feature is applied again for pre-base vowel sign.
222 (generator
223  (0
224   (cond
225    (" J([^ ]+) "
226     (1 otf:orya=pres,abvs,pstp,haln))
227    (" ([^ ]+) "
228     (1 otf:orya=vatu,pres,abvs,blws,pstp,haln))
229    ("."
230     [ otf:orya=+ ]))
231   *))
232
233 ;; Local Variables:
234 ;; mode: emacs-lisp
235 ;; End: