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