jdk/src/share/native/sun/font/layout/IndicReordering.cpp
author kvn
Tue, 28 Jan 2014 14:57:41 -0800
changeset 22607 ba232b417248
parent 22330 cafb826672bd
child 25101 2b07b28079a1
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3935
diff changeset
     6
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3935
diff changeset
     8
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3935
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3935
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 3935
diff changeset
    22
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 *
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    28
 * (C) Copyright IBM Corp. 1998-2009 - All Rights Reserved
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "LETypes.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "OpenTypeTables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "OpenTypeUtilities.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "IndicReordering.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include "LEGlyphStorage.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#include "MPreFixups.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    39
U_NAMESPACE_BEGIN
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
    40
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    41
#define loclFeatureTag LE_LOCL_FEATURE_TAG
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#define initFeatureTag LE_INIT_FEATURE_TAG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#define nuktFeatureTag LE_NUKT_FEATURE_TAG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
#define akhnFeatureTag LE_AKHN_FEATURE_TAG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
#define rphfFeatureTag LE_RPHF_FEATURE_TAG
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    46
#define rkrfFeatureTag LE_RKRF_FEATURE_TAG
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
#define blwfFeatureTag LE_BLWF_FEATURE_TAG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
#define halfFeatureTag LE_HALF_FEATURE_TAG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
#define pstfFeatureTag LE_PSTF_FEATURE_TAG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
#define vatuFeatureTag LE_VATU_FEATURE_TAG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
#define presFeatureTag LE_PRES_FEATURE_TAG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#define blwsFeatureTag LE_BLWS_FEATURE_TAG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
#define abvsFeatureTag LE_ABVS_FEATURE_TAG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
#define pstsFeatureTag LE_PSTS_FEATURE_TAG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
#define halnFeatureTag LE_HALN_FEATURE_TAG
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    56
#define cjctFeatureTag LE_CJCT_FEATURE_TAG
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
#define blwmFeatureTag LE_BLWM_FEATURE_TAG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
#define abvmFeatureTag LE_ABVM_FEATURE_TAG
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
#define distFeatureTag LE_DIST_FEATURE_TAG
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    60
#define caltFeatureTag LE_CALT_FEATURE_TAG
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    61
#define kernFeatureTag LE_KERN_FEATURE_TAG
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    63
#define loclFeatureMask 0x80000000UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    64
#define rphfFeatureMask 0x40000000UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    65
#define blwfFeatureMask 0x20000000UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    66
#define halfFeatureMask 0x10000000UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    67
#define pstfFeatureMask 0x08000000UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    68
#define nuktFeatureMask 0x04000000UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    69
#define akhnFeatureMask 0x02000000UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    70
#define vatuFeatureMask 0x01000000UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    71
#define presFeatureMask 0x00800000UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    72
#define blwsFeatureMask 0x00400000UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    73
#define abvsFeatureMask 0x00200000UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    74
#define pstsFeatureMask 0x00100000UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    75
#define halnFeatureMask 0x00080000UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    76
#define blwmFeatureMask 0x00040000UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    77
#define abvmFeatureMask 0x00020000UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    78
#define distFeatureMask 0x00010000UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    79
#define initFeatureMask 0x00008000UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    80
#define cjctFeatureMask 0x00004000UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    81
#define rkrfFeatureMask 0x00002000UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    82
#define caltFeatureMask 0x00001000UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    83
#define kernFeatureMask 0x00000800UL
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    85
// Syllable structure bits
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    86
#define baseConsonantMask       0x00000400UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    87
#define consonantMask           0x00000200UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    88
#define halfConsonantMask       0x00000100UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    89
#define rephConsonantMask       0x00000080UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    90
#define matraMask               0x00000040UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    91
#define vowelModifierMask       0x00000020UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    92
#define markPositionMask        0x00000018UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    93
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    94
#define postBasePosition        0x00000000UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    95
#define preBasePosition         0x00000008UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    96
#define aboveBasePosition       0x00000010UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    97
#define belowBasePosition       0x00000018UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    98
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
    99
#define repositionedGlyphMask   0x00000002UL
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   100
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   101
#define basicShapingFormsMask ( loclFeatureMask | nuktFeatureMask | akhnFeatureMask | rkrfFeatureMask | blwfFeatureMask | halfFeatureMask | vatuFeatureMask | cjctFeatureMask )
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   102
#define positioningFormsMask ( kernFeatureMask | distFeatureMask | abvmFeatureMask | blwmFeatureMask )
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   103
#define presentationFormsMask ( presFeatureMask | abvsFeatureMask | blwsFeatureMask | pstsFeatureMask | halnFeatureMask | caltFeatureMask )
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   104
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   105
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   106
#define C_MALAYALAM_VOWEL_SIGN_U 0x0D41
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   107
#define C_DOTTED_CIRCLE 0x25CC
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   108
#define NO_GLYPH 0xFFFF
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   109
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   110
// Some level of debate as to the proper value for MAX_CONSONANTS_PER_SYLLABLE.  Ticket 5588 states that 4
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   111
// is the magic number according to ISCII, but 5 seems to be the more consistent with XP.
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   112
#define MAX_CONSONANTS_PER_SYLLABLE 5
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   113
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   114
#define INDIC_BLOCK_SIZE 0x7F
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   115
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   116
class IndicReorderingOutput : public UMemory {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
private:
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   118
    le_int32   fSyllableCount;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
    le_int32   fOutIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    LEUnicode *fOutChars;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    LEGlyphStorage &fGlyphStorage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    LEUnicode   fMpre;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    le_int32    fMpreIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    LEUnicode   fMbelow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    le_int32    fMbelowIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    LEUnicode   fMabove;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    le_int32    fMaboveIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    LEUnicode   fMpost;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
    le_int32    fMpostIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    LEUnicode   fLengthMark;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    le_int32    fLengthMarkIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   139
    LEUnicode   fAlLakuna;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   140
    le_int32    fAlLakunaIndex;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    FeatureMask fMatraFeatures;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
    le_int32    fMPreOutIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    MPreFixups *fMPreFixups;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    LEUnicode   fVMabove;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    LEUnicode   fVMpost;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    le_int32    fVMIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
    FeatureMask fVMFeatures;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    LEUnicode   fSMabove;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    LEUnicode   fSMbelow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    le_int32    fSMIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    FeatureMask fSMFeatures;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   157
    LEUnicode   fPreBaseConsonant;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   158
    LEUnicode   fPreBaseVirama;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   159
    le_int32    fPBCIndex;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   160
    FeatureMask fPBCFeatures;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   161
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    void saveMatra(LEUnicode matra, le_int32 matraIndex, IndicClassTable::CharClass matraClass)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        // FIXME: check if already set, or if not a matra...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        if (IndicClassTable::isLengthMark(matraClass)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            fLengthMark = matra;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
            fLengthMarkIndex = matraIndex;
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   168
        } else if (IndicClassTable::isAlLakuna(matraClass)) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   169
            fAlLakuna = matra;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   170
            fAlLakunaIndex = matraIndex;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            switch (matraClass & CF_POS_MASK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            case CF_POS_BEFORE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                fMpre = matra;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
                fMpreIndex = matraIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            case CF_POS_BELOW:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                fMbelow = matra;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                fMbelowIndex = matraIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            case CF_POS_ABOVE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                fMabove = matra;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                fMaboveIndex = matraIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            case CF_POS_AFTER:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                fMpost = matra;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                fMpostIndex = matraIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                // can't get here...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
           }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
public:
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   201
    IndicReorderingOutput(LEUnicode *outChars, LEGlyphStorage &glyphStorage, MPreFixups *mpreFixups)
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   202
        : fSyllableCount(0), fOutIndex(0), fOutChars(outChars), fGlyphStorage(glyphStorage),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
          fMpre(0), fMpreIndex(0), fMbelow(0), fMbelowIndex(0), fMabove(0), fMaboveIndex(0),
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   204
          fMpost(0), fMpostIndex(0), fLengthMark(0), fLengthMarkIndex(0), fAlLakuna(0), fAlLakunaIndex(0),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
          fMatraFeatures(0), fMPreOutIndex(-1), fMPreFixups(mpreFixups),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
          fVMabove(0), fVMpost(0), fVMIndex(0), fVMFeatures(0),
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   207
          fSMabove(0), fSMbelow(0), fSMIndex(0), fSMFeatures(0),
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   208
          fPreBaseConsonant(0), fPreBaseVirama(0), fPBCIndex(0), fPBCFeatures(0)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        // nothing else to do...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   213
    ~IndicReorderingOutput()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
        // nothing to do here...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    void reset()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    {
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   220
        fSyllableCount += 1;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   221
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   222
        fMpre = fMbelow = fMabove = fMpost = fLengthMark = fAlLakuna = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        fMPreOutIndex = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        fVMabove = fVMpost  = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        fSMabove = fSMbelow = 0;
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   227
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   228
        fPreBaseConsonant = fPreBaseVirama = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    void writeChar(LEUnicode ch, le_uint32 charIndex, FeatureMask charFeatures)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        LEErrorCode success = LE_NO_ERROR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        fOutChars[fOutIndex] = ch;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        fGlyphStorage.setCharIndex(fOutIndex, charIndex, success);
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   238
        fGlyphStorage.setAuxData(fOutIndex, charFeatures | (fSyllableCount & LE_GLYPH_GROUP_MASK), success);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        fOutIndex += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   243
    void setFeatures ( le_uint32 charIndex, FeatureMask charFeatures)
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   244
    {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   245
        LEErrorCode success = LE_NO_ERROR;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   246
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   247
        fGlyphStorage.setAuxData( charIndex, charFeatures, success );
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   248
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   249
    }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   250
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   251
    FeatureMask getFeatures ( le_uint32 charIndex )
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   252
    {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   253
        LEErrorCode success = LE_NO_ERROR;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   254
        return fGlyphStorage.getAuxData(charIndex,success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   255
    }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   256
22330
cafb826672bd 8024530: Enhance font process resilience
prr
parents: 16891
diff changeset
   257
    void decomposeReorderMatras ( const IndicClassTable *classTable, le_int32 beginSyllable, le_int32 nextSyllable, le_int32 inv_count ) {
cafb826672bd 8024530: Enhance font process resilience
prr
parents: 16891
diff changeset
   258
        le_int32 i;
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   259
        LEErrorCode success = LE_NO_ERROR;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   260
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   261
                for ( i = beginSyllable ; i < nextSyllable ; i++ ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   262
                        if ( classTable->isMatra(fOutChars[i+inv_count])) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   263
                                IndicClassTable::CharClass matraClass = classTable->getCharClass(fOutChars[i+inv_count]);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   264
                                if ( classTable->isSplitMatra(matraClass)) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   265
                                        le_int32 saveIndex = fGlyphStorage.getCharIndex(i+inv_count,success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   266
                                        le_uint32 saveAuxData = fGlyphStorage.getAuxData(i+inv_count,success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   267
                    const SplitMatra *splitMatra = classTable->getSplitMatra(matraClass);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   268
                    int j;
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 7486
diff changeset
   269
                    for (j = 0 ; j < SM_MAX_PIECES && *(splitMatra)[j] != 0 ; j++) {
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   270
                        LEUnicode piece = (*splitMatra)[j];
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   271
                                                if ( j == 0 ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   272
                                                        fOutChars[i+inv_count] = piece;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   273
                                                        matraClass = classTable->getCharClass(piece);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   274
                                                } else {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   275
                                                        insertCharacter(piece,i+1+inv_count,saveIndex,saveAuxData);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   276
                                                        nextSyllable++;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   277
                                                }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   278
                                    }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   279
                                }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   280
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   281
                                if ((matraClass & CF_POS_MASK) == CF_POS_BEFORE) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   282
                    moveCharacter(i+inv_count,beginSyllable+inv_count);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   283
                                }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   284
                        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   285
                }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   286
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   287
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   288
        void moveCharacter( le_int32 fromPosition, le_int32 toPosition ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   289
                le_int32 i,saveIndex;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   290
                le_uint32 saveAuxData;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   291
                LEUnicode saveChar = fOutChars[fromPosition];
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   292
            LEErrorCode success = LE_NO_ERROR;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   293
                LEErrorCode success2 = LE_NO_ERROR;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   294
                saveIndex = fGlyphStorage.getCharIndex(fromPosition,success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   295
        saveAuxData = fGlyphStorage.getAuxData(fromPosition,success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   296
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   297
                if ( fromPosition > toPosition ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   298
                        for ( i = fromPosition ; i > toPosition ; i-- ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   299
                                fOutChars[i] = fOutChars[i-1];
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   300
                                fGlyphStorage.setCharIndex(i,fGlyphStorage.getCharIndex(i-1,success2),success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   301
                                fGlyphStorage.setAuxData(i,fGlyphStorage.getAuxData(i-1,success2), success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   302
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   303
                        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   304
                } else {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   305
                        for ( i = fromPosition ; i < toPosition ; i++ ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   306
                                fOutChars[i] = fOutChars[i+1];
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   307
                                fGlyphStorage.setCharIndex(i,fGlyphStorage.getCharIndex(i+1,success2),success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   308
                                fGlyphStorage.setAuxData(i,fGlyphStorage.getAuxData(i+1,success2), success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   309
                        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   310
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   311
                }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   312
                fOutChars[toPosition] = saveChar;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   313
                fGlyphStorage.setCharIndex(toPosition,saveIndex,success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   314
                fGlyphStorage.setAuxData(toPosition,saveAuxData,success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   315
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   316
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   317
        void insertCharacter( LEUnicode ch, le_int32 toPosition, le_int32 charIndex, le_uint32 auxData ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   318
            LEErrorCode success = LE_NO_ERROR;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   319
        le_int32 i;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   320
                fOutIndex += 1;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   321
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   322
                for ( i = fOutIndex ; i > toPosition ; i--) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   323
                                fOutChars[i] = fOutChars[i-1];
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   324
                                fGlyphStorage.setCharIndex(i,fGlyphStorage.getCharIndex(i-1,success),success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   325
                                fGlyphStorage.setAuxData(i,fGlyphStorage.getAuxData(i-1,success), success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   326
                }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   327
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   328
                fOutChars[toPosition] = ch;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   329
                fGlyphStorage.setCharIndex(toPosition,charIndex,success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   330
                fGlyphStorage.setAuxData(toPosition,auxData,success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   331
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   332
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   333
        void removeCharacter( le_int32 fromPosition ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   334
            LEErrorCode success = LE_NO_ERROR;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   335
        le_int32 i;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   336
                fOutIndex -= 1;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   337
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   338
                for ( i = fromPosition ; i < fOutIndex ; i--) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   339
                                fOutChars[i] = fOutChars[i+1];
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   340
                                fGlyphStorage.setCharIndex(i,fGlyphStorage.getCharIndex(i+1,success),success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   341
                                fGlyphStorage.setAuxData(i,fGlyphStorage.getAuxData(i+1,success), success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   342
                }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   343
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   344
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   345
    le_bool noteMatra(const IndicClassTable *classTable, LEUnicode matra, le_uint32 matraIndex, FeatureMask matraFeatures, le_bool wordStart)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        IndicClassTable::CharClass matraClass = classTable->getCharClass(matra);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        fMatraFeatures  = matraFeatures;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        if (wordStart) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
            fMatraFeatures |= initFeatureMask;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        if (IndicClassTable::isMatra(matraClass)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            if (IndicClassTable::isSplitMatra(matraClass)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
                const SplitMatra *splitMatra = classTable->getSplitMatra(matraClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
                int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 7486
diff changeset
   360
                for (i = 0; i < SM_MAX_PIECES && (*splitMatra)[i] != 0; i += 1) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
                    LEUnicode piece = (*splitMatra)[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                    IndicClassTable::CharClass pieceClass = classTable->getCharClass(piece);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                    saveMatra(piece, matraIndex, pieceClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                saveMatra(matra, matraIndex, matraClass);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   376
    void noteVowelModifier(const IndicClassTable *classTable, LEUnicode vowelModifier, le_uint32 vowelModifierIndex, FeatureMask vowelModifierFeatures)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        IndicClassTable::CharClass vmClass = classTable->getCharClass(vowelModifier);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        fVMIndex = vowelModifierIndex;
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   381
        fVMFeatures  = vowelModifierFeatures;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        if (IndicClassTable::isVowelModifier(vmClass)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
           switch (vmClass & CF_POS_MASK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
           case CF_POS_ABOVE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
               fVMabove = vowelModifier;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
               break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
           case CF_POS_AFTER:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
               fVMpost = vowelModifier;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
               break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
           default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
               // FIXME: this is an error...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
               break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
           }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   400
    void noteStressMark(const IndicClassTable *classTable, LEUnicode stressMark, le_uint32 stressMarkIndex, FeatureMask stressMarkFeatures)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
       IndicClassTable::CharClass smClass = classTable->getCharClass(stressMark);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        fSMIndex = stressMarkIndex;
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   405
        fSMFeatures  = stressMarkFeatures;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
        if (IndicClassTable::isStressMark(smClass)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            switch (smClass & CF_POS_MASK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            case CF_POS_ABOVE:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
                fSMabove = stressMark;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
            case CF_POS_BELOW:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
                fSMbelow = stressMark;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
                // FIXME: this is an error...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
           }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   424
    void notePreBaseConsonant(le_uint32 index,LEUnicode PBConsonant, LEUnicode PBVirama, FeatureMask features)
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   425
    {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   426
        fPBCIndex = index;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   427
        fPreBaseConsonant = PBConsonant;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   428
        fPreBaseVirama = PBVirama;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   429
        fPBCFeatures = features;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   430
    }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   431
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
    void noteBaseConsonant()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        if (fMPreFixups != NULL && fMPreOutIndex >= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            fMPreFixups->add(fOutIndex, fMPreOutIndex);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   439
    // Handles Al-Lakuna in Sinhala split vowels.
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   440
    void writeAlLakuna()
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    {
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   442
        if (fAlLakuna != 0) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   443
            writeChar(fAlLakuna, fAlLakunaIndex, fMatraFeatures);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    void writeMpre()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        if (fMpre != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
            fMPreOutIndex = fOutIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
            writeChar(fMpre, fMpreIndex, fMatraFeatures);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    void writeMbelow()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        if (fMbelow != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
            writeChar(fMbelow, fMbelowIndex, fMatraFeatures);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    void writeMabove()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        if (fMabove != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            writeChar(fMabove, fMaboveIndex, fMatraFeatures);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    void writeMpost()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        if (fMpost != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
            writeChar(fMpost, fMpostIndex, fMatraFeatures);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    void writeLengthMark()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
        if (fLengthMark != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
            writeChar(fLengthMark, fLengthMarkIndex, fMatraFeatures);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    void writeVMabove()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
        if (fVMabove != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
            writeChar(fVMabove, fVMIndex, fVMFeatures);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    void writeVMpost()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        if (fVMpost != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            writeChar(fVMpost, fVMIndex, fVMFeatures);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    void writeSMabove()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
        if (fSMabove != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
            writeChar(fSMabove, fSMIndex, fSMFeatures);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    void writeSMbelow()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        if (fSMbelow != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
            writeChar(fSMbelow, fSMIndex, fSMFeatures);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   511
    void writePreBaseConsonant()
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   512
    {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   513
        // The TDIL spec says that consonant + virama + RRA should produce a rakar in Malayalam.  However,
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   514
        // it seems that almost none of the fonts for Malayalam are set up to handle this.
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   515
        // So, we're going to force the issue here by using the rakar as defined with RA in most fonts.
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   516
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   517
        if (fPreBaseConsonant == 0x0d31) { // RRA
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   518
            fPreBaseConsonant = 0x0d30; // RA
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   519
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   520
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   521
        if (fPreBaseConsonant != 0) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   522
            writeChar(fPreBaseConsonant, fPBCIndex, fPBCFeatures);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   523
            writeChar(fPreBaseVirama,fPBCIndex-1,fPBCFeatures);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   524
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   525
    }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   526
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    le_int32 getOutputIndex()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        return fOutIndex;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   533
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
// TODO: Find better names for these!
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   536
#define tagArray4 (loclFeatureMask | nuktFeatureMask | akhnFeatureMask | vatuFeatureMask | presFeatureMask | blwsFeatureMask | abvsFeatureMask | pstsFeatureMask | halnFeatureMask | blwmFeatureMask | abvmFeatureMask | distFeatureMask)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
#define tagArray3 (pstfFeatureMask | tagArray4)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
#define tagArray2 (halfFeatureMask | tagArray3)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
#define tagArray1 (blwfFeatureMask | tagArray2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
#define tagArray0 (rphfFeatureMask | tagArray1)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   542
static const FeatureMap featureMap[] = {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   543
    {loclFeatureTag, loclFeatureMask},
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    {initFeatureTag, initFeatureMask},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    {nuktFeatureTag, nuktFeatureMask},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    {akhnFeatureTag, akhnFeatureMask},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
    {rphfFeatureTag, rphfFeatureMask},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    {blwfFeatureTag, blwfFeatureMask},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    {halfFeatureTag, halfFeatureMask},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    {pstfFeatureTag, pstfFeatureMask},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    {vatuFeatureTag, vatuFeatureMask},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    {presFeatureTag, presFeatureMask},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    {blwsFeatureTag, blwsFeatureMask},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    {abvsFeatureTag, abvsFeatureMask},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    {pstsFeatureTag, pstsFeatureMask},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
    {halnFeatureTag, halnFeatureMask},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    {blwmFeatureTag, blwmFeatureMask},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    {abvmFeatureTag, abvmFeatureMask},
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    {distFeatureTag, distFeatureMask}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
static const le_int32 featureCount = LE_ARRAY_SIZE(featureMap);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   564
static const FeatureMap v2FeatureMap[] = {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   565
        {loclFeatureTag, loclFeatureMask},
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   566
    {nuktFeatureTag, nuktFeatureMask},
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   567
    {akhnFeatureTag, akhnFeatureMask},
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   568
    {rphfFeatureTag, rphfFeatureMask},
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   569
        {rkrfFeatureTag, rkrfFeatureMask},
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   570
        {blwfFeatureTag, blwfFeatureMask},
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   571
    {halfFeatureTag, halfFeatureMask},
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   572
    {vatuFeatureTag, vatuFeatureMask},
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   573
    {cjctFeatureTag, cjctFeatureMask},
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   574
    {presFeatureTag, presFeatureMask},
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   575
    {abvsFeatureTag, abvsFeatureMask},
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   576
    {blwsFeatureTag, blwsFeatureMask},
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   577
    {pstsFeatureTag, pstsFeatureMask},
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   578
        {halnFeatureTag, halnFeatureMask},
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   579
        {caltFeatureTag, caltFeatureMask},
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   580
    {kernFeatureTag, kernFeatureMask},
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   581
    {distFeatureTag, distFeatureMask},
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   582
    {abvmFeatureTag, abvmFeatureMask},
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   583
    {blwmFeatureTag, blwmFeatureMask}
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   584
};
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   585
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   586
static const le_int32 v2FeatureMapCount = LE_ARRAY_SIZE(v2FeatureMap);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   587
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
static const le_int8 stateTable[][CC_COUNT] =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
{
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   590
//   xx  vm  sm  iv  i2  i3  ct  cn  nu  dv  s1  s2  s3  vr  zw  al
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   591
    { 1,  6,  1,  5,  8, 11,  3,  2,  1,  5,  9,  5,  5,  1,  1,  1}, //  0 - ground state
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   592
    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, //  1 - exit state
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   593
    {-1,  6,  1, -1, -1, -1, -1, -1, -1,  5,  9,  5,  5,  4, 12, -1}, //  2 - consonant with nukta
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   594
    {-1,  6,  1, -1, -1, -1, -1, -1,  2,  5,  9,  5,  5,  4, 12, 13}, //  3 - consonant
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   595
    {-1, -1, -1, -1, -1, -1,  3,  2, -1, -1, -1, -1, -1, -1,  7, -1}, //  4 - consonant virama
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   596
    {-1,  6,  1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, //  5 - dependent vowels
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   597
    {-1, -1,  1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, //  6 - vowel mark
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   598
    {-1, -1, -1, -1, -1, -1,  3,  2, -1, -1, -1, -1, -1, -1, -1, -1}, //  7 - consonant virama ZWJ, consonant ZWJ virama
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   599
    {-1,  6,  1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  4, -1, -1}, //  8 - independent vowels that can take a virama
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   600
    {-1,  6,  1, -1, -1, -1, -1, -1, -1, -1, -1, 10,  5, -1, -1, -1}, //  9 - first part of split vowel
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   601
    {-1,  6,  1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  5, -1, -1, -1}, // 10 - second part of split vowel
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   602
    {-1,  6,  1, -1, -1, -1, -1, -1, -1,  5,  9,  5,  5,  4, -1, -1}, // 11 - independent vowels that can take an iv
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   603
    {-1, -1,  1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  7, -1,  7}, // 12 - consonant ZWJ (TODO: Take everything else that can be after a consonant?)
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   604
    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,  7, -1}  // 13 - consonant al-lakuna ZWJ consonant
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
const FeatureMap *IndicReordering::getFeatureMap(le_int32 &count)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    count = featureCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
    return featureMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   615
const FeatureMap *IndicReordering::getv2FeatureMap(le_int32 &count)
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   616
{
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   617
    count = v2FeatureMapCount;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   618
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   619
    return v2FeatureMap;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   620
}
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   621
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
   622
le_int32 IndicReordering::findSyllable(const IndicClassTable *classTable, const LEUnicode *chars, le_int32 prev, le_int32 charCount)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    le_int32 cursor = prev;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
    le_int8 state = 0;
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   626
    le_int8 consonant_count = 0;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    while (cursor < charCount) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
        IndicClassTable::CharClass charClass = classTable->getCharClass(chars[cursor]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   631
        if ( IndicClassTable::isConsonant(charClass) ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   632
            consonant_count++;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   633
            if ( consonant_count > MAX_CONSONANTS_PER_SYLLABLE ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   634
                break;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   635
            }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   636
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   637
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        state = stateTable[state][charClass & CF_CLASS_MASK];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        if (state < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
        cursor += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    return cursor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
le_int32 IndicReordering::reorder(const LEUnicode *chars, le_int32 charCount, le_int32 scriptCode,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
                                  LEUnicode *outChars, LEGlyphStorage &glyphStorage,
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   652
                                  MPreFixups **outMPreFixups, LEErrorCode& success)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
{
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   654
    if (LE_FAILURE(success)) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   655
        return 0;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   656
    }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   657
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    MPreFixups *mpreFixups = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    const IndicClassTable *classTable = IndicClassTable::getScriptClassTable(scriptCode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16889
diff changeset
   661
    if(classTable==NULL) {
91e99bed64ae 8001031: Better font processing
prr
parents: 16889
diff changeset
   662
      success = LE_MEMORY_ALLOCATION_ERROR;
91e99bed64ae 8001031: Better font processing
prr
parents: 16889
diff changeset
   663
      return 0;
91e99bed64ae 8001031: Better font processing
prr
parents: 16889
diff changeset
   664
    }
91e99bed64ae 8001031: Better font processing
prr
parents: 16889
diff changeset
   665
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    if (classTable->scriptFlags & SF_MPRE_FIXUP) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        mpreFixups = new MPreFixups(charCount);
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   668
        if (mpreFixups == NULL) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   669
            success = LE_MEMORY_ALLOCATION_ERROR;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   670
            return 0;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   671
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   674
    IndicReorderingOutput output(outChars, glyphStorage, mpreFixups);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    le_int32 i, prev = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    le_bool lastInWord = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    while (prev < charCount) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        le_int32 syllable = findSyllable(classTable, chars, prev, charCount);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        le_int32 matra, markStart = syllable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
        output.reset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
        if (classTable->isStressMark(chars[markStart - 1])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
            markStart -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
            output.noteStressMark(classTable, chars[markStart], markStart, tagArray1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   689
        if (markStart != prev && classTable->isVowelModifier(chars[markStart - 1])) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
            markStart -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
            output.noteVowelModifier(classTable, chars[markStart], markStart, tagArray1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
        matra = markStart - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
        while (output.noteMatra(classTable, chars[matra], matra, tagArray1, !lastInWord) && matra != prev) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
            matra -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
        lastInWord = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        switch (classTable->getCharClass(chars[prev]) & CF_CLASS_MASK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
        case CC_RESERVED:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
            lastInWord = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
            /* fall through */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
        case CC_INDEPENDENT_VOWEL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
        case CC_ZERO_WIDTH_MARK:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
            for (i = prev; i < syllable; i += 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
                output.writeChar(chars[i], i, tagArray1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   715
        case CC_AL_LAKUNA:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
        case CC_NUKTA:
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   717
            output.writeChar(C_DOTTED_CIRCLE, prev, tagArray1);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   718
            output.writeChar(chars[prev], prev, tagArray1);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   719
            break;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   720
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
        case CC_VIRAMA:
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   722
            // A lone virama is illegal unless it follows a
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   723
            // MALAYALAM_VOWEL_SIGN_U. Such a usage is called
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   724
            // "samvruthokaram".
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   725
            if (chars[prev - 1] != C_MALAYALAM_VOWEL_SIGN_U) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
            output.writeChar(C_DOTTED_CIRCLE, prev, tagArray1);
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   727
            }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   728
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
            output.writeChar(chars[prev], prev, tagArray1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
        case CC_DEPENDENT_VOWEL:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
        case CC_SPLIT_VOWEL_PIECE_1:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
        case CC_SPLIT_VOWEL_PIECE_2:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
        case CC_SPLIT_VOWEL_PIECE_3:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
        case CC_VOWEL_MODIFIER:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
        case CC_STRESS_MARK:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
            output.writeMpre();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
            output.writeChar(C_DOTTED_CIRCLE, prev, tagArray1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
            output.writeMbelow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
            output.writeSMbelow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
            output.writeMabove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
            if ((classTable->scriptFlags & SF_MATRAS_AFTER_BASE) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
                output.writeMpost();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
            if ((classTable->scriptFlags & SF_REPH_AFTER_BELOW) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
                output.writeVMabove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
                output.writeSMabove(); // FIXME: there are no SM's in these scripts...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
            if ((classTable->scriptFlags & SF_MATRAS_AFTER_BASE) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
                output.writeMpost();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
            output.writeLengthMark();
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   760
            output.writeAlLakuna();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
            if ((classTable->scriptFlags & SF_REPH_AFTER_BELOW) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
                output.writeVMabove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
                output.writeSMabove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
            output.writeVMpost();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
        case CC_INDEPENDENT_VOWEL_2:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
        case CC_INDEPENDENT_VOWEL_3:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
        case CC_CONSONANT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        case CC_CONSONANT_WITH_NUKTA:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
            le_uint32 length = markStart - prev;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
            le_int32  lastConsonant = markStart - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
            le_int32  baseLimit = prev;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
            // Check for REPH at front of syllable
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   780
            if (length > 2 && classTable->isReph(chars[prev]) && classTable->isVirama(chars[prev + 1]) && chars[prev + 2] != C_SIGN_ZWNJ) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
                baseLimit += 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
                // Check for eyelash RA, if the script supports it
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
                if ((classTable->scriptFlags & SF_EYELASH_RA) != 0 &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
                    chars[baseLimit] == C_SIGN_ZWJ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
                    if (length > 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
                        baseLimit += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
                        baseLimit -= 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
            while (lastConsonant > baseLimit && !classTable->isConsonant(chars[lastConsonant])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
                lastConsonant -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   798
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   799
            IndicClassTable::CharClass charClass = CC_RESERVED;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   800
            IndicClassTable::CharClass nextClass = CC_RESERVED;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
            le_int32 baseConsonant = lastConsonant;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
            le_int32 postBase = lastConsonant + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
            le_int32 postBaseLimit = classTable->scriptFlags & SF_POST_BASE_LIMIT_MASK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
            le_bool  seenVattu = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
            le_bool  seenBelowBaseForm = FALSE;
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   806
            le_bool  seenPreBaseForm = FALSE;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   807
            le_bool  hasNukta = FALSE;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   808
            le_bool  hasBelowBaseForm = FALSE;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   809
            le_bool  hasPostBaseForm = FALSE;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   810
            le_bool  hasPreBaseForm = FALSE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
            if (postBase < markStart && classTable->isNukta(chars[postBase])) {
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   813
                charClass = CC_NUKTA;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
                postBase += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
            while (baseConsonant > baseLimit) {
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   818
                nextClass = charClass;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   819
                hasNukta  = IndicClassTable::isNukta(nextClass);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   820
                charClass = classTable->getCharClass(chars[baseConsonant]);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   821
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   822
                hasBelowBaseForm = IndicClassTable::hasBelowBaseForm(charClass) && !hasNukta;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   823
                hasPostBaseForm  = IndicClassTable::hasPostBaseForm(charClass)  && !hasNukta;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   824
                hasPreBaseForm = IndicClassTable::hasPreBaseForm(charClass) && !hasNukta;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
                if (IndicClassTable::isConsonant(charClass)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
                    if (postBaseLimit == 0 || seenVattu ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
                        (baseConsonant > baseLimit && !classTable->isVirama(chars[baseConsonant - 1])) ||
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   829
                        !(hasBelowBaseForm || hasPostBaseForm || hasPreBaseForm)) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
                        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   833
                    // Note any pre-base consonants
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   834
                    if ( baseConsonant == lastConsonant && lastConsonant > 0 &&
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   835
                         hasPreBaseForm && classTable->isVirama(chars[baseConsonant - 1])) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   836
                        output.notePreBaseConsonant(lastConsonant,chars[lastConsonant],chars[lastConsonant-1],tagArray2);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   837
                        seenPreBaseForm = TRUE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   839
                    }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   840
                    // consonants with nuktas are never vattus
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   841
                    seenVattu = IndicClassTable::isVattu(charClass) && !hasNukta;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   842
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   843
                    // consonants with nuktas never have below- or post-base forms
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   844
                    if (hasPostBaseForm) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
                        if (seenBelowBaseForm) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
                            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
                        postBase = baseConsonant;
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   850
                    } else if (hasBelowBaseForm) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
                        seenBelowBaseForm = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
                    postBaseLimit -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
                baseConsonant -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
            // Write Mpre
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
            output.writeMpre();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
            // Write eyelash RA
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
            // NOTE: baseLimit == prev + 3 iff eyelash RA present...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
            if (baseLimit == prev + 3) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
                output.writeChar(chars[prev], prev, tagArray2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
                output.writeChar(chars[prev + 1], prev + 1, tagArray2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
                output.writeChar(chars[prev + 2], prev + 2, tagArray2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
            // write any pre-base consonants
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   872
            output.writePreBaseConsonant();
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   873
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
            le_bool supressVattu = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
            for (i = baseLimit; i < baseConsonant; i += 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
                LEUnicode ch = chars[i];
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   878
                // Don't put 'pstf' or 'blwf' on anything before the base consonant.
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   879
                FeatureMask features = tagArray1 & ~( pstfFeatureMask | blwfFeatureMask );
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   880
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   881
                charClass = classTable->getCharClass(ch);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   882
                nextClass = classTable->getCharClass(chars[i + 1]);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   883
                hasNukta  = IndicClassTable::isNukta(nextClass);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
                if (IndicClassTable::isConsonant(charClass)) {
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   886
                    if (IndicClassTable::isVattu(charClass) && !hasNukta && supressVattu) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
                        features = tagArray4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   890
                    supressVattu = IndicClassTable::isVattu(charClass) && !hasNukta;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
                } else if (IndicClassTable::isVirama(charClass) && chars[i + 1] == C_SIGN_ZWNJ)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
                    features = tagArray4;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
                output.writeChar(ch, i, features);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
            le_int32 bcSpan = baseConsonant + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
            if (bcSpan < markStart && classTable->isNukta(chars[bcSpan])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
                bcSpan += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   905
            if (baseConsonant == lastConsonant && bcSpan < markStart &&
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   906
                 (classTable->isVirama(chars[bcSpan]) || classTable->isAlLakuna(chars[bcSpan]))) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
                bcSpan += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
                if (bcSpan < markStart && chars[bcSpan] == C_SIGN_ZWNJ) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
                    bcSpan += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
            // note the base consonant for post-GSUB fixups
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
            output.noteBaseConsonant();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
            // write base consonant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
            for (i = baseConsonant; i < bcSpan; i += 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
                output.writeChar(chars[i], i, tagArray4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
            if ((classTable->scriptFlags & SF_MATRAS_AFTER_BASE) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
                output.writeMbelow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
                output.writeSMbelow(); // FIXME: there are no SMs in these scripts...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
                output.writeMabove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
                output.writeMpost();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
            // write below-base consonants
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   930
            if (baseConsonant != lastConsonant && !seenPreBaseForm) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
                for (i = bcSpan + 1; i < postBase; i += 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
                    output.writeChar(chars[i], i, tagArray1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
                if (postBase > lastConsonant) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
                    // write halant that was after base consonant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
                    output.writeChar(chars[bcSpan], bcSpan, tagArray1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
            // write Mbelow, SMbelow, Mabove
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
            if ((classTable->scriptFlags & SF_MATRAS_AFTER_BASE) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
                output.writeMbelow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
                output.writeSMbelow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
                output.writeMabove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
            if ((classTable->scriptFlags & SF_REPH_AFTER_BELOW) != 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
                if (baseLimit == prev + 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
                    output.writeChar(chars[prev], prev, tagArray0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
                    output.writeChar(chars[prev + 1], prev + 1, tagArray0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
                output.writeVMabove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
                output.writeSMabove(); // FIXME: there are no SM's in these scripts...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
            // write post-base consonants
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
            // FIXME: does this put the right tags on post-base consonants?
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   960
            if (baseConsonant != lastConsonant && !seenPreBaseForm) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
                if (postBase <= lastConsonant) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
                    for (i = postBase; i <= lastConsonant; i += 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
                        output.writeChar(chars[i], i, tagArray3);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
                    // write halant that was after base consonant
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
                    output.writeChar(chars[bcSpan], bcSpan, tagArray1);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
                // write the training halant, if there is one
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
                if (lastConsonant < matra && classTable->isVirama(chars[matra])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
                    output.writeChar(chars[matra], matra, tagArray4);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
            // write Mpost
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
            if ((classTable->scriptFlags & SF_MATRAS_AFTER_BASE) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
                output.writeMpost();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
            output.writeLengthMark();
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
   982
            output.writeAlLakuna();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
            // write reph
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
            if ((classTable->scriptFlags & SF_REPH_AFTER_BELOW) == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
                if (baseLimit == prev + 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
                    output.writeChar(chars[prev], prev, tagArray0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
                    output.writeChar(chars[prev + 1], prev + 1, tagArray0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
                output.writeVMabove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
                output.writeSMabove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
            output.writeVMpost();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
        default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
            break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
        prev = syllable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
    *outMPreFixups = mpreFixups;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
    return output.getOutputIndex();
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1012
void IndicReordering::adjustMPres(MPreFixups *mpreFixups, LEGlyphStorage &glyphStorage, LEErrorCode& success)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
    if (mpreFixups != NULL) {
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1015
        mpreFixups->apply(glyphStorage, success);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
        delete mpreFixups;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
}
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
  1020
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1021
void IndicReordering::applyPresentationForms(LEGlyphStorage &glyphStorage, le_int32 count)
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1022
{
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1023
    LEErrorCode success = LE_NO_ERROR;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1024
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1025
//  This sets us up for 2nd pass of glyph substitution as well as setting the feature masks for the
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1026
//  GPOS table lookups
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1027
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1028
    for ( le_int32 i = 0 ; i < count ; i++ ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1029
        glyphStorage.setAuxData(i, ( presentationFormsMask | positioningFormsMask ), success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1030
    }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1031
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1032
}
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1033
void IndicReordering::finalReordering(LEGlyphStorage &glyphStorage, le_int32 count)
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1034
{
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1035
    LEErrorCode success = LE_NO_ERROR;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1036
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1037
    // Reposition REPH as appropriate
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1038
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1039
    for ( le_int32 i = 0 ; i < count ; i++ ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1040
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1041
        le_int32 tmpAuxData = glyphStorage.getAuxData(i,success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1042
        LEGlyphID tmpGlyph = glyphStorage.getGlyphID(i,success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1043
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1044
        if ( ( tmpGlyph != NO_GLYPH ) && (tmpAuxData & rephConsonantMask) && !(tmpAuxData & repositionedGlyphMask))  {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1045
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1046
            le_bool targetPositionFound = false;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1047
            le_int32 targetPosition = i+1;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1048
            le_int32 baseConsonantData;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1049
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1050
            while (!targetPositionFound) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1051
                tmpGlyph = glyphStorage.getGlyphID(targetPosition,success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1052
                tmpAuxData = glyphStorage.getAuxData(targetPosition,success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1053
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1054
                if ( tmpAuxData & baseConsonantMask ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1055
                    baseConsonantData = tmpAuxData;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1056
                    targetPositionFound = true;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1057
                } else {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1058
                    targetPosition++;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1059
                }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1060
            }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1061
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1062
            // Make sure we are not putting the reph into an empty hole
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1063
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1064
            le_bool targetPositionHasGlyph = false;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1065
            while (!targetPositionHasGlyph) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1066
                tmpGlyph = glyphStorage.getGlyphID(targetPosition,success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1067
                if ( tmpGlyph != NO_GLYPH ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1068
                    targetPositionHasGlyph = true;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1069
                } else {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1070
                    targetPosition--;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1071
                }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1072
            }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1073
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1074
            // Make sure that REPH is positioned after any above base or post base matras
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1075
            //
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1076
            le_bool checkMatraDone = false;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1077
            le_int32 checkMatraPosition = targetPosition+1;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1078
            while ( !checkMatraDone ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1079
               tmpAuxData = glyphStorage.getAuxData(checkMatraPosition,success);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1080
               if ( checkMatraPosition >= count || ( (tmpAuxData ^ baseConsonantData) & LE_GLYPH_GROUP_MASK)) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1081
                   checkMatraDone = true;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1082
                   continue;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1083
               }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1084
               if ( (tmpAuxData & matraMask) &&
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1085
                    (((tmpAuxData & markPositionMask) == aboveBasePosition) ||
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1086
                      ((tmpAuxData & markPositionMask) == postBasePosition))) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1087
                   targetPosition = checkMatraPosition;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1088
               }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1089
               checkMatraPosition++;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1090
            }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1091
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1092
            glyphStorage.moveGlyph(i,targetPosition,repositionedGlyphMask);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1093
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1094
    }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1095
}
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1096
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1097
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1098
le_int32 IndicReordering::v2process(const LEUnicode *chars, le_int32 charCount, le_int32 scriptCode,
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1099
                                  LEUnicode *outChars, LEGlyphStorage &glyphStorage)
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1100
{
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1101
    const IndicClassTable *classTable = IndicClassTable::getScriptClassTable(scriptCode);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1102
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1103
    DynamicProperties dynProps[INDIC_BLOCK_SIZE];
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1104
    IndicReordering::getDynamicProperties(dynProps,classTable);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1105
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1106
    IndicReorderingOutput output(outChars, glyphStorage, NULL);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1107
    le_int32 i, firstConsonant, baseConsonant, secondConsonant, inv_count = 0, beginSyllable = 0;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1108
    //le_bool lastInWord = FALSE;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1109
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1110
    while (beginSyllable < charCount) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1111
        le_int32 nextSyllable = findSyllable(classTable, chars, beginSyllable, charCount);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1112
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1113
        output.reset();
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1114
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1115
                // Find the First Consonant
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1116
                for ( firstConsonant = beginSyllable ; firstConsonant < nextSyllable ; firstConsonant++ ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1117
                         if ( classTable->isConsonant(chars[firstConsonant]) ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1118
                                        break;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1119
                                }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1120
                }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1121
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1122
        // Find the base consonant
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1123
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1124
        baseConsonant = nextSyllable - 1;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1125
        secondConsonant = firstConsonant;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1126
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1127
        // TODO: Use Dynamic Properties for hasBelowBaseForm and hasPostBaseForm()
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1128
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1129
        while ( baseConsonant > firstConsonant ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1130
            if ( classTable->isConsonant(chars[baseConsonant]) &&
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1131
                 !classTable->hasBelowBaseForm(chars[baseConsonant]) &&
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1132
                 !classTable->hasPostBaseForm(chars[baseConsonant]) ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1133
                break;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1134
            }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1135
            else {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1136
                if ( classTable->isConsonant(chars[baseConsonant]) ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1137
                    secondConsonant = baseConsonant;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1138
                }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1139
                baseConsonant--;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1140
            }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1141
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1142
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1143
        // If the syllable starts with Ra + Halant ( in a script that has Reph ) and has more than one
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1144
        // consonant, Ra is excluced from candidates for base consonants
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1145
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1146
        if ( classTable->isReph(chars[beginSyllable]) &&
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1147
             beginSyllable+1 < nextSyllable && classTable->isVirama(chars[beginSyllable+1]) &&
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1148
             secondConsonant != firstConsonant) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1149
            baseConsonant = secondConsonant;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1150
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1151
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1152
            // Populate the output
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1153
                for ( i = beginSyllable ; i < nextSyllable ; i++ ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1154
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1155
            // Handle invalid combinartions
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1156
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1157
            if ( classTable->isVirama(chars[beginSyllable]) ||
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1158
                             classTable->isMatra(chars[beginSyllable]) ||
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1159
                             classTable->isVowelModifier(chars[beginSyllable]) ||
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1160
                             classTable->isNukta(chars[beginSyllable]) ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1161
                     output.writeChar(C_DOTTED_CIRCLE,beginSyllable,basicShapingFormsMask);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1162
                     inv_count++;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1163
            }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1164
             output.writeChar(chars[i],i, basicShapingFormsMask);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1165
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1166
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1167
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1168
        // Adjust features and set syllable structure bits
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1169
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1170
        for ( i = beginSyllable ; i < nextSyllable ; i++ ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1171
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1172
            FeatureMask outMask = output.getFeatures(i+inv_count);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1173
            FeatureMask saveMask = outMask;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1174
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1175
            // Since reph can only validly occur at the beginning of a syllable
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1176
            // We only apply it to the first 2 characters in the syllable, to keep it from
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1177
            // conflicting with other features ( i.e. rkrf )
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1178
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1179
            // TODO : Use the dynamic property for determining isREPH
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1180
            if ( i == beginSyllable && i < baseConsonant && classTable->isReph(chars[i]) &&
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1181
                 i+1 < nextSyllable && classTable->isVirama(chars[i+1])) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1182
                outMask |= rphfFeatureMask;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1183
                outMask |= rephConsonantMask;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1184
                output.setFeatures(i+1+inv_count,outMask);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1185
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1186
            }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1187
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1188
            if ( i == baseConsonant ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1189
                outMask |= baseConsonantMask;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1190
            }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1191
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1192
            if ( classTable->isMatra(chars[i])) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1193
                    outMask |= matraMask;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1194
                    if ( classTable->hasAboveBaseForm(chars[i])) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1195
                        outMask |= aboveBasePosition;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1196
                    } else if ( classTable->hasBelowBaseForm(chars[i])) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1197
                        outMask |= belowBasePosition;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1198
                    }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1199
            }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1200
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1201
            // Don't apply half form to virama that stands alone at the end of a syllable
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1202
            // to prevent half forms from forming when syllable ends with virama
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1203
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1204
            if ( classTable->isVirama(chars[i]) && (i+1 == nextSyllable) ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1205
                outMask ^= halfFeatureMask;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1206
                if ( classTable->isConsonant(chars[i-1]) ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1207
                    FeatureMask tmp = output.getFeatures(i-1+inv_count);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1208
                    tmp ^= halfFeatureMask;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1209
                    output.setFeatures(i-1+inv_count,tmp);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1210
                }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1211
            }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1212
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1213
            if ( outMask != saveMask ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1214
                output.setFeatures(i+inv_count,outMask);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1215
            }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1216
                }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1217
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1218
            output.decomposeReorderMatras(classTable,beginSyllable,nextSyllable,inv_count);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1219
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1220
        beginSyllable = nextSyllable;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1221
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1222
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1223
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1224
    return output.getOutputIndex();
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1225
}
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1226
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1227
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1228
void IndicReordering::getDynamicProperties( DynamicProperties *, const IndicClassTable *classTable ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1229
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1230
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1231
    LEUnicode currentChar;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1232
    LEUnicode workChars[2];
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1233
    LEGlyphStorage workGlyphs;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1234
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1235
    IndicReorderingOutput workOutput(workChars, workGlyphs, NULL);
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1236
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1237
    //le_int32 offset = 0;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1238
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 7486
diff changeset
  1239
#if 0
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 7486
diff changeset
  1240
// TODO:  Should this section of code have actually been doing something?
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1241
    // First find the relevant virama for the script we are dealing with
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 7486
diff changeset
  1242
    LEUnicode virama;
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1243
    for ( currentChar = classTable->firstChar ; currentChar <= classTable->lastChar ; currentChar++ ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1244
        if ( classTable->isVirama(currentChar)) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1245
            virama = currentChar;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1246
            break;
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1247
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1248
    }
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents: 7486
diff changeset
  1249
#endif
7486
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1250
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1251
    for ( currentChar = classTable->firstChar ; currentChar <= classTable->lastChar ; currentChar++ ) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1252
        if ( classTable->isConsonant(currentChar)) {
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1253
            workOutput.reset();
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1254
        }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1255
    }
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1256
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1257
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1258
}
6a36b1ebc620 6886358: layout code update
srl
parents: 5506
diff changeset
  1259
3935
afcdb712a9c5 6501644: sync LayoutEngine *code* structure to match ICU
srl
parents: 2
diff changeset
  1260
U_NAMESPACE_END