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