os/textandloc/fontservices/textshaperplugin/IcuSource/layout/IndicClassTables.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
/*
sl@0
     2
 *
sl@0
     3
 * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
sl@0
     4
 *
sl@0
     5
 */
sl@0
     6
sl@0
     7
#include "LETypes.h"
sl@0
     8
#include "LEScripts.h"
sl@0
     9
#include "OpenTypeTables.h"
sl@0
    10
#include "OpenTypeUtilities.h"
sl@0
    11
#include "IndicReordering.h"
sl@0
    12
sl@0
    13
U_NAMESPACE_BEGIN
sl@0
    14
sl@0
    15
#define ARRAY_SIZE(array) (sizeof array  / sizeof array[0])
sl@0
    16
sl@0
    17
// Split matra table indices
sl@0
    18
#define _x1  (1 << CF_INDEX_SHIFT)
sl@0
    19
#define _x2  (2 << CF_INDEX_SHIFT)
sl@0
    20
#define _x3  (3 << CF_INDEX_SHIFT)
sl@0
    21
#define _x4  (4 << CF_INDEX_SHIFT)
sl@0
    22
#define _x5  (5 << CF_INDEX_SHIFT)
sl@0
    23
#define _x6  (6 << CF_INDEX_SHIFT)
sl@0
    24
#define _x7  (7 << CF_INDEX_SHIFT)
sl@0
    25
#define _x8  (8 << CF_INDEX_SHIFT)
sl@0
    26
#define _x9  (9 << CF_INDEX_SHIFT)
sl@0
    27
sl@0
    28
// simple classes
sl@0
    29
#define _xx  (CC_RESERVED)
sl@0
    30
#define _ma  (CC_VOWEL_MODIFIER | CF_POS_ABOVE)
sl@0
    31
#define _mp  (CC_VOWEL_MODIFIER | CF_POS_AFTER)
sl@0
    32
#define _sa  (CC_STRESS_MARK | CF_POS_ABOVE)
sl@0
    33
#define _sb  (CC_STRESS_MARK | CF_POS_BELOW)
sl@0
    34
#define _iv  (CC_INDEPENDENT_VOWEL)
sl@0
    35
// Added by Nokia -- Devanagai independent vowel A -> special case
sl@0
    36
#define _ia	 (CC_INDEPENDENT_VOWEL_A)
sl@0
    37
sl@0
    38
#define _i2  (CC_INDEPENDENT_VOWEL_2)
sl@0
    39
#define _ct  (CC_CONSONANT | CF_CONSONANT)
sl@0
    40
#define _cn  (CC_CONSONANT_WITH_NUKTA | CF_CONSONANT)
sl@0
    41
// Added by Nokia -- Special case Kannada and Bengali Ra to satisfy usecase (Initial)Ra + ZWJ + Virama + Consonant
sl@0
    42
#define _cr  (CC_CONSONANT_KANNADA_BENGALI_RA | CF_CONSONANT)
sl@0
    43
sl@0
    44
#define _nu  (CC_NUKTA)
sl@0
    45
#define _dv  (CC_DEPENDENT_VOWEL)
sl@0
    46
// Added by Nokia -- Devanagari vowel CANDRA E -> special case with independent vowel A
sl@0
    47
#define _de	 (CC_DEPENDENT_VOWEL_CANDRA_E | CF_POS_ABOVE)
sl@0
    48
sl@0
    49
// Added by Nokia -- Gurmukhi bearer ARA
sl@0
    50
#define _ba  (CC_GUR_BEARER_A)
sl@0
    51
// Added by Nokia -- Gurmukhi bearer IRI
sl@0
    52
#define _bi  (CC_GUR_BEARER_I)
sl@0
    53
// Added by Nokia -- Gurmukhi bearer URA
sl@0
    54
#define _bu  (CC_GUR_BEARER_U)
sl@0
    55
sl@0
    56
// Added by Nokia -- Gurmukhi dependent vowel which combined with bearer ARA to form an independent vowel
sl@0
    57
#define _ga  (CC_GUR_DEPENDENT_VOWEL_A)
sl@0
    58
// Added by Nokia -- Gurmukhi dependent vowel which combined with bearer IRI to form an independent vowel
sl@0
    59
#define _gi  (CC_GUR_DEPENDENT_VOWEL_I)
sl@0
    60
// Added by Nokia -- Gurmukhi dependent vowel which combined with bearer URA to form an independent vowel
sl@0
    61
#define _gu  (CC_GUR_DEPENDENT_VOWEL_U)
sl@0
    62
sl@0
    63
#define _gar (_ga | CF_POS_AFTER)
sl@0
    64
#define _gaa (_ga | CF_POS_ABOVE)
sl@0
    65
#define _gil (_gi | CF_POS_BEFORE)
sl@0
    66
#define _gir (_gi | CF_POS_AFTER)
sl@0
    67
#define _gia (_gi | CF_POS_ABOVE)
sl@0
    68
#define _gub (_gu | CF_POS_BELOW)
sl@0
    69
#define _gua (_gu | CF_POS_ABOVE)
sl@0
    70
sl@0
    71
#define _dl  (_dv | CF_POS_BEFORE)
sl@0
    72
#define _db  (_dv | CF_POS_BELOW)
sl@0
    73
#define _da  (_dv | CF_POS_ABOVE)
sl@0
    74
#define _dr  (_dv | CF_POS_AFTER)
sl@0
    75
#define _lm  (_dv | CF_LENGTH_MARK)
sl@0
    76
#define _l1  (CC_SPLIT_VOWEL_PIECE_1 | CF_POS_BEFORE)
sl@0
    77
#define _a1  (CC_SPLIT_VOWEL_PIECE_1 | CF_POS_ABOVE)
sl@0
    78
#define _r2  (CC_SPLIT_VOWEL_PIECE_2 | CF_POS_AFTER)
sl@0
    79
#define _m2  (CC_SPLIT_VOWEL_PIECE_2 | CF_LENGTH_MARK)
sl@0
    80
#define _m3  (CC_SPLIT_VOWEL_PIECE_3 | CF_LENGTH_MARK)
sl@0
    81
#define _vr  (CC_VIRAMA)
sl@0
    82
sl@0
    83
// split matras
sl@0
    84
#define _s1  (_dv | _x1)
sl@0
    85
#define _s2  (_dv | _x2)
sl@0
    86
#define _s3  (_dv | _x3)
sl@0
    87
#define _s4  (_dv | _x4)
sl@0
    88
#define _s5  (_dv | _x5)
sl@0
    89
#define _s6  (_dv | _x6)
sl@0
    90
#define _s7  (_dv | _x7)
sl@0
    91
#define _s8  (_dv | _x8)
sl@0
    92
#define _s9  (_dv | _x9)
sl@0
    93
sl@0
    94
// consonants with special forms
sl@0
    95
// NOTE: this assumes that no consonants with nukta have
sl@0
    96
// special forms... (Bengali RA?)
sl@0
    97
#define _bb  (_ct | CF_BELOW_BASE)
sl@0
    98
#define _pb  (_ct | CF_POST_BASE)
sl@0
    99
#define _vt  (_bb | CF_VATTU)
sl@0
   100
#define _rv  (_vt | CF_REPH)
sl@0
   101
#define _rp  (_pb | CF_REPH)
sl@0
   102
#define _rb  (_bb | CF_REPH)
sl@0
   103
sl@0
   104
// Added by Nokia -- for Kannada Ra & Bengali Ra
sl@0
   105
#define _b2  (_cr | CF_BELOW_BASE)
sl@0
   106
#define _kr  (_b2 | CF_REPH)
sl@0
   107
sl@0
   108
// Added by Nokia -- for Bengali Ya
sl@0
   109
#define _by  (_pb | CF_CONSONANT_BENGALI_YA)
sl@0
   110
sl@0
   111
// Added by Nokia -- for Tamil independent vowel O
sl@0
   112
#define _to  (CC_INDEPENDENT_VOWEL_TAMIL_O | CF_POS_AFTER)
sl@0
   113
sl@0
   114
// Added by Nokia -- for Malayalam CHILLU
sl@0
   115
#define _pbc  (_pb | CF_CONSONANT_MLYL_CHILLU)
sl@0
   116
#define _bbc  (_bb | CF_CONSONANT_MLYL_CHILLU)
sl@0
   117
#define _ctc  (_ct | CF_CONSONANT_MLYL_CHILLU)
sl@0
   118
sl@0
   119
//
sl@0
   120
// Character class tables
sl@0
   121
//
sl@0
   122
static const IndicClassTable::CharClass devaCharClasses[] =
sl@0
   123
{
sl@0
   124
    _xx, _ma, _ma, _mp, _iv, _ia, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, // 0900 - 090F
sl@0
   125
    _iv, _iv, _iv, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, // 0910 - 091F
sl@0
   126
    _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _cn, _ct, _ct, _ct, _ct, _ct, _ct, // 0920 - 092F
sl@0
   127
    _rv, _cn, _ct, _ct, _cn, _ct, _ct, _ct, _ct, _ct, _xx, _xx, _nu, _xx, _dr, _dl, // 0930 - 093F
sl@0
   128
    _dr, _db, _db, _db, _db, _de, _da, _da, _da, _dr, _dr, _dr, _dr, _vr, _xx, _xx, // 0940 - 094F
sl@0
   129
    _xx, _sa, _sb, _sa, _sa, _xx, _xx, _xx, _cn, _cn, _cn, _cn, _cn, _cn, _cn, _cn, // 0950 - 095F
sl@0
   130
    _iv, _iv, _db, _db, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0960 - 096F
sl@0
   131
    _xx                                                                             // 0970
sl@0
   132
};
sl@0
   133
sl@0
   134
// Nokia: Changed 09AF character from _pb to _by which represents a Bengali Ya which may or may not take
sl@0
   135
// post base form, depending on its position within a consonant cluster.
sl@0
   136
// Also changed 09B0 from _rb to special case _kr to satiisfy the usecase Ra + ZWJ + Virama + Consonant.
sl@0
   137
// Changed 09E2 and 09E3 to _db here, not _dv since the Bengali rendering rules want them below
sl@0
   138
// the base consonant.
sl@0
   139
static const IndicClassTable::CharClass bengCharClasses[] =
sl@0
   140
{
sl@0
   141
    _xx, _ma, _mp, _mp, _xx, _i2, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _i2, // 0980 - 098F
sl@0
   142
    _iv, _xx, _xx, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, // 0990 - 099F
sl@0
   143
    _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _ct, _bb, _ct, _ct, _by, // 09A0 - 09AF
sl@0
   144
    _kr, _xx, _ct, _xx, _xx, _xx, _ct, _ct, _ct, _ct, _xx, _xx, _nu, _xx, _r2, _dl, // 09B0 - 09BF
sl@0
   145
    _dr, _db, _db, _db, _db, _xx, _xx, _l1, _dl, _xx, _xx, _s1, _s2, _vr, _xx, _xx, // 09C0 - 09CF
sl@0
   146
    _xx, _xx, _xx, _xx, _xx, _xx, _xx, _m2, _xx, _xx, _xx, _xx, _cn, _cn, _xx, _cn, // 09D0 - 09DF
sl@0
   147
    _iv, _iv, _db, _db, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 09E0 - 09EF
sl@0
   148
    _ct, _ct, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx                           // 09F0 - 09FA
sl@0
   149
};
sl@0
   150
sl@0
   151
// Nokia: Changed 0A05 from _iv to _ba and 0A72&0A73 from _ct to _bi&_bu, changed 0A3E,0A48&0A4C
sl@0
   152
// from _d* to _ga*, 0A3F,0A40&0A47 from _d* to _gi*, 0A41,0A42&0A4B from _d* to _gu* to support 
sl@0
   153
// decompositions of the independent vowels into a sequence of a vowel bearer and a depending vowel sign.
sl@0
   154
// Also changed 0A2F from _bb to _pb since YA is expected to post-base when combined in constant cluster. 
sl@0
   155
static const IndicClassTable::CharClass punjCharClasses[] =
sl@0
   156
{
sl@0
   157
    _xx, _ma, _ma, _mp, _xx, _ba, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _xx, _xx, _iv, // 0A00 - 0A0F
sl@0
   158
    _iv, _xx, _xx, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, // 0A10 - 0A1F
sl@0
   159
    _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _ct, _ct, _ct, _ct, _pb, // 0A20 - 0A2F
sl@0
   160
    _vt, _xx, _ct, _cn, _xx, _bb, _cn, _xx, _ct, _bb, _xx, _xx, _nu, _xx, _gar, _gil, // 0A30 - 0A3F
sl@0
   161
    _gir, _gub, _gub, _xx, _xx, _xx, _xx, _gia, _gaa, _xx, _xx, _gua, _gaa, _vr, _xx, _xx, // 0A40 - 0A4F
sl@0
   162
    _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _cn, _cn, _cn, _ct, _xx, _cn, _xx, // 0A50 - 0A5F
sl@0
   163
    _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0A60 - 0A6F
sl@0
   164
    _ma, _ma, _bi, _bu, _xx                                                         // 0A70 - 0A74
sl@0
   165
};
sl@0
   166
sl@0
   167
static const IndicClassTable::CharClass gujrCharClasses[] =
sl@0
   168
{
sl@0
   169
    _xx, _ma, _ma, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _iv, _xx, _iv, // 0A80 - 0A8F
sl@0
   170
    _iv, _iv, _xx, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, // 0A90 - 0A9F
sl@0
   171
    _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _ct, _ct, _ct, _ct, _ct, // 0AA0 - 0AAF
sl@0
   172
    _rv, _xx, _ct, _ct, _xx, _ct, _ct, _ct, _ct, _ct, _xx, _xx, _nu, _xx, _dr, _dl, // 0AB0 - 0ABF
sl@0
   173
    _dr, _db, _db, _db, _db, _da, _xx, _da, _da, _dr, _xx, _dr, _dr, _vr, _xx, _xx, // 0AC0 - 0ACF
sl@0
   174
    _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0AD0 - 0ADF
sl@0
   175
    _iv, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx  // 0AE0 - 0AEF
sl@0
   176
};
sl@0
   177
sl@0
   178
static const IndicClassTable::CharClass oryaCharClasses[] =
sl@0
   179
{
sl@0
   180
    _xx, _ma, _mp, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _iv, // 0B00 - 0B0F
sl@0
   181
    _iv, _xx, _xx, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, // 0B10 - 0B1F
sl@0
   182
    _ct, _ct, _ct, _ct, _bb, _ct, _ct, _ct, _bb, _xx, _ct, _ct, _bb, _bb, _bb, _pb, // 0B20 - 0B2F
sl@0
   183
    _rb, _xx, _bb, _bb, _xx, _ct, _ct, _ct, _ct, _ct, _xx, _xx, _nu, _xx, _r2, _da, // 0B30 - 0B3F
sl@0
   184
    _dr, _db, _db, _db, _xx, _xx, _xx, _l1, _s1, _xx, _xx, _s2, _s3, _vr, _xx, _xx, // 0B40 - 0B4F
sl@0
   185
    _xx, _xx, _xx, _xx, _xx, _xx, _m2, _m2, _xx, _xx, _xx, _xx, _cn, _cn, _xx, _cn, // 0B50 - 0B5F
sl@0
   186
    _iv, _iv, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0B60 - 0B6F
sl@0
   187
    _xx, _ct                                                                        // 0B70 - 0B71
sl@0
   188
};
sl@0
   189
sl@0
   190
// Nokia: Changed 0B92 to _to for the exceptional case of Tamil independent vowel O
sl@0
   191
static const IndicClassTable::CharClass tamlCharClasses[] =
sl@0
   192
{
sl@0
   193
    _xx, _xx, _ma, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _xx, _xx, _iv, _iv, // 0B80 - 0B8F
sl@0
   194
    _iv, _xx, _to, _iv, _iv, _ct, _xx, _xx, _xx, _ct, _ct, _xx, _ct, _xx, _ct, _ct, // 0B90 - 0B9F
sl@0
   195
    _xx, _xx, _xx, _ct, _ct, _xx, _xx, _xx, _ct, _ct, _ct, _xx, _xx, _xx, _ct, _ct, // 0BA0 - 0BAF
sl@0
   196
    _ct, _ct, _ct, _ct, _ct, _ct, _xx, _ct, _ct, _ct, _xx, _xx, _xx, _xx, _r2, _dr, // 0BB0 - 0BBF
sl@0
   197
    _da, _dr, _dr, _xx, _xx, _xx, _l1, _l1, _dl, _xx, _s1, _s2, _s3, _vr, _xx, _xx, // 0BC0 - 0BCF
sl@0
   198
    _xx, _xx, _xx, _xx, _xx, _xx, _xx, _m2, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0BD0 - 0BDF
sl@0
   199
    _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0BE0 - 0BEF
sl@0
   200
    _xx, _xx, _xx                                                                   // 0BF0 - 0BF2
sl@0
   201
};
sl@0
   202
sl@0
   203
// FIXME: Should some of the bb's be pb's? (KA, NA, MA, YA, VA, etc. (approx 13))
sl@0
   204
// Nokia: Changed 0C31 character to _bb as with _ct the consonant cluster is not rendered correctly.
sl@0
   205
static const IndicClassTable::CharClass teluCharClasses[] =
sl@0
   206
{
sl@0
   207
    _xx, _mp, _mp, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _iv, _iv, // 0C00 - 0C0F
sl@0
   208
    _iv, _xx, _iv, _iv, _iv, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, // 0C10 - 0C1F
sl@0
   209
    _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _xx, _bb, _bb, _bb, _bb, _bb, _bb, // 0C20 - 0C2F
sl@0
   210
    _bb, _bb, _bb, _bb, _xx, _bb, _bb, _bb, _bb, _bb, _xx, _xx, _xx, _xx, _da, _da, // 0C30 - 0C3F
sl@0
   211
    _da, _dr, _dr, _dr, _dr, _xx, _a1, _da, _s1, _xx, _da, _da, _da, _vr, _xx, _xx, // 0C40 - 0C4F
sl@0
   212
    _xx, _xx, _xx, _xx, _xx, _da, _m2, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0C50 - 0C5F
sl@0
   213
    _iv, _iv, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx  // 0C60 - 0C6F
sl@0
   214
};
sl@0
   215
sl@0
   216
// U+CC3 and U+CC4 are _lm here not _dr since the Kannada rendering
sl@0
   217
// rules want them below and to the right of the entire cluster
sl@0
   218
//
sl@0
   219
// There's some information about this in:
sl@0
   220
//
sl@0
   221
//  http://brahmi.sourceforge.net/docs/KannadaComputing.html
sl@0
   222
sl@0
   223
// Nokia: Changed 0CBC character class to _nu (NUKTA), as post Unicode 4.0, this
sl@0
   224
// code point is classified as the Kannada NUKTA character.
sl@0
   225
// Also changed 0CB0 from _rb to special case _cr to satiisfy the usecase Ra + ZWJ + Virama + Consonant
sl@0
   226
// see _cr and _rb above
sl@0
   227
static const IndicClassTable::CharClass kndaCharClasses[] =
sl@0
   228
{
sl@0
   229
    _xx, _xx, _mp, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _iv, _iv, // 0C80 - 0C8F
sl@0
   230
    _iv, _xx, _iv, _iv, _iv, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, // 0C90 - 0C9F
sl@0
   231
    _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _bb, _xx, _bb, _bb, _bb, _bb, _bb, _bb, // 0CA0 - 0CAF
sl@0
   232
    _kr, _ct, _bb, _bb, _xx, _bb, _bb, _bb, _bb, _bb, _xx, _xx, _nu, _xx, _dr, _da, // 0CB0 - 0CBF
sl@0
   233
    _s1, _dr, _r2, _lm, _lm, _xx, _a1, _s2, _s3, _xx, _s4, _s5, _da, _vr, _xx, _xx, // 0CC0 - 0CCF
sl@0
   234
    _xx, _xx, _xx, _xx, _xx, _m3, _m2, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _bb, _xx, // 0CD0 - 0CDF
sl@0
   235
    _iv, _iv, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx  // 0CE0 - 0CEF
sl@0
   236
};
sl@0
   237
sl@0
   238
// FIXME: this is correct for old-style Malayalam (MAL) but not for reformed Malayalam (MLR)
sl@0
   239
// FIXME: should there be a REPH for old-style Malayalam?
sl@0
   240
static const IndicClassTable::CharClass mlymCharClasses[] =
sl@0
   241
{
sl@0
   242
    _xx, _xx, _mp, _mp, _xx, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _iv, _xx, _iv, _iv, // 0D00 - 0D0F
sl@0
   243
//    _iv, _xx, _iv, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _bb, // 0D10 - 0D1F //old
sl@0
   244
    _iv, _xx, _iv, _iv, _iv, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, _ct, // 0D10 - 0D1F
sl@0
   245
//    _ct, _ct, _ct, _bb, _ct, _bb, _bb, _ct, _ct, _xx, _ct, _ct, _ct, _ct, _ct, _pb, // 0D20 - 0D2F //old
sl@0
   246
    _ct, _ct, _ct, _ctc, _ct, _ct, _ct, _ct, _ctc, _xx, _ct, _ct, _ct, _ct, _ct, _pb, // 0D20 - 0D2F 
sl@0
   247
//    _pb, _cn, _bb, _ct, _ct, _pb, _ct, _ct, _ct, _ct, _xx, _xx, _xx, _xx, _r2, _dr, // 0D30 - 0D3F //old
sl@0
   248
    _pbc, _cn, _bbc, _ctc, _ct, _pb, _ct, _ct, _ct, _ct, _xx, _xx, _xx, _xx, _r2, _dr, // 0D30 - 0D3F 
sl@0
   249
    _dr, _dr, _dr, _dr, _xx, _xx, _l1, _l1, _dl, _xx, _s1, _s2, _s3, _vr, _xx, _xx, // 0D40 - 0D4F
sl@0
   250
    _xx, _xx, _xx, _xx, _xx, _xx, _xx, _m2, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, // 0D50 - 0D5F
sl@0
   251
    _iv, _iv, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx, _xx  // 0D60 - 0D6F
sl@0
   252
};
sl@0
   253
sl@0
   254
//
sl@0
   255
// Split matra tables
sl@0
   256
//
sl@0
   257
static const SplitMatra bengSplitTable[] = {{0x09C7, 0x09BE}, {0x09C7, 0x09D7}};
sl@0
   258
sl@0
   259
static const SplitMatra oryaSplitTable[] = {{0x0B47, 0x0B56}, {0x0B47, 0x0B3E}, {0x0B47, 0x0B57}};
sl@0
   260
sl@0
   261
static const SplitMatra tamlSplitTable[] = {{0x0BC6, 0x0BBE}, {0x0BC7, 0x0BBE}, {0x0BC6, 0x0BD7}};
sl@0
   262
sl@0
   263
static const SplitMatra teluSplitTable[] = {{0x0C46, 0x0C56}};
sl@0
   264
sl@0
   265
static const SplitMatra kndaSplitTable[] = {{0x0CBF, 0x0CD5}, {0x0CC6, 0x0CD5}, {0x0CC6, 0x0CD6}, {0x0CC6, 0x0CC2},
sl@0
   266
                                   {0x0CC6, 0x0CC2, 0x0CD5}};
sl@0
   267
sl@0
   268
static const SplitMatra mlymSplitTable[] = {{0x0D46, 0x0D3E}, {0x0D47, 0x0D3E}, {0x0D46, 0x0D57}};
sl@0
   269
sl@0
   270
//
sl@0
   271
// Script Flags
sl@0
   272
//
sl@0
   273
sl@0
   274
// FIXME: post 'GSUB' reordering of MATRA_PRE's for Malayalam and Tamil
sl@0
   275
// FIXME: reformed Malayalam needs to reorder VATTU to before base glyph...
sl@0
   276
// FIXME: eyelash RA only for Devanagari??
sl@0
   277
#define DEVA_SCRIPT_FLAGS (SF_EYELASH_RA | SF_NO_POST_BASE_LIMIT)
sl@0
   278
#define BENG_SCRIPT_FLAGS (SF_REPH_AFTER_BELOW | SF_NO_POST_BASE_LIMIT)
sl@0
   279
#define PUNJ_SCRIPT_FLAGS (SF_NO_POST_BASE_LIMIT | SF_MATRAS_AFTER_POSTBASE)
sl@0
   280
#define GUJR_SCRIPT_FLAGS (SF_NO_POST_BASE_LIMIT)
sl@0
   281
#define ORYA_SCRIPT_FLAGS (SF_REPH_AFTER_BELOW | SF_NO_POST_BASE_LIMIT)
sl@0
   282
#define TAML_SCRIPT_FLAGS (SF_MPRE_FIXUP | SF_NO_POST_BASE_LIMIT)
sl@0
   283
#define TELU_SCRIPT_FLAGS (SF_MATRAS_AFTER_BASE | 3)
sl@0
   284
#define KNDA_SCRIPT_FLAGS (SF_MATRAS_AFTER_BASE | 3)
sl@0
   285
#define MLYM_SCRIPT_FLAGS (SF_MPRE_FIXUP | SF_NO_POST_BASE_LIMIT)
sl@0
   286
sl@0
   287
//
sl@0
   288
// Indic Class Tables
sl@0
   289
//
sl@0
   290
static const IndicClassTable devaClassTable = {0x0900, 0x0970, 2, DEVA_SCRIPT_FLAGS, devaCharClasses, NULL};
sl@0
   291
sl@0
   292
static const IndicClassTable bengClassTable = {0x0980, 0x09FA, 3, BENG_SCRIPT_FLAGS, bengCharClasses, bengSplitTable};
sl@0
   293
sl@0
   294
static const IndicClassTable punjClassTable = {0x0A00, 0x0A74, 2, PUNJ_SCRIPT_FLAGS, punjCharClasses, NULL};
sl@0
   295
sl@0
   296
static const IndicClassTable gujrClassTable = {0x0A80, 0x0AEF, 2, GUJR_SCRIPT_FLAGS, gujrCharClasses, NULL};
sl@0
   297
sl@0
   298
static const IndicClassTable oryaClassTable = {0x0B00, 0x0B71, 3, ORYA_SCRIPT_FLAGS, oryaCharClasses, oryaSplitTable};
sl@0
   299
sl@0
   300
static const IndicClassTable tamlClassTable = {0x0B80, 0x0BF2, 3, TAML_SCRIPT_FLAGS, tamlCharClasses, tamlSplitTable};
sl@0
   301
sl@0
   302
static const IndicClassTable teluClassTable = {0x0C00, 0x0C6F, 3, TELU_SCRIPT_FLAGS, teluCharClasses, teluSplitTable};
sl@0
   303
sl@0
   304
static const IndicClassTable kndaClassTable = {0x0C80, 0x0CEF, 4, KNDA_SCRIPT_FLAGS, kndaCharClasses, kndaSplitTable};
sl@0
   305
sl@0
   306
static const IndicClassTable mlymClassTable = {0x0D00, 0x0D6F, 3, MLYM_SCRIPT_FLAGS, mlymCharClasses, mlymSplitTable};
sl@0
   307
sl@0
   308
//
sl@0
   309
// IndicClassTable addresses
sl@0
   310
//
sl@0
   311
static const IndicClassTable * const indicClassTables[] = {
sl@0
   312
    NULL,            /* 'zyyy' (COMMON) */
sl@0
   313
    NULL,            /* 'qaai' (INHERITED) */
sl@0
   314
    NULL,            /* 'arab' (ARABIC) */
sl@0
   315
    NULL,            /* 'armn' (ARMENIAN) */
sl@0
   316
    &bengClassTable, /* 'beng' (BENGALI) */
sl@0
   317
    NULL,            /* 'bopo' (BOPOMOFO) */
sl@0
   318
    NULL,            /* 'cher' (CHEROKEE) */
sl@0
   319
    NULL,            /* 'qaac' (COPTIC) */
sl@0
   320
    NULL,            /* 'cyrl' (CYRILLIC) */
sl@0
   321
    NULL,            /* 'dsrt' (DESERET) */
sl@0
   322
    &devaClassTable, /* 'deva' (DEVANAGARI) */
sl@0
   323
    NULL,            /* 'ethi' (ETHIOPIC) */
sl@0
   324
    NULL,            /* 'geor' (GEORGIAN) */
sl@0
   325
    NULL,            /* 'goth' (GOTHIC) */
sl@0
   326
    NULL,            /* 'grek' (GREEK) */
sl@0
   327
    &gujrClassTable, /* 'gujr' (GUJARATI) */
sl@0
   328
    &punjClassTable, /* 'guru' (GURMUKHI) */
sl@0
   329
    NULL,            /* 'hani' (HAN) */
sl@0
   330
    NULL,            /* 'hang' (HANGUL) */
sl@0
   331
    NULL,            /* 'hebr' (HEBREW) */
sl@0
   332
    NULL,            /* 'hira' (HIRAGANA) */
sl@0
   333
    &kndaClassTable, /* 'knda' (KANNADA) */
sl@0
   334
    NULL,            /* 'kata' (KATAKANA) */
sl@0
   335
    NULL,            /* 'khmr' (KHMER) */
sl@0
   336
    NULL,            /* 'laoo' (LAO) */
sl@0
   337
    NULL,            /* 'latn' (LATIN) */
sl@0
   338
    &mlymClassTable, /* 'mlym' (MALAYALAM) */
sl@0
   339
    NULL,            /* 'mong' (MONGOLIAN) */
sl@0
   340
    NULL,            /* 'mymr' (MYANMAR) */
sl@0
   341
    NULL,            /* 'ogam' (OGHAM) */
sl@0
   342
    NULL,            /* 'ital' (OLD-ITALIC) */
sl@0
   343
    &oryaClassTable, /* 'orya' (ORIYA) */
sl@0
   344
    NULL,            /* 'runr' (RUNIC) */
sl@0
   345
    NULL,            /* 'sinh' (SINHALA) */
sl@0
   346
    NULL,            /* 'syrc' (SYRIAC) */
sl@0
   347
    &tamlClassTable, /* 'taml' (TAMIL) */
sl@0
   348
    &teluClassTable, /* 'telu' (TELUGU) */
sl@0
   349
    NULL,            /* 'thaa' (THAANA) */
sl@0
   350
    NULL,            /* 'thai' (THAI) */
sl@0
   351
    NULL,            /* 'tibt' (TIBETAN) */
sl@0
   352
    NULL,            /* 'cans' (CANADIAN-ABORIGINAL) */
sl@0
   353
    NULL,            /* 'yiii' (YI) */
sl@0
   354
    NULL,            /* 'tglg' (TAGALOG) */
sl@0
   355
    NULL,            /* 'hano' (HANUNOO) */
sl@0
   356
    NULL,            /* 'buhd' (BUHID) */
sl@0
   357
    NULL,            /* 'tagb' (TAGBANWA) */
sl@0
   358
    NULL,            /* 'brai' (BRAILLE) */
sl@0
   359
    NULL,            /* 'cprt' (CYPRIOT) */
sl@0
   360
    NULL,            /* 'limb' (LIMBU) */
sl@0
   361
    NULL,            /* 'linb' (LINEAR_B) */
sl@0
   362
    NULL,            /* 'osma' (OSMANYA) */
sl@0
   363
    NULL,            /* 'shaw' (SHAVIAN) */
sl@0
   364
    NULL,            /* 'tale' (TAI_LE) */
sl@0
   365
    NULL,            /* 'ugar' (UGARITIC) */
sl@0
   366
    NULL             /* 'hrkt' (KATAKANA_OR_HIRAGANA) */
sl@0
   367
};
sl@0
   368
sl@0
   369
IndicClassTable::CharClass IndicClassTable::getCharClass(LEUnicode ch) const
sl@0
   370
{
sl@0
   371
    if (ch == C_SIGN_ZWJ) {
sl@0
   372
        return CF_CONSONANT | CC_ZERO_WIDTH_MARK;
sl@0
   373
    }
sl@0
   374
sl@0
   375
    if (ch == C_SIGN_ZWNJ) {
sl@0
   376
        return CC_ZERO_WIDTH_MARK;
sl@0
   377
    }
sl@0
   378
sl@0
   379
    if (ch < firstChar || ch > lastChar) {
sl@0
   380
        return CC_RESERVED;
sl@0
   381
    }
sl@0
   382
sl@0
   383
    return classTable[ch - firstChar];
sl@0
   384
}
sl@0
   385
sl@0
   386
const IndicClassTable *IndicClassTable::getScriptClassTable(le_int32 scriptCode)
sl@0
   387
{
sl@0
   388
    if (scriptCode < 0 || scriptCode >= scriptCodeCount) {
sl@0
   389
        return NULL;
sl@0
   390
    }
sl@0
   391
sl@0
   392
    return indicClassTables[scriptCode];
sl@0
   393
}
sl@0
   394
sl@0
   395
le_int32 IndicReordering::getWorstCaseExpansion(le_int32 scriptCode)
sl@0
   396
{
sl@0
   397
    const IndicClassTable *classTable = IndicClassTable::getScriptClassTable(scriptCode);
sl@0
   398
sl@0
   399
    if (classTable == NULL) {
sl@0
   400
        return 1;
sl@0
   401
    }
sl@0
   402
sl@0
   403
    return classTable->getWorstCaseExpansion();
sl@0
   404
}
sl@0
   405
sl@0
   406
U_NAMESPACE_END