Specify GPOS order explicitly.
[m17n/m17n-db.git] / FLT / KNDA-OTF.flt
1 ;; KNDA-OTF.flt -- Font Layout Table for Kannada OpenType fonts
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> KNDA-OTF.flt
25 ;;;
26 ;;; For Kannada OpenType fonts to draw Kannada.
27 ;;; Designed for Kedage-n.ttf <http://brahmi.sourceforge.net/downloads.html>
28
29 (font layouter knda-otf nil
30       (font (nil nil unicode-bmp :otf=knda=rphf)))
31
32 (category
33  ;; C: consonant (except for RA)
34  ;; R: RA
35  ;; n: NUKTA
36  ;; H: HALANT
37  ;; u: vowel sign (above)
38  ;; b: vowel sign (below)
39  ;; p: vowel sign (post)
40  ;; l: length mark
41  ;; a: vowel modifier (post)
42  ;; V: independent vowel
43  ;; N: ZWNJ (ZERO WIDTH NON-JOINER)
44  ;; J: ZWJ (ZERO WIDTH JOINER)
45  ;; X: generic
46  (0x0C80 0x0CFF ?X)                     ; generic
47  (0x0C82 0x0C83 ?a)                     ; SIGN ANUSVARA .. VISARGA
48  (0x0C85 0x0C94 ?V)                     ; LETTER A .. LETTER AU
49  (0x0C95 0x0CB9 ?C)                     ; LETTER KA .. LETTER HA
50  (0x0CB0        ?R)                     ; LETTER RA
51  (0x0CBC        ?n)                     ; SIGN NUKTA
52  (0x0CBE        ?p)                     ; VOWEL SIGN AA
53  (0x0CBF        ?u)                     ; VOWEL SIGN I
54  (0x0CC1 0x0CC4 ?p)                     ; VOWEL SIGN U .. RR
55  (0x0CC6        ?u)                     ; VOWEL SIGN E
56  (0x0CCC        ?u)                     ; VOWEL SIGN AU
57  (0x0CCD        ?H)                     ; SIGN VIRAMA
58  (0x0CD5 0x0CD6 ?l)                     ; LENGTH MARK .. AI LENGTH MARK
59  (0x0CDE        ?C)                     ; LETTER FA (LLLA)
60  (0x0CE0 0x0CE1 ?V)                     ; LETTER VOCALIC RR .. LL
61  (0x0CE2 0x0CE3 ?b)                     ; VOWEL SIGN VOCALIC L .. LL
62  (0x0964 0x0965 ?X)                     ; DANDA .. DOUBLE DANDA
63  (0x200C        ?N)                     ; ZWNJ
64  (0x200D        ?J)                     ; ZWJ
65  )
66
67 ;; Preprocessing
68 (generator
69  (0
70   (cond
71    ;; Decompose two-part and three-part vowels
72    ((0x0CC0)
73     0x0CBF 0x0CD5)
74    ((0x0CC7)
75     0x0CC6 0x0CD5)
76    ((0x0CC8)
77     0x0CC6 0x0CD6)
78    ((0x0CCA)
79     0x0CC6 0x0CC2)
80    ((0x0CCB)
81     0x0CC6 0x0CC2 0x0CD5)
82    ;; Move ZWJ between RA and HARANT.
83    ("(R)(J)(H)"
84     (2 =) (1 =) (3 =))
85    ("." =))
86   *))
87
88 ;; Syllable identification.
89 ;; Apply 'nukt' and 'akhn' before reordering.
90
91 (generator
92  (0
93   (cond
94    ;; A syllable with an above vowel sign.
95    ;;1   2      3          4
96    ("(J)?([CR]n?(H[CR]n?)*)(up?l?a?)"
97     < | (1 =) (2 otf:knda=nukt,akhn+) (4 = *) | >)
98
99    ;; A syllable with a post- or below vowel sign.
100    ;;1   2      3          4    5
101    ("(J)?([CR]n?(H[CR]n?)*)(p|b)(a)?"
102     < | (1 =) (2 otf:knda=nukt,akhn+) (4 =) (5 =) | >)
103
104    ;; A syllable with a vowel modifier, but without vowel signs.
105    ;;1   2      3          4
106    ("(J)?([CR]n?(H[CR]n?)*)(a)"
107     < | (1 =) (2 otf:knda=nukt,akhn+) (4 =) | >)
108
109    ;; No vowel signs, no vowel modifiers.
110    ;;1   2      3          4
111    ("(J)?([CR]n?(H[CR]n?)*)(H|HN)?"
112     < | (1 =) (2 otf:knda=nukt,akhn+) (4 = *) | >)
113
114    ;; A syllable starting with an independent vowel.
115    ("Va?"
116     < | = * | >)
117
118    ("." =))
119   *))
120
121 ;; Reordering.  The base consonant is always the first one, because
122 ;; all Kannada consonants have a below form.
123 (generator
124  (0
125   (cond
126    ;; 1    2  34     5     6   7   8
127    (" (RH)?([^N])((H[^N])*)(u|b)?(p)?(l)?(a)? "
128     | (2 =) (5 =) (6 =) (3 move-h) (7 =) (1 otf:knda=rphf+) (8 =) |)
129
130    ;; A syllable ending with a halant.
131    ;; 1    2   34
132    (" (RH)?(.H)((.H)*)N? "
133     ;; WORKAROUND : Kedage fonts produce halant form with 'psts'.
134     | (2 otf:knda=haln,psts+)(3 = *) (1 otf:knda=rphf+) |)
135
136    ;; No reph movement if preceded by a ZWJ.
137    ;;  1  23     4     5   6
138    (" J(.)((H[^N])*)(u|b)?(p)?(l?a?) "
139     | (1 =) (4 =) (5 =) (2 move-h) (6 = *) |)
140
141    ;;  1   23
142    (" J(.H)((.H)*)N? "
143     | (1 otf:knda=haln,psts+) (2 = *) |)
144
145    ("." =))
146   *)
147
148  (move-h
149   (cond
150    ("(H)(.+)"
151     (2 = *) (1 =)))))
152
153 ;; Apply other OTF features.
154 (generator
155  (0
156   (cond
157    (" ([^ ]+) "
158     (1 otf:knda=blwf,abvs,blws,psts+abvm,blwm,dist))
159
160    ("."
161     [ = ]))
162   *))
163
164 ;; Local Variables:
165 ;; mode: emacs-lisp
166 ;; End: