Versions changed to 1.6.1.
[m17n/m17n-db.git] / FLT / GURU-OTF.flt
1 ;; GURU-OTF.flt -- Font Layout Table for Gurmukhi OpenType fonts
2 ;; Copyright (C) 2004, 2007, 2008, 2010 AIST (H15PRO112)
3 ;; See the end for copying conditions.
4
5 (font layouter guru-otf nil
6       (version "1.6.0")
7       (font (nil nil unicode-bmp :otf=guru)))
8
9 ;;; <li> GURU-OTF.flt
10 ;;;
11 ;;; For Gurmukhi OpenType fonts to draw the Gurmukhi script.
12
13 (category
14  ;; B: consonants that have a below form
15  ;; C: consonants that do not
16  (0x0A00 0x0A7F ?X)                     ; generic
17  (0x0A01 0x0A02 ?a)                     ; SIGN ADAK BINDI .. BINDI
18  (0x0A03        ?A)                     ; SIGN VISARGA
19  (0x0A05 0x0A14 ?V)                     ; LETTER A .. AU
20  (0x0A15 0x0A38 ?C)                     ; LETTER KA .. SA
21  (0x0A2F        ?Y)                     ; LETTER YA
22  (0x0A30        ?B)                     ; LETTER RA
23  (0x0A35        ?B)                     ; LETTER VA
24  (0x0A39        ?B)                     ; LETTER HA
25  (0x0A3C        ?n)                     ; SIGN NUKTA
26  (0x0A3E        ?p)                     ; VOWEL SIGN AA
27  (0x0A3F        ?m)                     ; VOWEL SIGN I
28  (0x0A40        ?p)                     ; VOWEL SIGN II
29  (0x0A41 0x0A42 ?b)                     ; VOWEL SIGN U .. UU
30  (0x0A47 0x0A4C ?u)                     ; VOWEL SIGN EE .. AU
31  (0x0A4D        ?H)                     ; SIGN VIRAMA
32 ;; (0x0A51      ?)                      ; SIGN UDAAT
33  (0x0A59 0x0A5E ?C)                     ; LETTER KHHA .. FA
34  (0x0A70        ?a)                     ; TIPPI
35  (0x0A71        ?d)                     ; ADDAK
36 ;; (0x0A75      ?)                      ; SIGN YAKASH
37
38  (0x200C        ?N)                     ; ZWNJ
39  (0x200D        ?J)                     ; ZWJ
40  (0x25CC        ?X)                     ; DOTTED CIRCLE
41
42  (pstf          ?P)
43  )
44
45 ;; Stage 0
46 ;; Preprocessing
47 (generator
48  (0
49   (cond
50    ;; Compose a consonant and a nukta
51    ((0x0A32 0x0A3C) 0x0A33)
52    ((0x0A38 0x0A3C) 0x0A36)
53    ((0x0A16 0x0A3C) 0x0A59)
54    ((0x0A17 0x0A3C) 0x0A5A)
55    ((0x0A1C 0x0A3C) 0x0A5B)
56    ((0x0A2B 0x0A3C) 0x0A5E)
57    ("." =))
58   *))
59
60 ;; Stage 1
61 ;; Syllable identification
62 (generator
63  (0
64   (cond
65    ;; Consonant-based syllables
66    ;;1       23                  4
67    ("([CBY]n?((J?H|HJ?)[CBY]n?)*)(H[NJ]?|m?u?b?p?n?a?A?)"
68     < |
69     (cond
70      (".+HJ$" :otf=guru=nukt,akhn+)
71      ("(.+)(H)N?$" (1 :otf=guru=nukt,akhn+) (2 =) 0x200C)
72      (".+" :otf=guru=nukt,akhn+))
73     | >)
74
75    ;; Syllables with an independent vowel
76    ("(Vn?)((J?H[BY])?m?u?b?p?n?a?A?)"
77     < | (1 :otf=guru=nukt+) (2 = *) | >)
78
79    ;; Combining marks are displayed with a DOTTED CIRCLE.
80    ("m"
81     (cond
82      ((font-facility 0x25CC) < = 0x25CC >)
83      ("." [ = ])))
84    ("[nHubpaA]"
85     (cond
86      ((font-facility 0x25CC) < 0x25CC = >)
87      ("." [ = ])))
88
89    ;; Isolated blwf and pstf are displayed with a DOTTED CIRCLE in the
90    ;; next stage.
91    ("(J)(H)([BY])"
92     < | (1 =) (3 =) (2 =) | >)
93
94    ("." =))
95   *))
96
97 ;; Stage 2
98 ;; Reorder halant for blwf and pstf
99 (generator
100  (0
101   (cond
102    ;; Isolated blwf and pstf
103    ;; Saab.ttf uses vatu instead of blwf.
104    (" J([BY]H) "
105     (cond
106      ((font-facility 0x25CC) < 0x25CC (1 :otf=guru=blwf,pstf,vatu+) >)
107      (" J([BYR]H) " [ (1 :otf=guru=blwf,pstf,vatu+) ])))
108
109    ;; Syllables with an overt halant
110    (" ([^ ]+)(HN) "
111     | (1 reorder) (2 = =) |)
112
113    ;; Ordinary syllables
114    (" ([^mubpaA ]+)(m?u?b?p?n?a?A?) "
115     | (1 reorder) (2 = *) |)
116
117    ("." =))
118   *)
119
120  (reorder
121   ("(.|.+([^YJ]|JY|HJ))((J?HY)*)$"
122    (1 reorder-B *) (3 reorder-Y *)))
123
124  (reorder-B
125   (cond
126    ("J?(H)(B)"
127     (2 =) (1 =))
128    ("." =)))
129
130  (reorder-Y
131   ("J?(H)(Y)"
132    (2 =) (1 =)))
133  )
134
135 ;; Stage 3
136 ;; Language forms and matra reordering
137 (generator
138  (0
139   (cond
140    ;; Overt halant forms
141    (" ([^ ]+)(HN) "
142     | (1 b4post) (1 post) (2 = =) |)
143
144    ;; Other syllables
145    ;; 1            2     3     4     5     6   7
146    (" ([^mubpaA ]*)(mn?)?(un?)?(bn?)?(pn?)?(a)?(A)? "
147     | (2 = *) (1 b4post) (4 = *) (3 = *) (6 =) (1 post) (5 = *) (7 =) |)
148
149    ("." =))
150   *)
151
152  (b4post
153   (cond
154    ("(.H)J?(.*)"
155     (1 :otf=guru=half+)
156     (2 ("(.|.+([^YH]|JY|BH))((YH)*)$" (1 lang-forms *))))
157    ("(.|.+([^YH]|JY|BH))((YH)*)"
158     (1 lang-forms *))))
159
160  (lang-forms
161   (cond
162    ("(.H)J" (1 :otf=guru=half+))
163    (".H" :otf=guru=blwf,half,vatu+)
164    ("." =)))
165
166  (post
167   ("(.|.+([^YH]|JY|BH))((YH)+)$"
168    ;; lohit_pa.ttf uses psts instead of pstf for YA.
169    (3 :otf=guru=pstf+psts)))
170  )
171
172 ;; Stage 4
173 ;; Final reordering (Move pre-base matra after the last halant)
174 (generator
175  (0
176   (cond
177    ;; 1    2         3
178    (" (mn?)([^ ]+HJ?)([^H ]+) "
179     | (2 = *) (1 = *) (3 = *) |)
180
181    ("." =))
182   *))
183
184 ;; Stage 5
185 ;; Nukta for matra and Presentation forms
186 (generator
187  (0
188   (cond
189    (" ([^ ]+) "
190     ;; lohit_pa.ttf uses vatu instead of blws.
191     | (1 :otf=guru=nukt,vatu,pres,abvs,blws,psts,haln+) |)
192
193    ("." =))
194   *))
195
196 ;; Stage 6
197 ;; Remove ZWNJ/ZWJ
198 (generator
199  (0
200   (cond
201    ("[NJ]")
202
203    ("." =))
204   *))
205
206 ;; Stage 7
207 ;; GPOS processing
208 (generator
209  (0
210   (cond
211    (" ([^ ]+) "
212     (1 :otf=guru=+abvm,blwm,dist))
213
214    ("." =))
215   *))
216
217 ;; Copyright (C) 2004, 2007, 2008, 2010
218 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
219 ;;   Registration Number H15PRO112
220
221 ;; This file is part of the m17n database; a sub-part of the m17n
222 ;; library.
223
224 ;; The m17n library is free software; you can redistribute it and/or
225 ;; modify it under the terms of the GNU Lesser General Public License
226 ;; as published by the Free Software Foundation; either version 2.1 of
227 ;; the License, or (at your option) any later version.
228
229 ;; The m17n library is distributed in the hope that it will be useful,
230 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
231 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
232 ;; Lesser General Public License for more details.
233
234 ;; You should have received a copy of the GNU Lesser General Public
235 ;; License along with the m17n library; if not, write to the Free
236 ;; Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
237 ;; Boston, MA 02110-1301, USA.
238
239 ;; Local Variables:
240 ;; mode: emacs-lisp
241 ;; End: