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