*** empty log message ***
[m17n/m17n-db.git] / ORYA-OTF.flt
1 ;; ORYA-OTF.flt -- Font Layout Table for Oriya OpenType font
2 ;; Copyright (C) 2004
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., 59 Temple Place, Suite 330, Boston, MA
22 ;; 02111-1307, 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 (category
30  ;; C: consonant (excluding Y and R)
31  ;; R: consonant RA (reph, below)
32  ;; B: consonant (below)
33  ;; Y: consonant YA, YYA (post)
34  ;; n: NUKTA
35  ;; H: HALANT
36  ;; m: MATRA (pre)
37  ;; u: MATRA (above)
38  ;; b: MATRA (below)
39  ;; p: MATRA (post)
40  ;; t: MATRA (two-part)
41  ;; A: vowel modifier (above)
42  ;; a: vowel modifier (post)
43  ;; V: independent vowel
44  ;; N: ZWNJ (ZERO WIDTH NON-JOINER)
45  ;; J: ZWJ (ZERO WIDTH JOINER)
46  ;; E: ELSE
47  ;;
48  (0x200C        ?N)                     ; ZWNJ
49  (0x200D        ?J)                     ; ZWJ
50  (0x0664 0x0665 ?E)                     ; DANDA, DOUBLE DANDA
51  (0x0B00 0x0B7F ?E)                     ; ELSE
52  (0x0B01        ?A)                     ; SIGN CANDRABINDU (above)
53  (0x0B02 0x0B03 ?a)                     ; SIGN ANUSWAR, VISARGA (post)
54  (0x0B05 0x0B0C ?V)                     ; LETTER A .. VOCALIC L
55  (0x0B0F 0x0B10 ?V)                     ; LETTER E .. AI
56  (0x0B13 0x0B14 ?V)                     ; LETTER O .. AU
57  (0x0B15 0x0B39 ?C)                     ; LETTER KA .. HA
58  (0x0B24        ?B)                     ; LETTER TA
59  (0x0B28        ?B)                     ; LETTER NA
60  (0x0B2C        ?B)                     ; LETTER BA
61  (0x0B2D        ?B)                     ; LETTER BHA
62  (0x0B2E        ?B)                     ; LETTER MA
63  (0x0B2F        ?Y)                     ; LETTER YA
64  (0x0B30        ?R)                     ; LETTER RA
65  (0x0B32        ?B)                     ; LETTER LA
66  (0x0B33        ?B)                     ; LETTER LLA
67  (0x0B35        ?B)                     ; LETTER VA
68  (0x0B3C        ?n)                     ; SIGN NUKTA
69  (0x0B3E        ?p)                     ; VOWEL SIGN AA (post)
70  (0x0B3F        ?u)                     ; VOWEL SIGN I (above)
71  (0x0B40        ?p)                     ; VOWEL SIGN II (post)
72  (0x0B41 0x0B43 ?b)                     ; VOWEL SIGN U, UU, R (below)
73  (0x0B47        ?m)                     ; VOWEL SIGN E (pre)
74  (0x0B48 0x0B4C ?t)                     ; VOWEL SIGN AI, O, AU (two-part)
75  (0x0B4D        ?H)                     ; SIGN VIRAMA (HALANT)
76  (0x0B56        ?u)                     ; AI LENGTH MARK
77  (0x0B57        ?p)                     ; AU LENGTH MARK
78  (0x0B5C 0x0B5D ?C)                     ; LETTER RRA, RHA
79  (0x0B5F        ?Y)                     ; LETTER YYA
80  (0x0B60 0x0B61 ?V)                     ; LETTER VOCALIC RR, LL
81  (0x0B71        ?C)                     ; LETTER WA
82  (0x0B7E        ?x)                     ; mark #1 (internal use)
83  (0x0B7F        ?y)                     ; mark #2 (internal use)
84  )
85
86 ;; Step 1 : Syllable identification.  Recognised syllables are quoted
87 ;; by the pseudo character, which is generated by the command "|" and
88 ;; has the category " " (space).
89 (generator
90  (0
91   (cond
92    ;; Case F : Syllables containing an independent vowel.
93     ("(RH)?(V)(a)?(A)?"
94     < |
95     (2 =)
96     (1 = =)
97     (3 =)
98     (4 =)
99     | >)
100
101    ;; Case A-C are for those syllables that end with an explicit vowel
102    ;; mark and/or a vowel modifier.  They are divided into three cases
103    ;; for readability of the regular expressions.  The leading
104    ;; consonant-Halant repetition is analysed for reordering in the
105    ;; next step.  A two-part vowel, if any, is split for
106    ;; canonicalisation.
107
108    ;; Case A : A syllable ending with a vowel modifier.
109    ("(RH)?(([CRBY]n?H[NJ]?)*([CRBY]n?))([mbup]*)(t)?([Aa])"
110     < |
111     (1 = =)
112     (2 set-marks)
113     (5 = *)
114     (6 split)
115     (7 =)
116     | >)
117
118    ;; Case B : A syllable ending with a two-part vowel.
119    ("(RH)?(([CRBY]n?H[NJ]?)*([CRBY]n?))(t)"
120     < |
121     (1 = =)
122     (2 set-marks)
123     (5 split)
124     | >)
125
126    ;; Case C : A syllable ending with other vowel(s).  Note that a
127    ;; two-part vowel may be expressed with two vowel marks for
128    ;; backward compatibility.
129    ("(RH)?(([CRBY]n?H[NJ]?)*([CRBY]n?))([mbup]+)"
130     < |
131     (1 = =)
132     (2 set-marks)
133     (5 = *)
134     | >)
135
136    ;; Case E : No explicit vowel nor modifier.  If the syllable ends
137    ;; with a consonant, analyse it for reordering in the next step.
138    ;; Otherwise, just identify the syllable without changing anything.
139    ;;1    23                         4
140    ("(RH)?(([CRBY]n?H[NJ]?)*[CRBY]n?)(HN|HJ|H)?"
141     < |
142     (1 = =)
143     (2 set-marks)
144     (4 = *)
145     | >)
146
147    ("." =))
148   *)
149
150  ;; Set mark #1 (x) at the position where below consonants begin, and
151  ;; mark #2 (y) at the position to which below and above signs will be
152  ;; moved.
153  (set-marks
154   (cond
155    ;; Ending with Y.
156    ;;1        2            3  45        6
157    ("([CRBY]n?(H[NJ]?Cn?)*)(H)(([RB]H)*)(Y)$"
158     (1 = *)                             ; prebase & base
159     0x0B7E                              ; below begin
160     (4 = *)                             ; below consonants
161     0x0B7F                              ; below end
162     (6 =)                               ; YA
163     (3 =))                              ; moved HALANT
164    ;; Ending with R or B.
165    ;;1        2            3  45
166    ("([CRBY]n?(H[NJ]?Cn?)*)(H)(([RB]H)*[RB])$"
167     (1 = *)                             ; prebase & base
168     0x0B7E                              ; below begin
169     (4 = *)                             ; below consonants 
170     (3 =)                               ; moved HALANT
171     0x0B7F)                             ; below end
172    (".+"
173     = *
174     0x0B7E                              ; below begin
175     0x0B7F)))                           ; below end
176
177  ;; Split two-part dependent vowel signs for canonicalisation.
178  (split
179   (cond
180    ((0x0B48)    0x0B47 0x0B56)
181    ((0x0B4B)    0x0B47 0x0B3E)
182    ((0x0B4C)    0x0B47 0x0B57)))
183  )
184
185 ;; Step 2 : Move Reph and Matra if necessary.  From now on, we care
186 ;; only for those syllables that have been identified in Step 1.
187 (generator
188  (0
189   (cond
190    ;; Special case: a single consonant and a Halant.
191    (" (.)xy(H[NJ]?) "
192     |
193     (1 =)
194     (2 = *)
195     |)
196
197    ;; This is the most generic pattern.  It follows Case A-C and a
198    ;; part of Case E in Step 1.  Now Mark #1 is used to indicate the
199    ;; critical part that requires pre-base substitution in the
200    ;; following steps.
201
202    ;; 1    2         3        4    5   6   7   8   9   10  11
203    (" (RH)?([^ xy]+)x([^ y]*)y(YH)?(m)?(b)?(u)?(p)?(A)?(a)?(HN|HJ|H)? "
204     |
205     (5 =)                               ; [Mpre]
206     ;; We can safely perform Nukta composition here because it does
207     ;; not affect surrounding letters in the syllable.  The Akhand
208     ;; ligature operation is also applied here, before applying the
209     ;; half form operation because the Utkal font generates Akhand
210     ;; ligatures directly from the "C H C" sequence, not via the half
211     ;; form.
212     0x0B7E                              ; begin Cpre & Cbase
213     (2 otf:orya=nukt,akhn+)             ; {Cpre + H} + Cbase
214     0x0B7E                              ; end Cpre & Cbase
215     (3 otf:orya=blwf+)                  ; {Cbelow + H}
216     (6 =)                               ; [Mbelow]
217     (7 =)                               ; [Mabove]
218     (1 otf:orya=rphf+)                  ; [Reph]
219     (4 otf:orya=pstf+)                  ; [Cpost + H]
220     (8 =)                               ; [Mpost]
221     (9 =)                               ; [VMabove]
222     (10 =)                              ; [VMpost]
223     (11 = *)                            ; optional HALANT
224     |)
225
226    ;; Syllables that begin with an independent vowel (following up
227    ;; Step 1, Case F).  Syllables of this type do not require further
228    ;; modification.
229    (" (V)(RH)(.*) "
230     |
231     (1 =)
232     (2 otf:orya=rphf+)
233     (3 = *)
234     |)
235
236    ("." =))
237   *))
238
239 ;; Step 3 : Now only those syllables that contain the pseudo character
240 ;; x require pre-base substition.  Unlike the Mukti font for Bengali,
241 ;; the Utkal font can produce the ligature for "C1 H C2" from
242 ;; "C1halant" and "C2".  If such a ligature is not available, we get a
243 ;; sequence consisting of "C1halant" and "C2", which is satisfactory.
244
245 (generator
246  (0
247   (cond
248    (" (.H)J "
249     |
250     (1 otf:orya=half+)
251     |)
252    (" (.H)N? "
253     |
254     (1 otf:orya=haln+)
255     |)
256    (" ([^x ]?x)([^x ]*)(x[^ ]*) "
257     |
258     (1 = *)
259     (2 pres)
260     (3 = *)
261     |)
262    ("." =))
263   *)
264
265  (pres
266   (cond
267    ("([^NJ]*)(.H)J(.*)"
268     (1 otf:orya=haln,pres+)
269     (2 otf:orya=half+)
270     (3 pres))
271    ("([^N]*)(H)N(.*)"
272     (1 otf:orya=haln,pres+)
273     (2 =)
274     (3 pres))
275    (".*"
276     otf:orya=haln,pres+)))
277     
278  )
279
280 ;; Step 4 : Mpre/Cpre reordering.  If the pre-base substitution in
281 ;; the previous step results in more than one glyph, and there is an
282 ;; Mpre in this syllable, then move the Mpre before the Cbase.
283 ;; i.e. [Mpre]{Kh}Kf... -> {Kh}[Mpre]Kf...
284
285 (generator
286  (0
287   (cond
288    (" ([^x ])x([^x ]+)([^x ])x([^x ]*) "
289     |
290     (2 = *)
291     (1 =)
292     (3 =)
293     (4 = *)
294     |)
295    (" ([^x ])?x([^x ]*)x([^ ]*) "
296     |
297     (1 =)
298     (2 = *)
299     (3 = *)
300     |)
301    ("." =))
302   *))
303
304 ;; Step 5 : Substitutions & positioning.
305
306 (generator
307  (0
308   (cond
309    (" ([^ ]*) "
310     ;; FIXME : The pres below is for the TTA ligature in the Utkal
311     ;; font.  It should be removed once the font is updated.
312     (1 otf:orya=vatu,abvs,blws,psts,pres))
313    ("."
314     [ otf:orya=+ ]))
315   *))
316
317 ;; Local Variables:
318 ;; mode: emacs-lisp
319 ;; End: