1 /*
2 *
3 * (C) Copyright IBM Corp. 1998-2007 - All Rights Reserved
4 *
5 */
6
7 #include "LETypes.h"
8 #include "LEScripts.h"
9 #include "OpenTypeTables.h"
10 #include "OpenTypeUtilities.h"
11 #include "IndicReordering.h"
12
13 U_NAMESPACE_BEGIN
14
15 // Split matra table indices
16 #define _x1 (1 << CF_INDEX_SHIFT)
17 #define _x2 (2 << CF_INDEX_SHIFT)
18 #define _x3 (3 << CF_INDEX_SHIFT)
19 #define _x4 (4 << CF_INDEX_SHIFT)
20 #define _x5 (5 << CF_INDEX_SHIFT)
21 #define _x6 (6 << CF_INDEX_SHIFT)
22 #define _x7 (7 << CF_INDEX_SHIFT)
23 #define _x8 (8 << CF_INDEX_SHIFT)
24 #define _x9 (9 << CF_INDEX_SHIFT)
25
26 // simple classes
27 #define _xx (CC_RESERVED)
28 #define _ma (CC_VOWEL_MODIFIER | CF_POS_ABOVE)
29 #define _mp (CC_VOWEL_MODIFIER | CF_POS_AFTER)
30 #define _sa (CC_STRESS_MARK | CF_POS_ABOVE)
31 #define _sb (CC_STRESS_MARK | CF_POS_BELOW)
32 #define _iv (CC_INDEPENDENT_VOWEL)
33 #define _i2 (CC_INDEPENDENT_VOWEL_2)
34 #define _i3 (CC_INDEPENDENT_VOWEL_3)
35 #define _ct (CC_CONSONANT | CF_CONSONANT)
36 #define _cn (CC_CONSONANT_WITH_NUKTA | CF_CONSONANT)
37 #define _nu (CC_NUKTA)
38 #define _dv (CC_DEPENDENT_VOWEL)
39 #define _dl (_dv | CF_POS_BEFORE)
40 #define _db (_dv | CF_POS_BELOW)
41 #define _da (_dv | CF_POS_ABOVE)
42 #define _dr (_dv | CF_POS_AFTER)
43 #define _lm (_dv | CF_LENGTH_MARK)
44 #define _l1 (CC_SPLIT_VOWEL_PIECE_1 | CF_POS_BEFORE)
45 #define _a1 (CC_SPLIT_VOWEL_PIECE_1 | CF_POS_ABOVE)
46 #define _b2 (CC_SPLIT_VOWEL_PIECE_2 | CF_POS_BELOW)
47 #define _r2 (CC_SPLIT_VOWEL_PIECE_2 | CF_POS_AFTER)
48 #define _m2 (CC_SPLIT_VOWEL_PIECE_2 | CF_LENGTH_MARK)
49 #define _m3 (CC_SPLIT_VOWEL_PIECE_3 | CF_LENGTH_MARK)
50 #define _vr (CC_VIRAMA)
51
52 // split matras
53 #define _s1 (_dv | _x1)
54 #define _s2 (_dv | _x2)
55 #define _s3 (_dv | _x3)
56 #define _s4 (_dv | _x4)
57 #define _s5 (_dv | _x5)
58 #define _s6 (_dv | _x6)
59 #define _s7 (_dv | _x7)
60 #define _s8 (_dv | _x8)
61 #define _s9 (_dv | _x9)
62
63 // consonants with special forms
64 // NOTE: this assumes that no consonants with nukta have
65 // special forms... (Bengali RA?)
66 #define _bb (_ct | CF_BELOW_BASE)
67 #define _pb (_ct | CF_POST_BASE)
68 #define _vt (_bb | CF_VATTU)
69 #define _rv (_vt | CF_REPH)
70 #define _rp (_pb | CF_REPH)
71 #define _rb (_bb | CF_REPH)
72
73 //
74 // Character class tables
75 //
76 static const IndicClassTable::CharClass devaCharClasses[] =
77 {
78 _xx, _ma, _ma, _mp, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, // 0900 - 090F
79 _iv, _iv, _iv, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, // 0910 - 091F
80 _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _cn, _ct, _ct, _ct, _ct, _ct, _ct, // 0920 - 092F
81 _rv, _cn, _ct, _ct, _cn, _ct, _ct, _ct, _ct, _ct, _xx, _xx, _nu, _xx, _dr, _dl, // 0930 - 093F
82 _dr, _db, _db, _db, _db, _da, _da, _da, _da, _dr, _dr, _dr, _dr, _vr, _xx, _xx, // 0940 - 094F
83 _xx, _sa, _sb, _sa, _sa, _xx, _xx, _xx, _cn, _cn, _cn, _cn, _cn, _cn, _cn, _cn, // 0950 - 095F
84 _iv, _iv, _db, _db, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0960 - 096F
85 _xx // 0970
86 };
87
88 static const IndicClassTable::CharClass bengCharClasses[] =
89 {
90 _xx, _ma, _mp, _mp, _xx, _i2, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _i2, // 0980 - 098F
91 _iv, _xx, _xx, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, // 0990 - 099F
92 _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _ct, _bb, _ct, _ct, _pb, // 09A0 - 09AF
93 _rv, _xx, _ct, _xx, _xx, _xx, _ct, _ct, _ct, _ct, _xx, _xx, _nu, _xx, _r2, _dl, // 09B0 - 09BF
94 _dr, _db, _db, _db, _db, _xx, _xx, _l1, _dl, _xx, _xx, _s1, _s2, _vr, _xx, _xx, // 09C0 - 09CF
95 _xx, _xx, _xx, _xx, _xx, _xx, _xx, _m2, _xx, _xx, _xx, _xx, _cn, _cn, _xx, _cn, // 09D0 - 09DF
96 _iv, _iv, _dv, _dv, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 09E0 - 09EF
97 _rv, _ct, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx // 09F0 - 09FA
98 };
99
100 static const IndicClassTable::CharClass punjCharClasses[] =
101 {
102 _xx, _ma, _ma, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _xx, _xx, _iv, // 0A00 - 0A0F
103 _iv, _xx, _xx, _i3, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, // 0A10 - 0A1F
104 _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _ct, _ct, _ct, _ct, _bb, // 0A20 - 0A2F
105 _vt, _xx, _ct, _cn, _xx, _bb, _cn, _xx, _ct, _bb, _xx, _xx, _nu, _xx, _dr, _dl, // 0A30 - 0A3F
106 _dr, _b2, _db, _xx, _xx, _xx, _xx, _da, _da, _xx, _xx, _a1, _da, _vr, _xx, _xx, // 0A40 - 0A4F
107 _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _cn, _cn, _cn, _ct, _xx, _cn, _xx, // 0A50 - 0A5F
108 _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0A60 - 0A6F
109 _ma, _ma, _xx, _xx, _xx // 0A70 - 0A74
110 };
111
112 static const IndicClassTable::CharClass gujrCharClasses[] =
113 {
114 _xx, _ma, _ma, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _iv, _xx, _iv, // 0A80 - 0A8F
115 _iv, _iv, _xx, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, // 0A90 - 0A9F
116 _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _ct, _ct, _ct, _ct, _ct, // 0AA0 - 0AAF
117 _rv, _xx, _ct, _ct, _xx, _ct, _ct, _ct, _ct, _ct, _xx, _xx, _nu, _xx, _dr, _dl, // 0AB0 - 0ABF
118 _dr, _db, _db, _db, _db, _da, _xx, _da, _da, _dr, _xx, _dr, _dr, _vr, _xx, _xx, // 0AC0 - 0ACF
119 _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0AD0 - 0ADF
120 _iv, _iv, _db, _db, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx // 0AE0 - 0AEF
121 };
122
123 #if 1
124 static const IndicClassTable::CharClass oryaCharClasses[] =
125 {
126 _xx, _ma, _mp, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _iv, /* 0B00 - 0B0F */
127 _iv, _xx, _xx, _iv, _iv, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _ct, _bb, /* 0B10 - 0B1F */
128 _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _xx, _bb, _bb, _bb, _bb, _bb, _pb, /* 0B20 - 0B2F */
129 _rb, _xx, _bb, _bb, _xx, _bb, _bb, _bb, _bb, _bb, _xx, _xx, _nu, _xx, _dr, _da, /* 0B30 - 0B3F */
130 _dr, _db, _db, _db, _xx, _xx, _xx, _dl, _s1, _xx, _xx, _s2, _s3, _vr, _xx, _xx, /* 0B40 - 0B4F */
131 _xx, _xx, _xx, _xx, _xx, _xx, _da, _dr, _xx, _xx, _xx, _xx, _cn, _cn, _xx, _pb, /* 0B50 - 0B5F */
132 _iv, _iv, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, /* 0B60 - 0B6F */
133 _xx, _bb /* 0B70 - 0B71 */
134 };
135 #else
136 static const IndicClassTable::CharClass oryaCharClasses[] =
137 {
138 _xx, _ma, _mp, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _iv, // 0B00 - 0B0F
139 _iv, _xx, _xx, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, // 0B10 - 0B1F
140 _ct, _ct, _ct, _ct, _bb, _ct, _ct, _ct, _bb, _xx, _ct, _ct, _bb, _bb, _bb, _pb, // 0B20 - 0B2F
141 _rb, _xx, _bb, _bb, _xx, _ct, _ct, _ct, _ct, _ct, _xx, _xx, _nu, _xx, _r2, _da, // 0B30 - 0B3F
142 _dr, _db, _db, _db, _xx, _xx, _xx, _l1, _s1, _xx, _xx, _s2, _s3, _vr, _xx, _xx, // 0B40 - 0B4F
143 _xx, _xx, _xx, _xx, _xx, _xx, _m2, _m2, _xx, _xx, _xx, _xx, _cn, _cn, _xx, _cn, // 0B50 - 0B5F
144 _iv, _iv, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0B60 - 0B6F
145 _xx, _ct // 0B70 - 0B71
146 };
147 #endif
148
149 static const IndicClassTable::CharClass tamlCharClasses[] =
150 {
151 _xx, _xx, _ma, _xx, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _xx, _iv, _iv, // 0B80 - 0B8F
152 _iv, _xx, _iv, _iv, _iv, _ct, _xx, _xx, _xx, _ct, _ct, _xx, _ct, _xx, _ct, _ct, // 0B90 - 0B9F
153 _xx, _xx, _xx, _ct, _ct, _xx, _xx, _xx, _ct, _ct, _ct, _xx, _xx, _xx, _ct, _ct, // 0BA0 - 0BAF
154 _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _ct, _ct, _xx, _xx, _xx, _xx, _r2, _dr, // 0BB0 - 0BBF
155 _da, _dr, _dr, _xx, _xx, _xx, _l1, _l1, _dl, _xx, _s1, _s2, _s3, _vr, _xx, _xx, // 0BC0 - 0BCF
156 _xx, _xx, _xx, _xx, _xx, _xx, _xx, _m2, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0BD0 - 0BDF
157 _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0BE0 - 0BEF
158 _xx, _xx, _xx // 0BF0 - 0BF2
159 };
160
161 // FIXME: Should some of the bb's be pb's? (KA, NA, MA, YA, VA, etc. (approx 13))
162 static const IndicClassTable::CharClass teluCharClasses[] =
163 {
164 _xx, _mp, _mp, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _iv, _iv, // 0C00 - 0C0F
165 _iv, _xx, _iv, _iv, _iv, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, // 0C10 - 0C1F
166 _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _xx, _bb, _bb, _bb, _bb, _bb, _bb, // 0C20 - 0C2F
167 _bb, _bb, _bb, _bb, _xx, _bb, _bb, _bb, _bb, _bb, _xx, _xx, _xx, _xx, _da, _da, // 0C30 - 0C3F
168 _da, _dr, _dr, _dr, _dr, _xx, _a1, _da, _s1, _xx, _da, _da, _da, _vr, _xx, _xx, // 0C40 - 0C4F
169 _xx, _xx, _xx, _xx, _xx, _da, _m2, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0C50 - 0C5F
170 _iv, _iv, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx // 0C60 - 0C6F
171 };
172
173 // U+CC3 and U+CC4 are _lm here not _dr since the Kannada rendering
174 // rules want them below and to the right of the entire cluster
175 //
176 // There's some information about this in:
177 //
178 // http://brahmi.sourceforge.net/docs/KannadaComputing.html
179 static const IndicClassTable::CharClass kndaCharClasses[] =
180 {
181 _xx, _xx, _mp, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _iv, // 0C80 - 0C8F
182 _iv, _xx, _iv, _iv, _iv, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, // 0C90 - 0C9F
183 _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _xx, _bb, _bb, _bb, _bb, _bb, _bb, // 0CA0 - 0CAF
184 _rb, _ct, _bb, _bb, _xx, _bb, _bb, _bb, _bb, _bb, _xx, _xx, _xx, _xx, _dr, _da, // 0CB0 - 0CBF
185 _s1, _dr, _r2, _lm, _lm, _xx, _a1, _s2, _s3, _xx, _s4, _s5, _da, _vr, _xx, _xx, // 0CC0 - 0CCF
186 _xx, _xx, _xx, _xx, _xx, _m3, _m2, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _ct, _xx, // 0CD0 - 0CDF
187 _iv, _iv, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx // 0CE0 - 0CEF
188 };
189
190 // FIXME: this is correct for old-style Malayalam (MAL) but not for reformed Malayalam (MLR)
191 // FIXME: should there be a REPH for old-style Malayalam?
192 static const IndicClassTable::CharClass mlymCharClasses[] =
193 {
194 _xx, _xx, _mp, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _iv, _iv, // 0D00 - 0D0F
195 _iv, _xx, _iv, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, // 0D10 - 0D1F
196 _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _ct, _ct, _ct, _ct, _pb, // 0D20 - 0D2F
197 _pb, _cn, _bb, _ct, _ct, _pb, _ct, _ct, _ct, _ct, _xx, _xx, _xx, _xx, _r2, _dr, // 0D30 - 0D3F
198 _dr, _dr, _dr, _dr, _xx, _xx, _l1, _l1, _dl, _xx, _s1, _s2, _s3, _vr, _xx, _xx, // 0D40 - 0D4F
199 _xx, _xx, _xx, _xx, _xx, _xx, _xx, _m2, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0D50 - 0D5F
200 _iv, _iv, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx // 0D60 - 0D6F
201 };
202
203 static const IndicClassTable::CharClass sinhCharClasses[] =
204 {
205 _xx, _xx, _mp, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, // 0D80 - 0D8F
206 _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _xx, _ct, _ct, _ct, _ct, _ct, _ct, // 0D90 - 0D9F
207 _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, // 0DA0 - 0DAF
208 _ct, _ct, _xx, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _xx, _xx, // 0DB0 - 0DBF
209 _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _xx, _xx, _vr, _xx, _xx, _xx, _xx, _dr, // 0DC0 - 0DCF
210 _dr, _dr, _da, _da, _db, _xx, _db, _xx, _dr, _dl, _s1, _dl, _s2, _s3, _s4, _dr, // 0DD0 - 0DDF
211 _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0DE0 - 0DEF
212 _xx, _xx, _dr, _dr, _xx // 0DF0 - 0DF4
213 };
214
215 //
216 // Split matra tables
217 //
218 static const SplitMatra bengSplitTable[] = {{0x09C7, 0x09BE}, {0x09C7, 0x09D7}};
219
220 static const SplitMatra oryaSplitTable[] = {{0x0B47, 0x0B56}, {0x0B47, 0x0B3E}, {0x0B47, 0x0B57}};
221
222 static const SplitMatra tamlSplitTable[] = {{0x0BC6, 0x0BBE}, {0x0BC7, 0x0BBE}, {0x0BC6, 0x0BD7}};
223
224 static const SplitMatra teluSplitTable[] = {{0x0C46, 0x0C56}};
225
226 static const SplitMatra kndaSplitTable[] = {{0x0CBF, 0x0CD5}, {0x0CC6, 0x0CD5}, {0x0CC6, 0x0CD6}, {0x0CC6, 0x0CC2},
227 {0x0CC6, 0x0CC2, 0x0CD5}};
228
229 static const SplitMatra mlymSplitTable[] = {{0x0D46, 0x0D3E}, {0x0D47, 0x0D3E}, {0x0D46, 0x0D57}};
230
231
232 static const SplitMatra sinhSplitTable[] = {{0x0DD9, 0x0DCA}, {0x0DD9, 0x0DCF}, {0x0DD9, 0x0DCF,0x0DCA},
233 {0x0DD9, 0x0DDF}};
234 //
235 // Script Flags
236 //
237
238 // FIXME: post 'GSUB' reordering of MATRA_PRE's for Malayalam and Tamil
239 // FIXME: reformed Malayalam needs to reorder VATTU to before base glyph...
240 // FIXME: not sure passing ZWJ/ZWNJ is best way to render Malayalam Cillu...
241 // FIXME: eyelash RA only for Devanagari??
242 #define DEVA_SCRIPT_FLAGS (SF_EYELASH_RA | SF_NO_POST_BASE_LIMIT | SF_FILTER_ZERO_WIDTH)
243 #define BENG_SCRIPT_FLAGS (SF_REPH_AFTER_BELOW | SF_NO_POST_BASE_LIMIT | SF_FILTER_ZERO_WIDTH)
244 #define PUNJ_SCRIPT_FLAGS (SF_NO_POST_BASE_LIMIT | SF_FILTER_ZERO_WIDTH)
245 #define GUJR_SCRIPT_FLAGS (SF_NO_POST_BASE_LIMIT | SF_FILTER_ZERO_WIDTH)
246 #define ORYA_SCRIPT_FLAGS (SF_REPH_AFTER_BELOW | SF_NO_POST_BASE_LIMIT | SF_FILTER_ZERO_WIDTH)
247 #define TAML_SCRIPT_FLAGS (SF_MPRE_FIXUP | SF_NO_POST_BASE_LIMIT | SF_FILTER_ZERO_WIDTH)
248 #define TELU_SCRIPT_FLAGS (SF_MATRAS_AFTER_BASE | SF_FILTER_ZERO_WIDTH | 3)
249 #define KNDA_SCRIPT_FLAGS (SF_MATRAS_AFTER_BASE | SF_FILTER_ZERO_WIDTH | 3)
250 #define MLYM_SCRIPT_FLAGS (SF_MPRE_FIXUP | SF_NO_POST_BASE_LIMIT /*| SF_FILTER_ZERO_WIDTH*/)
251 #define SINH_SCRIPT_FLAGS (SF_MPRE_FIXUP | SF_NO_POST_BASE_LIMIT)
252
253 //
254 // Indic Class Tables
255 //
256 static const IndicClassTable devaClassTable = {0x0900, 0x0970, 2, DEVA_SCRIPT_FLAGS, devaCharClasses, NULL};
257
258 static const IndicClassTable bengClassTable = {0x0980, 0x09FA, 3, BENG_SCRIPT_FLAGS, bengCharClasses, bengSplitTable};
259
260 static const IndicClassTable punjClassTable = {0x0A00, 0x0A74, 2, PUNJ_SCRIPT_FLAGS, punjCharClasses, NULL};
261
262 static const IndicClassTable gujrClassTable = {0x0A80, 0x0AEF, 2, GUJR_SCRIPT_FLAGS, gujrCharClasses, NULL};
263
264 static const IndicClassTable oryaClassTable = {0x0B00, 0x0B71, 3, ORYA_SCRIPT_FLAGS, oryaCharClasses, oryaSplitTable};
265
266 static const IndicClassTable tamlClassTable = {0x0B80, 0x0BF2, 3, TAML_SCRIPT_FLAGS, tamlCharClasses, tamlSplitTable};
267
268 static const IndicClassTable teluClassTable = {0x0C00, 0x0C6F, 3, TELU_SCRIPT_FLAGS, teluCharClasses, teluSplitTable};
269
270 static const IndicClassTable kndaClassTable = {0x0C80, 0x0CEF, 4, KNDA_SCRIPT_FLAGS, kndaCharClasses, kndaSplitTable};
271
272 static const IndicClassTable mlymClassTable = {0x0D00, 0x0D6F, 3, MLYM_SCRIPT_FLAGS, mlymCharClasses, mlymSplitTable};
273
274 static const IndicClassTable sinhClassTable = {0x0D80, 0x0DF4, 4, SINH_SCRIPT_FLAGS, sinhCharClasses, sinhSplitTable};
275
276 //
277 // IndicClassTable addresses
278 //
279 static const IndicClassTable * const indicClassTables[scriptCodeCount] = {
280 NULL, /* 'zyyy' (COMMON) */
281 NULL, /* 'qaai' (INHERITED) */
282 NULL, /* 'arab' (ARABIC) */
283 NULL, /* 'armn' (ARMENIAN) */
284 &bengClassTable, /* 'beng' (BENGALI) */
285 NULL, /* 'bopo' (BOPOMOFO) */
286 NULL, /* 'cher' (CHEROKEE) */
287 NULL, /* 'copt' (COPTIC) */
288 NULL, /* 'cyrl' (CYRILLIC) */
289 NULL, /* 'dsrt' (DESERET) */
290 &devaClassTable, /* 'deva' (DEVANAGARI) */
291 NULL, /* 'ethi' (ETHIOPIC) */
292 NULL, /* 'geor' (GEORGIAN) */
293 NULL, /* 'goth' (GOTHIC) */
294 NULL, /* 'grek' (GREEK) */
295 &gujrClassTable, /* 'gujr' (GUJARATI) */
296 &punjClassTable, /* 'guru' (GURMUKHI) */
297 NULL, /* 'hani' (HAN) */
298 NULL, /* 'hang' (HANGUL) */
299 NULL, /* 'hebr' (HEBREW) */
300 NULL, /* 'hira' (HIRAGANA) */
301 &kndaClassTable, /* 'knda' (KANNADA) */
302 NULL, /* 'kata' (KATAKANA) */
303 NULL, /* 'khmr' (KHMER) */
304 NULL, /* 'laoo' (LAO) */
305 NULL, /* 'latn' (LATIN) */
306 &mlymClassTable, /* 'mlym' (MALAYALAM) */
307 NULL, /* 'mong' (MONGOLIAN) */
308 NULL, /* 'mymr' (MYANMAR) */
309 NULL, /* 'ogam' (OGHAM) */
310 NULL, /* 'ital' (OLD-ITALIC) */
311 &oryaClassTable, /* 'orya' (ORIYA) */
312 NULL, /* 'runr' (RUNIC) */
313 &sinhClassTable, /* 'sinh' (SINHALA) */
314 NULL, /* 'syrc' (SYRIAC) */
315 &tamlClassTable, /* 'taml' (TAMIL) */
316 &teluClassTable, /* 'telu' (TELUGU) */
317 NULL, /* 'thaa' (THAANA) */
318 NULL, /* 'thai' (THAI) */
319 NULL, /* 'tibt' (TIBETAN) */
320 NULL, /* 'cans' (CANADIAN-ABORIGINAL) */
321 NULL, /* 'yiii' (YI) */
322 NULL, /* 'tglg' (TAGALOG) */
323 NULL, /* 'hano' (HANUNOO) */
324 NULL, /* 'buhd' (BUHID) */
325 NULL, /* 'tagb' (TAGBANWA) */
326 NULL, /* 'brai' (BRAILLE) */
327 NULL, /* 'cprt' (CYPRIOT) */
328 NULL, /* 'limb' (LIMBU) */
329 NULL, /* 'linb' (LINEAR_B) */
330 NULL, /* 'osma' (OSMANYA) */
331 NULL, /* 'shaw' (SHAVIAN) */
332 NULL, /* 'tale' (TAI_LE) */
333 NULL, /* 'ugar' (UGARITIC) */
334 NULL, /* 'hrkt' (KATAKANA_OR_HIRAGANA) */
335 NULL, /* 'bugi' (BUGINESE) */
336 NULL, /* 'glag' (GLAGOLITIC) */
337 NULL, /* 'khar' (KHAROSHTHI) */
338 NULL, /* 'sylo' (SYLOTI_NAGRI) */
339 NULL, /* 'talu' (NEW_TAI_LUE) */
340 NULL, /* 'tfng' (TIFINAGH) */
341 NULL, /* 'xpeo' (OLD_PERSIAN) */
342 NULL, /* 'bali' (BALINESE) */
343 NULL, /* 'batk' (BATK) */
344 NULL, /* 'blis' (BLIS) */
345 NULL, /* 'brah' (BRAH) */
346 NULL, /* 'cham' (CHAM) */
347 NULL, /* 'cirt' (CIRT) */
348 NULL, /* 'cyrs' (CYRS) */
349 NULL, /* 'egyd' (EGYD) */
350 NULL, /* 'egyh' (EGYH) */
351 NULL, /* 'egyp' (EGYP) */
352 NULL, /* 'geok' (GEOK) */
353 NULL, /* 'hans' (HANS) */
354 NULL, /* 'hant' (HANT) */
355 NULL, /* 'hmng' (HMNG) */
356 NULL, /* 'hung' (HUNG) */
357 NULL, /* 'inds' (INDS) */
358 NULL, /* 'java' (JAVA) */
359 NULL, /* 'kali' (KALI) */
360 NULL, /* 'latf' (LATF) */
361 NULL, /* 'latg' (LATG) */
362 NULL, /* 'lepc' (LEPC) */
363 NULL, /* 'lina' (LINA) */
364 NULL, /* 'mand' (MAND) */
365 NULL, /* 'maya' (MAYA) */
366 NULL, /* 'mero' (MERO) */
367 NULL, /* 'nko ' (NKO) */
368 NULL, /* 'orkh' (ORKH) */
369 NULL, /* 'perm' (PERM) */
370 NULL, /* 'phag' (PHAGS_PA) */
371 NULL, /* 'phnx' (PHOENICIAN) */
372 NULL, /* 'plrd' (PLRD) */
373 NULL, /* 'roro' (RORO) */
374 NULL, /* 'sara' (SARA) */
375 NULL, /* 'syre' (SYRE) */
376 NULL, /* 'syrj' (SYRJ) */
377 NULL, /* 'syrn' (SYRN) */
378 NULL, /* 'teng' (TENG) */
379 NULL, /* 'vai ' (VAII) */
380 NULL, /* 'visp' (VISP) */
381 NULL, /* 'xsux' (CUNEIFORM) */
382 NULL, /* 'zxxx' (ZXXX) */
383 NULL, /* 'zzzz' (UNKNOWN) */
384 NULL, /* 'cari' (CARI) */
385 NULL, /* 'jpan' (JPAN) */
386 NULL, /* 'lana' (LANA) */
387 NULL, /* 'lyci' (LYCI) */
388 NULL, /* 'lydi' (LYDI) */
389 NULL, /* 'olck' (OLCK) */
390 NULL, /* 'rjng' (RJNG) */
391 NULL, /* 'saur' (SAUR) */
392 NULL, /* 'sgnw' (SGNW) */
393 NULL, /* 'sund' (SUND) */
394 NULL, /* 'moon' (MOON) */
395 NULL /* 'mtei' (MTEI) */
396 };
397
getCharClass(LEUnicode ch) const398 IndicClassTable::CharClass IndicClassTable::getCharClass(LEUnicode ch) const
399 {
400 if (ch == C_SIGN_ZWJ) {
401 return CF_CONSONANT | CC_ZERO_WIDTH_MARK;
402 }
403
404 if (ch == C_SIGN_ZWNJ) {
405 return CC_ZERO_WIDTH_MARK;
406 }
407
408 if (ch < firstChar || ch > lastChar) {
409 return CC_RESERVED;
410 }
411
412 return classTable[ch - firstChar];
413 }
414
getScriptClassTable(le_int32 scriptCode)415 const IndicClassTable *IndicClassTable::getScriptClassTable(le_int32 scriptCode)
416 {
417 if (scriptCode < 0 || scriptCode >= scriptCodeCount) {
418 return NULL;
419 }
420
421 return indicClassTables[scriptCode];
422 }
423
getWorstCaseExpansion(le_int32 scriptCode)424 le_int32 IndicReordering::getWorstCaseExpansion(le_int32 scriptCode)
425 {
426 const IndicClassTable *classTable = IndicClassTable::getScriptClassTable(scriptCode);
427
428 if (classTable == NULL) {
429 return 1;
430 }
431
432 return classTable->getWorstCaseExpansion();
433 }
434
getFilterZeroWidth(le_int32 scriptCode)435 le_bool IndicReordering::getFilterZeroWidth(le_int32 scriptCode)
436 {
437 const IndicClassTable *classTable = IndicClassTable::getScriptClassTable(scriptCode);
438
439 if (classTable == NULL) {
440 return TRUE;
441 }
442
443 return classTable->getFilterZeroWidth();
444 }
445
446 U_NAMESPACE_END
447