Stage 3: Consider a possibility that an Anudatta follows a Halant.
[m17n/m17n-db.git] / FLT / GJR2-OTF.flt
1 ;; GJR2-OTF.flt -- Font Layout Table for gjr2 OpenType fonts
2 ;; Copyright (C) 2010 AIST (H15PRO112)
3 ;; See the end for copying conditions.
4
5 (font layouter gjr2-otf nil
6       (version "1.6.0")
7       (font (nil nil unicode-bmp :otf=gjr2)))
8
9 ;;; <li> GJR2-OTF.flt
10 ;;;
11 ;;; For gjr2 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     < | (0 = *) | >)
60
61    ;; Consonant-based syllables
62    ("([CR]n?J?HJ?)*[CR]n?(H[NJ]?|m?u?b?p?n?)a?A?"
63     < | (0 = *) | >)
64
65    ;; Combining marks are displayed with a DOTTED CIRCLE.
66    ("(m)|(n|H|u|b|p|a|A|JHR)"
67     < | (1 =) 0x25CC (2 :otf=gjr2=blwf+) | >)
68
69    ("." =))
70   *))
71
72 ;; Stage 1
73 ;; Basic shaping forms and matra reordering
74 (generator
75  (0
76   (cond
77    ;; Explicit halant form starting with RA + H + ZWJ
78    (" (RHJ[CRnHJ]+)(HN?a?A?) "
79     | (1 :otf=gjr2=locl,nukt,akhn,rkrf,blwf,half,vatu,cjct+) (2 = *) |)
80
81    ;; Explicit halant form starting with a reph
82    (" (RH)([CRnHJ]+)(HN?a?A?) "
83     | (1 :otf=gjr2=rphf+) (2 :otf=gjr2=locl,nukt,akhn,rkrf,blwf,half,vatu,cjct+)
84     (3 = *) |)
85
86    ;; Other explicit halant forms
87    (" ([CRnHJ]+)(HN?a?A?) "
88     | (1 :otf=gjr2=locl,nukt,akhn,rkrf,blwf,half,vatu,cjct+) (2 = *) |)
89
90    ;; Ordinary syllables starting with RA + H + ZWJ
91    ;; 1            2     3
92    (" (RHJ[CRnHJ]*)(mn?)?(u?b?p?n?a?A?) "
93     ;;           |
94     ;; This is an asterisk.  (See DEV2-OTF.flt)
95     | (2 = *) (1 :otf=gjr2=locl,nukt,akhn,rkrf,blwf,half,vatu,cjct+)
96     (3 = *) |)
97
98    ;; Ordinary syllables starting with a reph
99    ;; 1   2          3     4
100    (" (RH)([CRnHJV]+)(mn?)?(u?b?p?n?a?A?) "
101     | (3 = *) (1 :otf=gjr2=rphf+)
102     (2 :otf=gjr2=locl,nukt,akhn,rkrf,blwf,half,vatu,cjct+)
103     (4 = *) |)
104    
105    ;; Other ordinary syllables
106    ;; 1          2     3
107    (" ([CRnHJV]+)(mn?)?(u?b?p?n?a?A?) "
108     | (2 = *) (1 :otf=gjr2=locl,nukt,akhn,rkrf,blwf,half,vatu,cjct+)
109     (3 = *) |)
110
111    ("." =))
112   *))    
113
114 ;; Stage 2
115 ;; Final reordering #1 (Move pre-base matra after the last halant)
116 (generator
117  (0
118   (cond
119    ;; 1    2         3
120    (" (mn?)([^ ]+HJ?)([^H ]+) "
121     | (2 = *) (1 = *) (3 = *) |)
122
123    ("." =))
124   *))
125
126 ;; Stage 3
127 ;; Final reordering #2 (Move reph after the first halant)
128 (generator
129  (0
130   (cond
131    ;; Syllables with a reph and an explicit halant
132    ;; 1     2  3          4
133    (" (mn?)?(r)([^H ]+HJ?)([^ ]*) "
134     | (1 = *) (3 = *) (2 =) (4 = *) |)
135
136    ;; A reph without explicit halant
137    ;; 1     2  3        4
138    (" (mn?)?(r)([^aA ]+)(a?A?) "
139     | (1 = *) (3 = *) (2 =) (4 = *) |)
140
141    ("." =))
142   *))
143
144 ;; Stage 4
145 ;; Nukta for matra and presentation forms
146 (generator
147  (0
148   (cond
149    (" ([^ ]+) "
150     | (1 :otf=gjr2=nukt,pres,abvs,blws,psts,haln,calt+) |)
151
152    ("." =))
153   *))
154
155 ;; Stage 5
156 ;; Remove ZWNJ/ZWJ
157 (generator
158  (0
159   (cond
160    ("[NJ]")
161
162    ("." =))
163   *))
164
165 ;; Stage 6
166 ;; GPOS processing
167 (generator
168  (0
169   (cond
170    (" ([^ ]+) "
171     (1 :otf=gjr2=+kern,dist,abvm,blwm))
172
173    ("." =))
174   *))
175
176 ;; Copyright (C) 2010
177 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
178 ;;   Registration Number H15PRO112
179
180 ;; This file is part of the m17n database; a sub-part of the m17n
181 ;; library.
182
183 ;; The m17n library is free software; you can redistribute it and/or
184 ;; modify it under the terms of the GNU Lesser General Public License
185 ;; as published by the Free Software Foundation; either version 2.1 of
186 ;; the License, or (at your option) any later version.
187
188 ;; The m17n library is distributed in the hope that it will be useful,
189 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
190 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
191 ;; Lesser General Public License for more details.
192
193 ;; You should have received a copy of the GNU Lesser General Public
194 ;; License along with the m17n library; if not, write to the Free
195 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
196 ;; Boston, MA 02110-1301, USA.
197
198 ;; Local Variables:
199 ;; mode: emacs-lisp
200 ;; End: