Put internal mark (Z) aftter the below form consonant rather than
[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 0x0902 ?A)                     ; SIGN CANDRABINDU .. ANUSVARA
52  (0x0903        ?a)                     ; SIGN VISARGA
53  (0x0904 0x0914 ?V)                     ; LETTER SHORT A .. AU
54  (0x0915 0x0939 ?C)                     ; LETTER KA .. HA
55  (0x0930        ?R)                     ; LETTER RA
56  (0x093C        ?n)                     ; SIGN NUKTA
57  (0x093E        ?p)                     ; VOWEL SIGN AA
58  (0x093F        ?m)                     ; VOWEL SIGN I
59  (0x0940        ?p)                     ; VOWEL SIGN II
60  (0x0941 0x0944 ?b)                     ; VOWEL SIGN UU .. VOCALIC RR
61  (0x0945 0x0948 ?u)                     ; VOWEL SIGN CANDRA E .. AI
62  (0x0949 0x094C ?p)                     ; VOWEL SIGN CANDRA O .. AU
63  (0x094D        ?H)                     ; SIGN VIRAMA
64  (0x0951        ?S)                     ; STRESS SIGN UDATTA
65  (0x0952        ?s)                     ; STRESS SIGN ANUDATTA
66  (0x0953 0x0954 ?S)                     ; GRAVE ACCENT .. ACUTE ACCENT
67  (0x0958 0x095F ?C)                     ; LETTER QA .. YYA
68  (0x0960 0x0961 ?V)                     ; LETTER VOCALIC RR  .. VOCALIC LL
69  (0x0962 0x0963 ?b)                     ; VOWEL SIGN VOCALIC L .. VOCALIC LL
70  (0x097B 0x097C ?C)                     ; LETTER GGA .. JJA
71  (0x097E 0x097F ?C)                     ; LETTER DDDA .. BBA
72  (0x200C        ?N)                     ; ZWNJ
73  (0x200D        ?J)                     ; ZWJ
74  )
75
76 ;; Reordering
77 (generator
78  (0
79   (cond
80    ;; A syllable containing a vowel sign.
81    ;;1    23                45   6   7      8   9   10  11
82    ("(RH)?(([CR]n?H)*[CR]n?)((m)|(b)|([up]))(A)?(a)?(S)?(s)?"
83     < |
84     (5 =) (2 move-h) (6 =) (11 =) (7 =) (1 otf:deva=rphf+) (8 =) (10 =) (9 =)
85     | >)
86
87    ;; A syllable without vowel signs but with a vowel modifier.
88    ;;1    23                45   6   7   8
89    ("(RH)?(([CR]n?H)*[CR]n?)((A)|(a))(S)?(s)?"
90     < | (2 move-h) (8 =) (1 otf:deva=rphf+) (5 =) (7 =) (6 =) | >)
91
92    ;; No vowel signs, No vowel modifiers, but with a stress sign or an accent.
93    ;;1    23                45   6  
94    ("(RH)?(([CR]n?H)*[CR]n?)((S)|(s))"
95     < | (2 move-h) (6 =) (1 otf:deva=rphf+) (5 =) | >)
96
97    ;; A special case: eyelash RA
98    ("(RH)J"
99     < (1 otf:deva=half+) >)
100
101    ;; Forced half form.  Do not move halant.
102    ;;1    23
103    ("(RH)?(([CR]n?H)+)J"
104     < | (2 = *) (1 otf:deva=rphf+) | >)
105
106    ;; When a syllable ends with a halant, add a ZWNJ explicitly.
107    ;;1    23                4   5
108    ("(RH)?(([CR]n?H)*[CR]n?)(H)?(N)?"
109     < | (2 move-h) (1 otf:deva=rphf+) (4 = 0x200C) | >)
110
111    ;; A syllable starting with an independent vowel.
112    ;;1  2   3   4   5
113    ("(V)(A)?(a)?(S)?(s)?"
114     < | (1 =) (5 =) (2 =) (4 =) (3 =) | >)
115
116    ("." =))
117   *)
118
119  ;; Move the halant that follows the base consonant to the end.
120  ;; Put a mark after the below form consonants.
121  (move-h
122   (cond
123    ;;12             3  45
124    ("(([CR]n?H)*Cn?)(H)((RH)*R)$"
125     (1 = *) (4 = *) (3 =) 0x0900)
126    ;;1  2  34
127    ("(R)(H)((RH)*R)$"
128     (1 =) (3 = *) (2 =) 0x0900)
129    (".+" = * 0x0900))))
130
131 ;; If a syllable ends with a halant and a ZWNJ, render the final
132 ;; halant explicitly.  Do not apply 'blwf' nor 'half' to the initial
133 ;; RA.
134 (generator
135  (0
136   (cond
137    (" (R)([^Z]*)(Z)([^ ]*)(H)N "
138     | (1 =) (2 gsub1) (3 =) (4 = *) (5 =) |)
139    (" (m?R)([^Z ]*)(Z)?([^ ]*) "
140     | (1 = *) (2 gsub1) (3 =) (4 = *) |)
141    (" ([^Z]+)(Z)([^ ]*)(H)N "
142     | (1 gsub1) (2 =) (3 * =) (4 =) |)
143    (" (m)?([^Z ]+)(Z)?([^ ]*) "
144     | (1 =) (2 gsub1) (3 =) (4 = *) |)
145    ("." =))
146   *)
147
148  (gsub1
149   otf:deva=nukt,akhn,blwf,half,vatu,pres+))
150
151 ;; When the number of glyphs between a pre-base vowel sign and the
152 ;; post-below mark is more than one, move the pre-base vowel sign
153 ;; before the final glyph.
154 (generator
155  (0
156   (cond
157    (" (m)([^Z]+)([^Z])Z([^ ]*) "
158     | (2 = *) (1 =) (3 =) (4 = *) |)
159    (" ([^Z]+)Z([^ ]*) "
160     | (1 = *) (2 = *) |)
161    ("." =))
162   *))
163
164 ;; Apply other features.  The 'pres' feature is applied again for
165 ;; pre-base vowel sign.
166 (generator
167  (0
168   (cond
169    (" ([^ ]+) "
170     (1 otf:deva=pres,abvs,blws,psts,haln))
171    ("."
172     [ otf:deva=+ ]))
173   *))
174
175 ;; Local Variables:
176 ;; mode: emacs-lisp
177 ;; End: