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