(state:state-LVT-or-LVTL): Add backspace branch.
[m17n/m17n-db.git] / FLT / GUJR-OTF.flt
1 ;; GUJR-OTF.flt -- Font Layout Table for Gujarati OpenType fonts
2 ;; Copyright (C) 2004, 2007, 2010 AIST (H15PRO112)
3 ;; See the end for copying conditions.
4
5 (font layouter gujr-otf nil
6       (version "1.6.0")
7       (font (nil nil unicode-bmp :otf=gujr)))
8
9 ;;; <li> GUJR-OTF.flt
10 ;;;
11 ;;; For Gujarati OpenType fonts to draw the Gujarati script.
12
13 (category
14  ;; X: generic
15  ;; V: independent vowel
16  ;; C: consonant
17  ;; R: RA
18  ;; n: NUKTA
19  ;; H: HALANT
20  ;; m: vowel sign (pre)
21  ;; u: vowel sign (above)
22  ;; b: vowel sign (below)
23  ;; p: vowel sign (post)
24  ;; a: vowel modifier (above)
25  ;; A: vowel modifier (post)
26  ;; N: ZWNJ
27  ;; J: ZWJ
28  (0x0A80 0x0AFF ?X)                     ; generic
29  (0x0A81 0x0A82 ?a)                     ; SIGN CANDRABINDU .. ANUSVARA
30  (0x0A83        ?A)                     ; SIGN VISARGA
31  (0x0A85 0x0A94 ?V)                     ; LETTER A .. AU
32  (0x0A95 0x0AB9 ?C)                     ; LETTER KA .. HA
33  (0x0AB0        ?R)                     ; LETTER RA
34  (0x0ABC        ?n)                     ; SIGN NUKTA
35  (0x0ABE        ?p)                     ; VOWEL SIGN AA
36  (0x0ABF        ?m)                     ; VOWEL SIGN I
37  (0x0AC0        ?p)                     ; VOWEL SIGN II
38  (0x0AC1 0x0AC4 ?b)                     ; VOWEL SIGN UU .. VOCALIC RR
39  (0x0AC5 0x0AC8 ?u)                     ; VOWEL SIGN CANDRA E .. AI
40  (0x0AC9 0x0ACC ?p)                     ; VOWEL SIGN CANDRA O .. AU
41  (0x0ACD        ?H)                     ; SIGN VIRAMA
42  (0x0AE0 0x0AE1 ?V)                     ; LETTER VOCALIC RR  .. VOCALIC LL
43  (0x0AE2 0x0AE3 ?b)                     ; VOWEL SIGN VOCALIC L .. VOCALIC LL
44
45  (0x200C        ?N)                     ; ZWNJ
46  (0x200D        ?J)                     ; ZWJ
47  (0x25CC        ?X)                     ; DOTTED CIRCLE
48
49  (rphf          ?r)
50  )
51
52 ;; Stage 0
53 ;; Syllable identification
54 (generator
55  (0
56   (cond
57    ;; Syllables with an independent vowel
58    ("(RH)?(Vn?)((J?HR)?m?u?b?p?n?a?A?)"
59     < | (1 = =) (2 :otf=gujr=nukt+) (3 = *) | >)
60
61    ;; Consonant-based syllables
62    ;;1      23                 4
63    ("([CR]n?((J?H|HJ?)[CR]n?)*)(H[NJ]?|m?u?b?p?n?a?A?)"
64     < |
65     (cond
66      (".+HJ$" :otf=gujr=nukt,akhn+)
67      ("(.+)(H)N?$" (1 :otf=gujr=nukt,akhn+) (2 =) 0x200C)
68      (".+" :otf=gujr=nukt,akhn+))
69     | >)
70
71    ;; Combining marks are displayed with a DOTTED CIRCLE.
72    ("m"
73     (cond
74      ((font-facility 0x25CC) < = 0x25CC >)
75      ("." [ = ])))
76    ("[nHubpaA]"
77     (cond
78      ((font-facility 0x25CC) < 0x25CC = >)
79      ("." [ = ])))
80
81    ;; Isolated blwf is displayed with a DOTTED CIRCLE in the next stage.
82    ("(J)(H)(R)"
83     < | (1 =) (3 =) (2 =) | >)
84
85    ("." =))
86   *))
87
88 ;; Stage 1
89 ;; Reorder halant for blwf
90 (generator
91  (0
92   (cond
93    ;; Isolated blwf
94    (" J(RH) "
95     (cond
96      ((font-facility 0x25CC) < 0x25CC :otf=gujr=blwf+ >)
97      (" J(RH) " [ (1 :otf=gujr=blwf+) ])))
98
99    ;; Syllables with an overt halant
100    (" (RHJ?)?([^ ]+)(HN) "
101     | (1 = *) (2 reorder) (3 = =) |)
102
103    ;; Ordinary syllables
104    (" (RHJ?)?([^mubpaA ]+)(m?u?b?p?n?a?A?) "
105     | (1 = *) (2 reorder) (3 = *) |)
106
107    ("." =))
108   *)
109
110  ;; In Devanagari and Gujarati, vattu has a half form.  Thus we handle
111  ;; the sequence CHRHC as (CH)half + (RH)blwf + C instead of
112  ;; reordering and interpreting it as C + (RH)blwf + H + C.
113  (reorder
114   (cond
115    ("(.+)(H)(R)$" (1 = *) (3 =) (2 =))
116    (".+" = *)))
117  )
118
119 ;; Stage 2
120 ;; Language forms and matra reordering
121 (generator
122  (0
123   (cond
124    ;; Overt halant forms
125    (" (RHJ?)?([^ ]+)(HN) "
126     |
127     (1 (cond ("RHJ" :otf=gujr=half+)
128              ("RH" :otf=gujr=rphf+)))
129     (2 (cond ("(.H)J?(.*)" (1 :otf=gujr=half+) (2 lang-forms *))
130              (".+" lang-forms *)))
131     (3 = =) |)
132
133    ;; Other syllables
134    ;; 1      2            3     4     5     6
135    (" (RHJ?)?([^mubpaA ]*)(mn?)?(un?)?(bn?)?(p?n?a?A?) "
136     | (3 = *)
137     (1 (cond ("RHJ" :otf=gujr=half+)
138              ("RH" :otf=gujr=rphf+)))
139     (2 (cond ("(.H)J?(.*)" (1 :otf=gujr=half+) (2 lang-forms *))
140              (".+" lang-forms *)))
141     (5 = *) (4 = *) (6 = *) |)
142
143    ("." =))
144   *)
145
146  (lang-forms
147   (cond
148    ("(.H)J" (1 :otf=gujr=half+))
149    (".H" :otf=gujr=blwf,half+)
150    ("." =)))
151  )
152
153 ;; Stage 3
154 ;; Final reordering #1 (Move pre-base matra after the last halant)
155 (generator
156  (0
157   (cond
158    ;; 1    2         3
159    (" (mn?)([^ ]+HJ?)([^H ]+) "
160     | (2 = *) (1 = *) (3 = *) |)
161
162    ("." =))
163   *))
164
165 ;; Stage 4
166 ;; Final reordering #2 (Move reph after the first halant)
167 (generator
168  (0
169   (cond
170    ;; Syllables with a reph and an explicit halant
171    ;; 1     2  3          4
172    (" (mn?)?(r)([^H ]+HJ?)([^ ]*) "
173     | (1 = *) (3 = *) (2 =) (4 = *) |)
174
175    ;; A reph without explicit halant
176    ;; 1     2  3        4
177    (" (mn?)?(r)([^aA ]+)(a?A?) "
178     | (1 = *) (3 = *) (2 =) (4 = *) |)
179
180    ("." =))
181   *))
182
183 ;; Stage 5
184 ;; Nukta for matra, vattu and presentation forms
185 (generator
186  (0
187   (cond
188    (" ([^ ]+) "
189     | (1 :otf=gujr=nukt,vatu,pres,abvs,blws,psts,haln+) |)
190
191    ("." =))
192   *))
193
194 ;; Stage 6
195 ;; Remove ZWNJ/ZWJ
196 (generator
197  (0
198   (cond
199    ("[NJ]")
200
201    ("." =))
202   *))
203
204 ;; Stage 7
205 ;; GPOS processing
206 (generator
207  (0
208   (cond
209    (" ([^ ]+) "
210     (1 :otf=gujr=+abvm,blwm,dist))
211
212    ("." =))
213   *))
214
215 ;; Copyright (C) 2004, 2007, 2010
216 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
217 ;;   Registration Number H15PRO112
218
219 ;; This file is part of the m17n database; a sub-part of the m17n
220 ;; library.
221
222 ;; The m17n library is free software; you can redistribute it and/or
223 ;; modify it under the terms of the GNU Lesser General Public License
224 ;; as published by the Free Software Foundation; either version 2.1 of
225 ;; the License, or (at your option) any later version.
226
227 ;; The m17n library is distributed in the hope that it will be useful,
228 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
229 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
230 ;; Lesser General Public License for more details.
231
232 ;; You should have received a copy of the GNU Lesser General Public
233 ;; License along with the m17n library; if not, write to the Free
234 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
235 ;; Boston, MA 02110-1301, USA.
236
237 ;; Local Variables:
238 ;; mode: emacs-lisp
239 ;; End: