*** empty log message ***
[m17n/m17n-db.git] / FLT / DEVA-OTF.flt
1 ;; DEVA-OTF.flt -- Font Layout Table for Devanagari OpenType font
2 ;; Copyright (C) 2003, 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> DEVA-OTF.flt
25 ;;;
26 ;;; For Devanagari OpenType fonts to draw the Devanagari script.
27
28 (font layouter deva-otf nil
29       (font (nil nil unicode-bmp :otf=deva=rphf)))
30
31 (category
32  ;; C: consonant (except for R)
33  ;; R: consonant RA
34  ;; n: NUKTA
35  ;; H: HALANT
36  ;; m: vowel sign (pre)
37  ;; u: vowel sign (above)
38  ;; b: vowel sign (below)
39  ;; p: vowel sign (post)
40  ;; A: vowel modifier (above)
41  ;; a: vowel modifier (post)
42  ;; S: stress sign / accent (above)
43  ;; s: stress sign / accent (below)
44  ;; V: independent vowel
45  ;; N: ZWNJ
46  ;; J: ZWJ
47  ;; X: generic
48  ;; Z: internal use
49  (0x0900        ?Z)                     ; internal use
50  (0x0901 0x097F ?X)                     ; generic
51  (0x0901        ?A)                     ; SIGN CANDRABINDU
52  (0x0902        ?A)                     ; SIGN ANUSVARA
53  (0x0903        ?a)                     ; SIGN VISARGA
54  (0x0904 0x0914 ?V)                     ; LETTER SHORT A .. AU
55  (0x0915 0x0939 ?C)                     ; LETTER KA .. HA
56  (0x0930        ?R)                     ; LETTER RA
57  (0x093C        ?n)                     ; SIGN NUKTA
58  (0x093E        ?p)                     ; VOWEL SIGN AA
59  (0x093F        ?m)                     ; VOWEL SIGN I
60  (0x0940        ?p)                     ; VOWEL SIGN II
61  (0x0941 0x0944 ?b)                     ; VOWEL SIGN UU .. VOCALIC RR
62  (0x0945 0x0948 ?u)                     ; VOWEL SIGN CANDRA E .. AI
63  (0x0949 0x094C ?p)                     ; VOWEL SIGN CANDRA O .. AU
64  (0x094D        ?H)                     ; SIGN VIRAMA
65  (0x0951        ?S)                     ; STRESS SIGN UDATTA
66  (0x0952        ?s)                     ; STRESS SIGN ANUDATTA
67  (0x0953 0x0954 ?S)                     ; GRAVE ACCENT .. ACUTE ACCENT
68  (0x0958 0x095F ?C)                     ; LETTER QA .. YYA
69  (0x0960 0x0961 ?V)                     ; LETTER VOCALIC RR  .. VOCALIC LL
70  (0x0962 0x0963 ?b)                     ; VOWEL SIGN VOCALIC L .. VOCALIC LL
71  (0x097B 0x097C ?C)                     ; LETTER GGA .. JJA
72  (0x097E 0x097F ?C)                     ; LETTER DDDA .. BBA
73  (0x200C        ?N)                     ; ZWNJ
74  (0x200D        ?J)                     ; ZWJ
75  )
76
77 ;; Reordering
78 (generator
79  (0
80   (cond
81    ;; A syllable containing a vowel sign.
82    ;;1    23                45   6   7      89   A    BC   D
83    ("(RH)?(([CR]n?H)*[CR]n?)((m)|(b)|([up]))((A)|(a))?((S)|(s))?"
84     < |
85     (5 =) (2 move-h) (6 =) (13 =) (7 =) (1 otf:deva=rphf+) (9 =) (12 =) (10 =)
86     | >)
87
88    ;; A syllable without vowel signs but with a vowel modifier.
89    ;;1    23                45   6   78   9
90    ("(RH)?(([CR]n?H)*[CR]n?)((A)|(a))((S)|(s))?"
91     < | (2 move-h) (9 =) (1 otf:deva=rphf+) (5 =) (8 =) (6 =) | >)
92
93    ;; No vowel signs, No vowel modifiers, but with a stress sign or an accent.
94    ;;1    23                45   6  
95    ("(RH)?(([CR]n?H)*[CR]n?)((S)|(s))"
96     < | (2 move-h) (6 =)(1 otf:deva=rphf+) (5 =) | >)
97
98    ;; A special case: eyelash RA
99    ("(RH)J"
100     < (1 otf:deva=half+) >)
101
102    ;; Forced half form.  Do not move halant.
103    ;;1    23
104    ("(RH)?(([CR]n?H)+)J"
105     < | (2 = *) (1 otf:deva=rphf+) | >)
106
107    ;; When a syllable ends with a halant, add a ZWNJ explicitly.
108    ;;1    23                4   5
109    ("(RH)?(([CR]n?H)*[CR]n?)(H)?(N)?"
110     < | (2 move-h) (1 otf:deva=rphf+) (4 = 0x200C) | >)
111
112    ;; A syllable starting with an independent vowel.
113    ;;1  23   4    56   7
114    ("(V)((A)|(a))?((S)|(s))?"
115     < | (1 =) (7 =) (3 =) (6 =) (4 =) | >)
116
117    ("." =))
118   *)
119
120  ;; Move the halant that follows the base consonant to the end.
121  ;; Put a mark after the base consonant.
122  (move-h
123   (cond
124    ;;12         3     4  56
125    ("(([CR]n?H)*(Cn?))(H)((RH)*R)$"
126     (1 = *) 0x0900 (5 = *) (4 =))
127    ;;1  2  34
128    ("(R)(H)((RH)*R)$"
129     (1 =) 0x0900 (3 = *) (2 =))
130    (".+" = * 0x0900))))
131
132 ;; If a syllable ends with a halant and a ZWNJ, render the final
133 ;; halant explicitly.  Do not apply 'blwf' nor 'half' to the initial
134 ;; RA.
135 (generator
136  (0
137   (cond
138    (" (R)([^Z ]*)(Z)?([^ ]*)(H)N "
139     | (1 =) (2 gsub1) (3 =) (4 gsub2) (5 =) |)
140    (" (m?R)([^Z ]*)(Z)?([^ ]*) "
141     | (1 = *) (2 gsub1) (3 =) (4 gsub2) |)
142    (" ([^Z ]+)(Z)?([^ ]*)(H)N "
143     | (1 gsub1) (2 =) (3 gsub2) (4 =) |)
144    (" ([^Z ]+)(Z)?([^ ]*) "
145     | (1 gsub1) (2 =) (3 gsub2) |)
146    ("." =))
147   *)
148
149  (gsub1
150   otf:deva=nukt,akhn,blwf,half,vatu+)
151
152  (gsub2
153   otf:deva=blwf+))
154
155 ;; Apply 'pres' to get pre-base conjuncts.
156 (generator
157  (0
158   (cond
159    (" (m)?([^Z ]+)(Z[^ ]*) "
160     | (1 =) (2 otf:deva=pres+) (3 = *) |)
161    ("." =))
162   *))
163
164 ;; When the number of glyphs between a pre-base vowel sign and the
165 ;; post-base mark is more than one, move the pre-base vowel sign
166 ;; before the base glyph.
167 (generator
168  (0
169   (cond
170 ;;   (" (m)([^ZH ]+)(H)([^Z ])Z([^ ]*) "
171 ;;    | (2 = *) (3 =) (1 =) (4 =) (5 = *) |)
172    (" (m)([^Z]+)([^Z])Z([^ ]*) "
173     | (2 = *) (1 =) (3 =) (4 = *) |)
174    (" ([^Z]+)Z([^ ]*) "
175     | (1 = *) (2 = *) |)
176    ("." =))
177   *))
178
179 ;; Apply other features.  The 'vatu' feature is applied again to get
180 ;; base and post-base conjunct.  The 'pres' feature is also applied
181 ;; again for pre-base vowel sign.
182 (generator
183  (0
184   (cond
185    (" ([^ ]+) "
186     (1 otf:deva=vatu,pres,abvs,blws,psts,haln))
187    ("."
188     [ otf:deva=+ ]))
189   *))
190
191 ;; Local Variables:
192 ;; mode: emacs-lisp
193 ;; End: