Moved from the parent directory. Add layouter information.
[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: MATRA (pre)
37  ;; u: MATRA (above)
38  ;; b: MATRA (below)
39  ;; p: MATRA (post)
40  ;; A: vowel modifier (above)
41  ;; a: vowel modifier (post)
42  ;; S: stress sign (above)
43  ;; s: stress sign (below)
44  ;; V: independent vowel
45  ;; N: ZWNJ (ZERO WIDTH NON-JOINER)
46  ;; J: ZWJ (ZERO WIDTH JOINER)
47  ;; E: ELSE
48  ;;
49  (#x0900 #x097F ?E)                     ; ELSE
50  (#x0901        ?A)                     ; SIGN CANDRABINDU (above)
51  (#x0902        ?A)                     ; SIGN ANUSVARA (above)
52  (#x0903        ?a)                     ; SIGN VISARGA (post)
53  (#x0905 #x0914 ?V)                     ; LETTER A .. LETTER AU
54  (#x0915 #x0939 ?C)                     ; LETTER KA .. LETTER HA
55  (#x0930        ?R)                     ; LETTER RA
56  (#x093C        ?n)                     ; SIGN NUKTA
57  (#x093D        ?E)                     ; SIGN AVAGRAHA
58  (#x093E #x094C ?p)                     ; VOWEL SIGN (post)
59  (#x093F        ?m)                     ; VOWEL SIGN I (pre)
60  (#x0941 #x0944 ?b)                     ; VOWEL SIGN (below)
61  (#x0945 #x0948 ?u)                     ; VOWEL SIGN (above)
62  (#x094D        ?H)                     ; SIGN VIRAMA (HALANT)
63  (#x0950        ?E)                     ; OM
64  (#x0951 #x0954 ?S)                 ; STRESS SIGN or TONE MARK (above)
65  (#x0952        ?s)                 ; STRESS SIGN or TONE MARK (below)
66  (#x0958 #x095E ?C)                     ; LETTER QA .. LETTER YYA
67  (#x0960        ?V)                     ; LETTER VOCALIC RR
68  (#x0961        ?V)                     ; LETTER VOCALIC LL
69  (#x0962 #x0963 ?b)                     ; VOWEL SIGN (below)
70  (#x0964 #x0970 ?E)                     ; DANDA .. ABBREVIATION SIGN
71  (#x200C        ?N)                     ; ZWNJ
72  (#x200D        ?J)                     ; ZWJ
73  (#x097D        ?x)             ; internally used tag to indicate Reph
74  (#x097E        ?y)             ; internally used tag to indicate Mpost
75  (#x097F        ?z)             ; internally used tag to indicate Cbase
76  )
77
78 ;; The first stage is to extract a syllable and re-order characters in
79 ;; it.
80 (generator
81  (0
82   (cond
83    ;; If [CR]H is followed by ZWNJ/ZWJ, move ZWNJ/ZWJ to the head so
84    ;; that the later stages find it quickly.
85    ("([CR]n?H)([NJ])"
86     < | (2 =) (1 = *) | > )
87
88    ;; A syllable starting with RH (Reph) and ending with a vowel
89    ;; and/or a vowel modifier.
90    ("(RH)(([CR]n?H)*[CR]n?)([mubp][Aa]?[Ss]?|[Aa][Ss]?|[Ss])"
91     < | (1 #x097D = =) (2 move-base-Halant) (4 reorder-post-base) | >)
92
93    ;; A syllable starting with RH (Reph) and ending without a vowel
94    ;; nor a vowel modifier.
95    ("(RH)(([CR]n?H)*[CR]n?)(H)?"
96     < | (1 #x097D = =) (2 move-base-Halant) (4 =) | >)
97
98    ;; A syllable starting with the other consonant and ending with a
99    ;; vowel and/or a vowel modifier.
100    ("(([CR]n?H)*[CR]n?)([mubp][Aa]?[Ss]?|[Aa][Ss]?|[Ss])"
101     < | (1 move-base-Halant) (3 reorder-post-base) | >)
102
103    ;; A syllable starting with the other consonant and ending without
104    ;; a vowel nor a vowel modifier.
105    ("(([CR]n?H)*[CR]n?)(H)?"
106     < | (1 move-base-Halant) (3 =) | >)
107
108    ;; A syllable starting with an independent vowel.
109    ("V[Aa]?[Ss]?"
110     < | = * | > )
111
112    ("." =))
113   *)
114
115  ;; Move Halant on a base consonant to the tail.
116  (move-base-Halant
117   (cond
118    ("(([CR]n?H)*[CR]n?)(H)(R)"
119     (1 = *)
120     (4 =)
121     (3 =))
122    (".*"
123     = *)))
124
125  ;; Re-order post modifiers.
126  (reorder-post-base
127   ;; 12   3   4   5    67   8     9   10
128   ("((m)|(u)|(b)|(p))?((A)|(a))?((S)|(s))?$"
129    (2 =) (4 =) (10 =) (3 =) (5 =)
130    #x097E
131    (7 =) (9 =) (8))))
132
133 ;; The second stage is to reorder Reph and Mpre.
134 (generator
135  (0
136   (cond
137    (" [NJ]([^ ]*) "
138     = *)
139    (" (x(..))([CRnH]*) "
140     | (3 = *) (2 otf:deva=rphf) |)
141    (" (x(..))([CRnH]*)(m?)([^y]*)y([^ ]*) "
142     | (4 =) (3 = *) (5 = *) (2 otf:deva=rphf) (6 = *) |)
143    (" ([CRnH][CRnH]*) "
144     = *)
145    (" ([CRnH][CRnH]*)(m?)([^y]*)y([^ ]*) "
146     | (2 =) (1 = *) (3 = *) (4 = *) |)
147    ("." =))
148   *))
149
150 ;; The third stage is to drive OTF tables.  For the moment, we use
151 ;; the default LangSys, and try all GSUB/GPOS features except for the
152 ;; sequence followed by ZWNJ in which case try "nukt" and "haln"
153 ;; features only.
154 (generator
155  (0
156   (cond
157    (" N([^ ]*) "
158     (1 otf:deva=nukt,haln))
159
160    (" J([^ ]*) "
161     (1 otf:deva))
162
163    (" ([^ ]*)(CH) "
164     (1 otf:deva=~rphf,*) (2 otf:deva=haln))
165
166    (" ([^ ]*) "
167     (1 otf:deva=~rphf,*))
168
169    ("."
170     \[ otf:deva=+ \] ))
171   *))
172
173 ;; Local Variables:
174 ;; mode: emacs-lisp
175 ;; End: