J. Duke | 319a3b9 | 2007-12-01 00:00:00 +0000 | [diff] [blame^] | 1 | /* |
| 2 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 3 | * |
| 4 | * This code is free software; you can redistribute it and/or modify it |
| 5 | * under the terms of the GNU General Public License version 2 only, as |
| 6 | * published by the Free Software Foundation. Sun designates this |
| 7 | * particular file as subject to the "Classpath" exception as provided |
| 8 | * by Sun in the LICENSE file that accompanied this code. |
| 9 | * |
| 10 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 13 | * version 2 for more details (a copy is included in the LICENSE file that |
| 14 | * accompanied this code). |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License version |
| 17 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 18 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 19 | * |
| 20 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
| 21 | * CA 95054 USA or visit www.sun.com if you need additional information or |
| 22 | * have any questions. |
| 23 | * |
| 24 | */ |
| 25 | |
| 26 | /* |
| 27 | * |
| 28 | * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved |
| 29 | * |
| 30 | */ |
| 31 | |
| 32 | #include "LETypes.h" |
| 33 | #include "LEScripts.h" |
| 34 | #include "OpenTypeTables.h" |
| 35 | #include "OpenTypeUtilities.h" |
| 36 | #include "IndicReordering.h" |
| 37 | |
| 38 | // Split matra table indices |
| 39 | #define _x1 (1 << CF_INDEX_SHIFT) |
| 40 | #define _x2 (2 << CF_INDEX_SHIFT) |
| 41 | #define _x3 (3 << CF_INDEX_SHIFT) |
| 42 | #define _x4 (4 << CF_INDEX_SHIFT) |
| 43 | #define _x5 (5 << CF_INDEX_SHIFT) |
| 44 | #define _x6 (6 << CF_INDEX_SHIFT) |
| 45 | #define _x7 (7 << CF_INDEX_SHIFT) |
| 46 | #define _x8 (8 << CF_INDEX_SHIFT) |
| 47 | #define _x9 (9 << CF_INDEX_SHIFT) |
| 48 | |
| 49 | // simple classes |
| 50 | #define _xx (CC_RESERVED) |
| 51 | #define _ma (CC_VOWEL_MODIFIER | CF_POS_ABOVE) |
| 52 | #define _mp (CC_VOWEL_MODIFIER | CF_POS_AFTER) |
| 53 | #define _sa (CC_STRESS_MARK | CF_POS_ABOVE) |
| 54 | #define _sb (CC_STRESS_MARK | CF_POS_BELOW) |
| 55 | #define _iv (CC_INDEPENDENT_VOWEL) |
| 56 | #define _i2 (CC_INDEPENDENT_VOWEL_2) |
| 57 | #define _i3 (CC_INDEPENDENT_VOWEL_3) |
| 58 | #define _ct (CC_CONSONANT | CF_CONSONANT) |
| 59 | #define _cn (CC_CONSONANT_WITH_NUKTA | CF_CONSONANT) |
| 60 | #define _nu (CC_NUKTA) |
| 61 | #define _dv (CC_DEPENDENT_VOWEL) |
| 62 | #define _dl (_dv | CF_POS_BEFORE) |
| 63 | #define _db (_dv | CF_POS_BELOW) |
| 64 | #define _da (_dv | CF_POS_ABOVE) |
| 65 | #define _dr (_dv | CF_POS_AFTER) |
| 66 | #define _lm (_dv | CF_LENGTH_MARK) |
| 67 | #define _l1 (CC_SPLIT_VOWEL_PIECE_1 | CF_POS_BEFORE) |
| 68 | #define _a1 (CC_SPLIT_VOWEL_PIECE_1 | CF_POS_ABOVE) |
| 69 | #define _b2 (CC_SPLIT_VOWEL_PIECE_2 | CF_POS_BELOW) |
| 70 | #define _r2 (CC_SPLIT_VOWEL_PIECE_2 | CF_POS_AFTER) |
| 71 | #define _m2 (CC_SPLIT_VOWEL_PIECE_2 | CF_LENGTH_MARK) |
| 72 | #define _m3 (CC_SPLIT_VOWEL_PIECE_3 | CF_LENGTH_MARK) |
| 73 | #define _vr (CC_VIRAMA) |
| 74 | |
| 75 | // split matras |
| 76 | #define _s1 (_dv | _x1) |
| 77 | #define _s2 (_dv | _x2) |
| 78 | #define _s3 (_dv | _x3) |
| 79 | #define _s4 (_dv | _x4) |
| 80 | #define _s5 (_dv | _x5) |
| 81 | #define _s6 (_dv | _x6) |
| 82 | #define _s7 (_dv | _x7) |
| 83 | #define _s8 (_dv | _x8) |
| 84 | #define _s9 (_dv | _x9) |
| 85 | |
| 86 | // consonants with special forms |
| 87 | // NOTE: this assumes that no consonants with nukta have |
| 88 | // special forms... (Bengali RA?) |
| 89 | #define _bb (_ct | CF_BELOW_BASE) |
| 90 | #define _pb (_ct | CF_POST_BASE) |
| 91 | #define _vt (_bb | CF_VATTU) |
| 92 | #define _rv (_vt | CF_REPH) |
| 93 | #define _rp (_pb | CF_REPH) |
| 94 | #define _rb (_bb | CF_REPH) |
| 95 | |
| 96 | // |
| 97 | // Character class tables |
| 98 | // |
| 99 | static const IndicClassTable::CharClass devaCharClasses[] = |
| 100 | { |
| 101 | _xx, _ma, _ma, _mp, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, // 0900 - 090F |
| 102 | _iv, _iv, _iv, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, // 0910 - 091F |
| 103 | _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _cn, _ct, _ct, _ct, _ct, _ct, _ct, // 0920 - 092F |
| 104 | _rv, _cn, _ct, _ct, _cn, _ct, _ct, _ct, _ct, _ct, _xx, _xx, _nu, _xx, _dr, _dl, // 0930 - 093F |
| 105 | _dr, _db, _db, _db, _db, _da, _da, _da, _da, _dr, _dr, _dr, _dr, _vr, _xx, _xx, // 0940 - 094F |
| 106 | _xx, _sa, _sb, _sa, _sa, _xx, _xx, _xx, _cn, _cn, _cn, _cn, _cn, _cn, _cn, _cn, // 0950 - 095F |
| 107 | _iv, _iv, _db, _db, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0960 - 096F |
| 108 | _xx // 0970 |
| 109 | }; |
| 110 | |
| 111 | static const IndicClassTable::CharClass bengCharClasses[] = |
| 112 | { |
| 113 | _xx, _ma, _mp, _mp, _xx, _i2, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _i2, // 0980 - 098F |
| 114 | _iv, _xx, _xx, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, // 0990 - 099F |
| 115 | _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _ct, _bb, _ct, _ct, _pb, // 09A0 - 09AF |
| 116 | _rv, _xx, _ct, _xx, _xx, _xx, _ct, _ct, _ct, _ct, _xx, _xx, _nu, _xx, _r2, _dl, // 09B0 - 09BF |
| 117 | _dr, _db, _db, _db, _db, _xx, _xx, _l1, _dl, _xx, _xx, _s1, _s2, _vr, _xx, _xx, // 09C0 - 09CF |
| 118 | _xx, _xx, _xx, _xx, _xx, _xx, _xx, _m2, _xx, _xx, _xx, _xx, _cn, _cn, _xx, _cn, // 09D0 - 09DF |
| 119 | _iv, _iv, _dv, _dv, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 09E0 - 09EF |
| 120 | _ct, _ct, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx // 09F0 - 09FA |
| 121 | }; |
| 122 | |
| 123 | static const IndicClassTable::CharClass punjCharClasses[] = |
| 124 | { |
| 125 | _xx, _ma, _ma, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _xx, _xx, _iv, // 0A00 - 0A0F |
| 126 | _iv, _xx, _xx, _i3, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, // 0A10 - 0A1F |
| 127 | _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _ct, _ct, _ct, _ct, _bb, // 0A20 - 0A2F |
| 128 | _vt, _xx, _ct, _cn, _xx, _bb, _cn, _xx, _ct, _bb, _xx, _xx, _nu, _xx, _dr, _dl, // 0A30 - 0A3F |
| 129 | _dr, _b2, _db, _xx, _xx, _xx, _xx, _da, _da, _xx, _xx, _a1, _da, _vr, _xx, _xx, // 0A40 - 0A4F |
| 130 | _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _cn, _cn, _cn, _ct, _xx, _cn, _xx, // 0A50 - 0A5F |
| 131 | _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0A60 - 0A6F |
| 132 | _ma, _ma, _xx, _xx, _xx // 0A70 - 0A74 |
| 133 | }; |
| 134 | |
| 135 | static const IndicClassTable::CharClass gujrCharClasses[] = |
| 136 | { |
| 137 | _xx, _ma, _ma, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _iv, _xx, _iv, // 0A80 - 0A8F |
| 138 | _iv, _iv, _xx, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, // 0A90 - 0A9F |
| 139 | _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _ct, _ct, _ct, _ct, _ct, // 0AA0 - 0AAF |
| 140 | _rv, _xx, _ct, _ct, _xx, _ct, _ct, _ct, _ct, _ct, _xx, _xx, _nu, _xx, _dr, _dl, // 0AB0 - 0ABF |
| 141 | _dr, _db, _db, _db, _db, _da, _xx, _da, _da, _dr, _xx, _dr, _dr, _vr, _xx, _xx, // 0AC0 - 0ACF |
| 142 | _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0AD0 - 0ADF |
| 143 | _iv, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx // 0AE0 - 0AEF |
| 144 | }; |
| 145 | |
| 146 | static const IndicClassTable::CharClass oryaCharClasses[] = |
| 147 | { |
| 148 | _xx, _ma, _mp, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _iv, // 0B00 - 0B0F |
| 149 | _iv, _xx, _xx, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, // 0B10 - 0B1F |
| 150 | _ct, _ct, _ct, _ct, _bb, _ct, _ct, _ct, _bb, _xx, _ct, _ct, _bb, _bb, _bb, _pb, // 0B20 - 0B2F |
| 151 | _rb, _xx, _bb, _bb, _xx, _ct, _ct, _ct, _ct, _ct, _xx, _xx, _nu, _xx, _r2, _da, // 0B30 - 0B3F |
| 152 | _dr, _db, _db, _db, _xx, _xx, _xx, _l1, _s1, _xx, _xx, _s2, _s3, _vr, _xx, _xx, // 0B40 - 0B4F |
| 153 | _xx, _xx, _xx, _xx, _xx, _xx, _m2, _m2, _xx, _xx, _xx, _xx, _cn, _cn, _xx, _cn, // 0B50 - 0B5F |
| 154 | _iv, _iv, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0B60 - 0B6F |
| 155 | _xx, _ct // 0B70 - 0B71 |
| 156 | }; |
| 157 | |
| 158 | static const IndicClassTable::CharClass tamlCharClasses[] = |
| 159 | { |
| 160 | _xx, _xx, _ma, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _xx, _iv, _iv, // 0B80 - 0B8F |
| 161 | _iv, _xx, _iv, _iv, _iv, _ct, _xx, _xx, _xx, _ct, _ct, _xx, _ct, _xx, _ct, _ct, // 0B90 - 0B9F |
| 162 | _xx, _xx, _xx, _ct, _ct, _xx, _xx, _xx, _ct, _ct, _ct, _xx, _xx, _xx, _ct, _ct, // 0BA0 - 0BAF |
| 163 | _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _ct, _ct, _xx, _xx, _xx, _xx, _r2, _dr, // 0BB0 - 0BBF |
| 164 | _da, _dr, _dr, _xx, _xx, _xx, _l1, _l1, _dl, _xx, _s1, _s2, _s3, _vr, _xx, _xx, // 0BC0 - 0BCF |
| 165 | _xx, _xx, _xx, _xx, _xx, _xx, _xx, _m2, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0BD0 - 0BDF |
| 166 | _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0BE0 - 0BEF |
| 167 | _xx, _xx, _xx // 0BF0 - 0BF2 |
| 168 | }; |
| 169 | |
| 170 | // FIXME: Should some of the bb's be pb's? (KA, NA, MA, YA, VA, etc. (approx 13)) |
| 171 | static const IndicClassTable::CharClass teluCharClasses[] = |
| 172 | { |
| 173 | _xx, _mp, _mp, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _iv, _iv, // 0C00 - 0C0F |
| 174 | _iv, _xx, _iv, _iv, _iv, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, // 0C10 - 0C1F |
| 175 | _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _xx, _bb, _bb, _bb, _bb, _bb, _bb, // 0C20 - 0C2F |
| 176 | _bb, _ct, _bb, _bb, _xx, _bb, _bb, _bb, _bb, _bb, _xx, _xx, _xx, _xx, _da, _da, // 0C30 - 0C3F |
| 177 | _da, _dr, _dr, _dr, _dr, _xx, _a1, _da, _s1, _xx, _da, _da, _da, _vr, _xx, _xx, // 0C40 - 0C4F |
| 178 | _xx, _xx, _xx, _xx, _xx, _da, _m2, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0C50 - 0C5F |
| 179 | _iv, _iv, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx // 0C60 - 0C6F |
| 180 | }; |
| 181 | |
| 182 | // U+CC3 and U+CC4 are _lm here not _dr since the Kannada rendering |
| 183 | // rules want them below and to the right of the entire cluster |
| 184 | // |
| 185 | // There's some information about this in: |
| 186 | // |
| 187 | // http://brahmi.sourceforge.net/docs/KannadaComputing.html |
| 188 | static const IndicClassTable::CharClass kndaCharClasses[] = |
| 189 | { |
| 190 | _xx, _xx, _mp, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _iv, // 0C80 - 0C8F |
| 191 | _iv, _xx, _iv, _iv, _iv, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, // 0C90 - 0C9F |
| 192 | _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _xx, _bb, _bb, _bb, _bb, _bb, _bb, // 0CA0 - 0CAF |
| 193 | _rb, _ct, _bb, _bb, _xx, _bb, _bb, _bb, _bb, _bb, _xx, _xx, _xx, _xx, _dr, _da, // 0CB0 - 0CBF |
| 194 | _s1, _dr, _r2, _lm, _lm, _xx, _a1, _s2, _s3, _xx, _s4, _s5, _da, _vr, _xx, _xx, // 0CC0 - 0CCF |
| 195 | _xx, _xx, _xx, _xx, _xx, _m3, _m2, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _ct, _xx, // 0CD0 - 0CDF |
| 196 | _iv, _iv, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx // 0CE0 - 0CEF |
| 197 | }; |
| 198 | |
| 199 | // FIXME: this is correct for old-style Malayalam (MAL) but not for reformed Malayalam (MLR) |
| 200 | // FIXME: should there be a REPH for old-style Malayalam? |
| 201 | static const IndicClassTable::CharClass mlymCharClasses[] = |
| 202 | { |
| 203 | _xx, _xx, _mp, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _iv, _iv, // 0D00 - 0D0F |
| 204 | _iv, _xx, _iv, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _bb, // 0D10 - 0D1F |
| 205 | _ct, _ct, _ct, _bb, _ct, _bb, _bb, _ct, _ct, _xx, _ct, _ct, _ct, _ct, _ct, _pb, // 0D20 - 0D2F |
| 206 | _pb, _cn, _bb, _ct, _ct, _pb, _ct, _ct, _ct, _ct, _xx, _xx, _xx, _xx, _r2, _dr, // 0D30 - 0D3F |
| 207 | _dr, _dr, _dr, _dr, _xx, _xx, _l1, _l1, _dl, _xx, _s1, _s2, _s3, _vr, _xx, _xx, // 0D40 - 0D4F |
| 208 | _xx, _xx, _xx, _xx, _xx, _xx, _xx, _m2, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0D50 - 0D5F |
| 209 | _iv, _iv, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx // 0D60 - 0D6F |
| 210 | }; |
| 211 | |
| 212 | static const IndicClassTable::CharClass sinhCharClasses[] = |
| 213 | { |
| 214 | _xx, _xx, _mp, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, // 0D80 - 0D8F |
| 215 | _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _xx, _ct, _ct, _ct, _ct, _ct, _ct, // 0D90 - 0D9F |
| 216 | _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, // 0DA0 - 0DAF |
| 217 | _ct, _ct, _xx, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _xx, _xx, // 0DB0 - 0DBF |
| 218 | _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _xx, _xx, _vr, _xx, _xx, _xx, _xx, _dr, // 0DC0 - 0DCF |
| 219 | _dr, _dr, _da, _da, _db, _xx, _db, _xx, _dr, _dl, _s1, _dl, _s2, _s3, _s4, _dr, // 0DD0 - 0DDF |
| 220 | _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0DE0 - 0DEF |
| 221 | _xx, _xx, _dr, _dr, _xx // 0DF0 - 0DF4 |
| 222 | }; |
| 223 | |
| 224 | // |
| 225 | // Split matra tables |
| 226 | // |
| 227 | static const SplitMatra bengSplitTable[] = {{0x09C7, 0x09BE}, {0x09C7, 0x09D7}}; |
| 228 | |
| 229 | static const SplitMatra oryaSplitTable[] = {{0x0B47, 0x0B56}, {0x0B47, 0x0B3E}, {0x0B47, 0x0B57}}; |
| 230 | |
| 231 | static const SplitMatra tamlSplitTable[] = {{0x0BC6, 0x0BBE}, {0x0BC7, 0x0BBE}, {0x0BC6, 0x0BD7}}; |
| 232 | |
| 233 | static const SplitMatra teluSplitTable[] = {{0x0C46, 0x0C56}}; |
| 234 | |
| 235 | static const SplitMatra kndaSplitTable[] = {{0x0CBF, 0x0CD5}, {0x0CC6, 0x0CD5}, {0x0CC6, 0x0CD6}, {0x0CC6, 0x0CC2}, |
| 236 | {0x0CC6, 0x0CC2, 0x0CD5}}; |
| 237 | |
| 238 | static const SplitMatra mlymSplitTable[] = {{0x0D46, 0x0D3E}, {0x0D47, 0x0D3E}, {0x0D46, 0x0D57}}; |
| 239 | |
| 240 | |
| 241 | static const SplitMatra sinhSplitTable[] = {{0x0DD9, 0x0DCA}, {0x0DD9, 0x0DCF}, {0x0DD9, 0x0DCF,0x0DCA}, |
| 242 | {0x0DD9, 0x0DDF}}; |
| 243 | // |
| 244 | // Script Flags |
| 245 | // |
| 246 | |
| 247 | // FIXME: post 'GSUB' reordering of MATRA_PRE's for Malayalam and Tamil |
| 248 | // FIXME: reformed Malayalam needs to reorder VATTU to before base glyph... |
| 249 | // FIXME: eyelash RA only for Devanagari?? |
| 250 | #define DEVA_SCRIPT_FLAGS (SF_EYELASH_RA | SF_NO_POST_BASE_LIMIT) |
| 251 | #define BENG_SCRIPT_FLAGS (SF_REPH_AFTER_BELOW | SF_NO_POST_BASE_LIMIT) |
| 252 | #define PUNJ_SCRIPT_FLAGS (SF_NO_POST_BASE_LIMIT) |
| 253 | #define GUJR_SCRIPT_FLAGS (SF_NO_POST_BASE_LIMIT) |
| 254 | #define ORYA_SCRIPT_FLAGS (SF_REPH_AFTER_BELOW | SF_NO_POST_BASE_LIMIT) |
| 255 | #define TAML_SCRIPT_FLAGS (SF_MPRE_FIXUP | SF_NO_POST_BASE_LIMIT) |
| 256 | #define TELU_SCRIPT_FLAGS (SF_MATRAS_AFTER_BASE | 3) |
| 257 | #define KNDA_SCRIPT_FLAGS (SF_MATRAS_AFTER_BASE | 3) |
| 258 | #define MLYM_SCRIPT_FLAGS (SF_MPRE_FIXUP | SF_NO_POST_BASE_LIMIT) |
| 259 | #define SINH_SCRIPT_FLAGS (SF_MPRE_FIXUP | SF_NO_POST_BASE_LIMIT) |
| 260 | |
| 261 | // |
| 262 | // Indic Class Tables |
| 263 | // |
| 264 | static const IndicClassTable devaClassTable = {0x0900, 0x0970, 2, DEVA_SCRIPT_FLAGS, devaCharClasses, NULL}; |
| 265 | |
| 266 | static const IndicClassTable bengClassTable = {0x0980, 0x09FA, 3, BENG_SCRIPT_FLAGS, bengCharClasses, bengSplitTable}; |
| 267 | |
| 268 | static const IndicClassTable punjClassTable = {0x0A00, 0x0A74, 2, PUNJ_SCRIPT_FLAGS, punjCharClasses, NULL}; |
| 269 | |
| 270 | static const IndicClassTable gujrClassTable = {0x0A80, 0x0AEF, 2, GUJR_SCRIPT_FLAGS, gujrCharClasses, NULL}; |
| 271 | |
| 272 | static const IndicClassTable oryaClassTable = {0x0B00, 0x0B71, 3, ORYA_SCRIPT_FLAGS, oryaCharClasses, oryaSplitTable}; |
| 273 | |
| 274 | static const IndicClassTable tamlClassTable = {0x0B80, 0x0BF2, 3, TAML_SCRIPT_FLAGS, tamlCharClasses, tamlSplitTable}; |
| 275 | |
| 276 | static const IndicClassTable teluClassTable = {0x0C00, 0x0C6F, 3, TELU_SCRIPT_FLAGS, teluCharClasses, teluSplitTable}; |
| 277 | |
| 278 | static const IndicClassTable kndaClassTable = {0x0C80, 0x0CEF, 4, KNDA_SCRIPT_FLAGS, kndaCharClasses, kndaSplitTable}; |
| 279 | |
| 280 | static const IndicClassTable mlymClassTable = {0x0D00, 0x0D6F, 3, MLYM_SCRIPT_FLAGS, mlymCharClasses, mlymSplitTable}; |
| 281 | |
| 282 | static const IndicClassTable sinhClassTable = {0x0D80, 0x0DF4, 3, SINH_SCRIPT_FLAGS, sinhCharClasses, sinhSplitTable}; |
| 283 | |
| 284 | // |
| 285 | // IndicClassTable addresses |
| 286 | // |
| 287 | static const IndicClassTable * const indicClassTables[] = { |
| 288 | NULL, /* 'zyyy' (COMMON) */ |
| 289 | NULL, /* 'qaai' (INHERITED) */ |
| 290 | NULL, /* 'arab' (ARABIC) */ |
| 291 | NULL, /* 'armn' (ARMENIAN) */ |
| 292 | &bengClassTable, /* 'beng' (BENGALI) */ |
| 293 | NULL, /* 'bopo' (BOPOMOFO) */ |
| 294 | NULL, /* 'cher' (CHEROKEE) */ |
| 295 | NULL, /* 'copt' (COPTIC) */ |
| 296 | NULL, /* 'cyrl' (CYRILLIC) */ |
| 297 | NULL, /* 'dsrt' (DESERET) */ |
| 298 | &devaClassTable, /* 'deva' (DEVANAGARI) */ |
| 299 | NULL, /* 'ethi' (ETHIOPIC) */ |
| 300 | NULL, /* 'geor' (GEORGIAN) */ |
| 301 | NULL, /* 'goth' (GOTHIC) */ |
| 302 | NULL, /* 'grek' (GREEK) */ |
| 303 | &gujrClassTable, /* 'gujr' (GUJARATI) */ |
| 304 | &punjClassTable, /* 'guru' (GURMUKHI) */ |
| 305 | NULL, /* 'hani' (HAN) */ |
| 306 | NULL, /* 'hang' (HANGUL) */ |
| 307 | NULL, /* 'hebr' (HEBREW) */ |
| 308 | NULL, /* 'hira' (HIRAGANA) */ |
| 309 | &kndaClassTable, /* 'knda' (KANNADA) */ |
| 310 | NULL, /* 'kata' (KATAKANA) */ |
| 311 | NULL, /* 'khmr' (KHMER) */ |
| 312 | NULL, /* 'laoo' (LAO) */ |
| 313 | NULL, /* 'latn' (LATIN) */ |
| 314 | &mlymClassTable, /* 'mlym' (MALAYALAM) */ |
| 315 | NULL, /* 'mong' (MONGOLIAN) */ |
| 316 | NULL, /* 'mymr' (MYANMAR) */ |
| 317 | NULL, /* 'ogam' (OGHAM) */ |
| 318 | NULL, /* 'ital' (OLD-ITALIC) */ |
| 319 | &oryaClassTable, /* 'orya' (ORIYA) */ |
| 320 | NULL, /* 'runr' (RUNIC) */ |
| 321 | &sinhClassTable, /* 'sinh' (SINHALA) */ |
| 322 | NULL, /* 'syrc' (SYRIAC) */ |
| 323 | &tamlClassTable, /* 'taml' (TAMIL) */ |
| 324 | &teluClassTable, /* 'telu' (TELUGU) */ |
| 325 | NULL, /* 'thaa' (THAANA) */ |
| 326 | NULL, /* 'thai' (THAI) */ |
| 327 | NULL, /* 'tibt' (TIBETAN) */ |
| 328 | NULL, /* 'cans' (CANADIAN-ABORIGINAL) */ |
| 329 | NULL, /* 'yiii' (YI) */ |
| 330 | NULL, /* 'tglg' (TAGALOG) */ |
| 331 | NULL, /* 'hano' (HANUNOO) */ |
| 332 | NULL, /* 'buhd' (BUHID) */ |
| 333 | NULL, /* 'tagb' (TAGBANWA) */ |
| 334 | NULL, /* 'brai' (BRAILLE) */ |
| 335 | NULL, /* 'cprt' (CYPRIOT) */ |
| 336 | NULL, /* 'limb' (LIMBU) */ |
| 337 | NULL, /* 'linb' (LINEAR_B) */ |
| 338 | NULL, /* 'osma' (OSMANYA) */ |
| 339 | NULL, /* 'shaw' (SHAVIAN) */ |
| 340 | NULL, /* 'tale' (TAI_LE) */ |
| 341 | NULL, /* 'ugar' (UGARITIC) */ |
| 342 | NULL, /* 'hrkt' (KATAKANA_OR_HIRAGANA) */ |
| 343 | NULL, /* 'bugi' (BUGINESE) */ |
| 344 | NULL, /* 'glag' (GLAGOLITIC) */ |
| 345 | NULL, /* 'khar' (KHAROSHTHI) */ |
| 346 | NULL, /* 'sylo' (SYLOTI_NAGRI) */ |
| 347 | NULL, /* 'talu' (NEW_TAI_LUE) */ |
| 348 | NULL, /* 'tfng' (TIFINAGH) */ |
| 349 | NULL /* 'xpeo' (OLD_PERSIAN) */ |
| 350 | }; |
| 351 | |
| 352 | IndicClassTable::CharClass IndicClassTable::getCharClass(LEUnicode ch) const |
| 353 | { |
| 354 | if (ch == C_SIGN_ZWJ) { |
| 355 | return CF_CONSONANT | CC_ZERO_WIDTH_MARK; |
| 356 | } |
| 357 | |
| 358 | if (ch == C_SIGN_ZWNJ) { |
| 359 | return CC_ZERO_WIDTH_MARK; |
| 360 | } |
| 361 | |
| 362 | if (ch < firstChar || ch > lastChar) { |
| 363 | return CC_RESERVED; |
| 364 | } |
| 365 | |
| 366 | return classTable[ch - firstChar]; |
| 367 | } |
| 368 | |
| 369 | const IndicClassTable *IndicClassTable::getScriptClassTable(le_int32 scriptCode) |
| 370 | { |
| 371 | if (scriptCode < 0 || scriptCode >= scriptCodeCount) { |
| 372 | return NULL; |
| 373 | } |
| 374 | |
| 375 | return indicClassTables[scriptCode]; |
| 376 | } |
| 377 | |
| 378 | le_int32 IndicReordering::getWorstCaseExpansion(le_int32 scriptCode) |
| 379 | { |
| 380 | const IndicClassTable *classTable = IndicClassTable::getScriptClassTable(scriptCode); |
| 381 | |
| 382 | if (classTable == NULL) { |
| 383 | return 1; |
| 384 | } |
| 385 | |
| 386 | return classTable->getWorstCaseExpansion(); |
| 387 | } |