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