jdk/src/share/native/sun/font/layout/IndicRearrangementProcessor.cpp
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 3935 afcdb712a9c5
permissions -rw-r--r--
Initial load
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * have any questions.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
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 "MorphTables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "StateTables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
#include "MorphStateTables.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
#include "SubtableProcessor.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#include "StateTableProcessor.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include "IndicRearrangementProcessor.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#include "LEGlyphStorage.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#include "LESwaps.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
IndicRearrangementProcessor::IndicRearrangementProcessor(const MorphSubtableHeader *morphSubtableHeader)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
  : StateTableProcessor(morphSubtableHeader)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    indicRearrangementSubtableHeader = (const IndicRearrangementSubtableHeader *) morphSubtableHeader;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    entryTable = (const IndicRearrangementStateEntry *) ((char *) &stateTableHeader->stHeader + entryTableOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
IndicRearrangementProcessor::~IndicRearrangementProcessor()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
void IndicRearrangementProcessor::beginStateTable()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    firstGlyph = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    lastGlyph = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
ByteOffset IndicRearrangementProcessor::processStateEntry(LEGlyphStorage &glyphStorage,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    le_int32 &currGlyph, EntryTableIndex index)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    const IndicRearrangementStateEntry *entry = &entryTable[index];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    ByteOffset newState = SWAPW(entry->newStateOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    IndicRearrangementFlags flags = (IndicRearrangementFlags) SWAPW(entry->flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    if (flags & irfMarkFirst) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
        firstGlyph = currGlyph;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    if (flags & irfMarkLast) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        lastGlyph = currGlyph;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    doRearrangementAction(glyphStorage, (IndicRearrangementVerb) (flags & irfVerbMask));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    if (!(flags & irfDontAdvance)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        // XXX: Should handle reverse too...
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
        currGlyph += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    return newState;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
void IndicRearrangementProcessor::endStateTable()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
void IndicRearrangementProcessor::doRearrangementAction(LEGlyphStorage &glyphStorage, IndicRearrangementVerb verb) const
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    LEGlyphID a, b, c, d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    le_int32 ia, ib, ic, id, ix, x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    LEErrorCode success = LE_NO_ERROR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    switch(verb)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    case irvNoAction:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    case irvxA:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        a = glyphStorage[firstGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        ia = glyphStorage.getCharIndex(firstGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        x = firstGlyph + 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        while (x <= lastGlyph) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            glyphStorage[x - 1] = glyphStorage[x];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            ix = glyphStorage.getCharIndex(x, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
            glyphStorage.setCharIndex(x - 1, ix, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            x += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        glyphStorage[lastGlyph] = a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        glyphStorage.setCharIndex(lastGlyph, ia, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    case irvDx:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
        d = glyphStorage[lastGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        id = glyphStorage.getCharIndex(lastGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        x = lastGlyph - 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        while (x >= firstGlyph) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
            glyphStorage[x + 1] = glyphStorage[x];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            ix = glyphStorage.getCharIndex(x, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
            glyphStorage.setCharIndex(x + 1, ix, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
            x -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
        glyphStorage[firstGlyph] = d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        glyphStorage.setCharIndex(firstGlyph, id, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    case irvDxA:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        a = glyphStorage[firstGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        ia = glyphStorage.getCharIndex(firstGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
        id = glyphStorage.getCharIndex(lastGlyph,  success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        glyphStorage[firstGlyph] = glyphStorage[lastGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        glyphStorage[lastGlyph] = a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        glyphStorage.setCharIndex(firstGlyph, id, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
        glyphStorage.setCharIndex(lastGlyph,  ia, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    case irvxAB:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        a = glyphStorage[firstGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        b = glyphStorage[firstGlyph + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        ia = glyphStorage.getCharIndex(firstGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        ib = glyphStorage.getCharIndex(firstGlyph + 1, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        x = firstGlyph + 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        while (x <= lastGlyph) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            glyphStorage[x - 2] = glyphStorage[x];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            ix = glyphStorage.getCharIndex(x, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            glyphStorage.setCharIndex(x - 2, ix, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            x += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
        glyphStorage[lastGlyph - 1] = a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        glyphStorage[lastGlyph] = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        glyphStorage.setCharIndex(lastGlyph - 1, ia, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        glyphStorage.setCharIndex(lastGlyph, ib, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    case irvxBA:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        a = glyphStorage[firstGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
        b = glyphStorage[firstGlyph + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        ia = glyphStorage.getCharIndex(firstGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
        ib = glyphStorage.getCharIndex(firstGlyph + 1, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        x = firstGlyph + 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
        while (x <= lastGlyph) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            glyphStorage[x - 2] = glyphStorage[x];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            ix = glyphStorage.getCharIndex(x, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            glyphStorage.setCharIndex(x - 2, ix, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            x += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        glyphStorage[lastGlyph - 1] = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        glyphStorage[lastGlyph] = a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        glyphStorage.setCharIndex(lastGlyph - 1, ib, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        glyphStorage.setCharIndex(lastGlyph, ia, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    case irvCDx:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
        c = glyphStorage[lastGlyph - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        d = glyphStorage[lastGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
        ic = glyphStorage.getCharIndex(lastGlyph - 1, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        id = glyphStorage.getCharIndex(lastGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        x = lastGlyph - 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
        while (x >= firstGlyph) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            glyphStorage[x + 2] = glyphStorage[x];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            ix = glyphStorage.getCharIndex(x, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
            glyphStorage.setCharIndex(x + 2, ix, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            x -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        glyphStorage[firstGlyph] = c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        glyphStorage[firstGlyph + 1] = d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        glyphStorage.setCharIndex(firstGlyph, ic, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        glyphStorage.setCharIndex(firstGlyph + 1, id, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    case irvDCx:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        c = glyphStorage[lastGlyph - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
        d = glyphStorage[lastGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        ic = glyphStorage.getCharIndex(lastGlyph - 1, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        id = glyphStorage.getCharIndex(lastGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        x = lastGlyph - 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        while (x >= firstGlyph) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            glyphStorage[x + 2] = glyphStorage[x];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            ix = glyphStorage.getCharIndex(x, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
            glyphStorage.setCharIndex(x + 2, ix, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            x -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        glyphStorage[firstGlyph] = d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        glyphStorage[firstGlyph + 1] = c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        glyphStorage.setCharIndex(firstGlyph, id, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        glyphStorage.setCharIndex(firstGlyph + 1, ic, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    case irvCDxA:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        a = glyphStorage[firstGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        c = glyphStorage[lastGlyph - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
        d = glyphStorage[lastGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        ia = glyphStorage.getCharIndex(firstGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
        ic = glyphStorage.getCharIndex(lastGlyph - 1, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        id = glyphStorage.getCharIndex(lastGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        x = lastGlyph - 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        while (x > firstGlyph) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            glyphStorage[x + 1] = glyphStorage[x];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            ix = glyphStorage.getCharIndex(x, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
            glyphStorage.setCharIndex(x + 1, ix, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            x -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        glyphStorage[firstGlyph] = c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        glyphStorage[firstGlyph + 1] = d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        glyphStorage[lastGlyph] = a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        glyphStorage.setCharIndex(firstGlyph, ic, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        glyphStorage.setCharIndex(firstGlyph + 1, id, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        glyphStorage.setCharIndex(lastGlyph, ia, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    case irvDCxA:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        a = glyphStorage[firstGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        c = glyphStorage[lastGlyph - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        d = glyphStorage[lastGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        ia = glyphStorage.getCharIndex(firstGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        ic = glyphStorage.getCharIndex(lastGlyph - 1, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        id = glyphStorage.getCharIndex(lastGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        x = lastGlyph - 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        while (x > firstGlyph) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            glyphStorage[x + 1] = glyphStorage[x];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            ix = glyphStorage.getCharIndex(x, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            glyphStorage.setCharIndex(x + 1, ix, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            x -= 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        glyphStorage[firstGlyph] = d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        glyphStorage[firstGlyph + 1] = c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
        glyphStorage[lastGlyph] = a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        glyphStorage.setCharIndex(firstGlyph, id, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        glyphStorage.setCharIndex(firstGlyph + 1, ic, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        glyphStorage.setCharIndex(lastGlyph, ia, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    case irvDxAB:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        a = glyphStorage[firstGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        b = glyphStorage[firstGlyph + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        d = glyphStorage[lastGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        ia = glyphStorage.getCharIndex(firstGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        ib = glyphStorage.getCharIndex(firstGlyph + 1, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        id = glyphStorage.getCharIndex(lastGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        x = firstGlyph + 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
        while (x < lastGlyph) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
            glyphStorage[x - 2] = glyphStorage[x];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            ix = glyphStorage.getCharIndex(x, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
            glyphStorage.setCharIndex(x - 2, ix, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
            x += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
        glyphStorage[firstGlyph] = d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        glyphStorage[lastGlyph - 1] = a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        glyphStorage[lastGlyph] = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        glyphStorage.setCharIndex(firstGlyph, id, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        glyphStorage.setCharIndex(lastGlyph - 1, ia, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
        glyphStorage.setCharIndex(lastGlyph, ib, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    case irvDxBA:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        a = glyphStorage[firstGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        b = glyphStorage[firstGlyph + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        d = glyphStorage[lastGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        ia = glyphStorage.getCharIndex(firstGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        ib = glyphStorage.getCharIndex(firstGlyph + 1, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        id = glyphStorage.getCharIndex(lastGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        x = firstGlyph + 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        while (x < lastGlyph) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            glyphStorage[x - 2] = glyphStorage[x];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            ix = glyphStorage.getCharIndex(x, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            glyphStorage.setCharIndex(x - 2, ix, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            x += 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
        glyphStorage[firstGlyph] = d;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        glyphStorage[lastGlyph - 1] = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        glyphStorage[lastGlyph] = a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        glyphStorage.setCharIndex(firstGlyph, id, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
        glyphStorage.setCharIndex(lastGlyph - 1, ib, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        glyphStorage.setCharIndex(lastGlyph, ia, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    case irvCDxAB:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        a = glyphStorage[firstGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        b = glyphStorage[firstGlyph + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        glyphStorage[firstGlyph] = glyphStorage[lastGlyph - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
        glyphStorage[firstGlyph + 1] = glyphStorage[lastGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        glyphStorage[lastGlyph - 1] = a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        glyphStorage[lastGlyph] = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        ia = glyphStorage.getCharIndex(firstGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        ib = glyphStorage.getCharIndex(firstGlyph + 1, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        ic = glyphStorage.getCharIndex(lastGlyph - 1, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
        id = glyphStorage.getCharIndex(lastGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        glyphStorage.setCharIndex(firstGlyph, ic, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        glyphStorage.setCharIndex(firstGlyph + 1, id, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        glyphStorage.setCharIndex(lastGlyph - 1, ia, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
        glyphStorage.setCharIndex(lastGlyph, ib, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    case irvCDxBA:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
        a = glyphStorage[firstGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
        b = glyphStorage[firstGlyph + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        glyphStorage[firstGlyph] = glyphStorage[lastGlyph - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        glyphStorage[firstGlyph + 1] = glyphStorage[lastGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        glyphStorage[lastGlyph - 1] = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
        glyphStorage[lastGlyph] = a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
        ia = glyphStorage.getCharIndex(firstGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        ib = glyphStorage.getCharIndex(firstGlyph + 1, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
        ic = glyphStorage.getCharIndex(lastGlyph - 1, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
        id = glyphStorage.getCharIndex(lastGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        glyphStorage.setCharIndex(firstGlyph, ic, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
        glyphStorage.setCharIndex(firstGlyph + 1, id, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        glyphStorage.setCharIndex(lastGlyph - 1, ib, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        glyphStorage.setCharIndex(lastGlyph, ia, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    case irvDCxAB:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        a = glyphStorage[firstGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        b = glyphStorage[firstGlyph + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        glyphStorage[firstGlyph] = glyphStorage[lastGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        glyphStorage[firstGlyph + 1] = glyphStorage[lastGlyph - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        glyphStorage[lastGlyph - 1] = a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        glyphStorage[lastGlyph] = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
        ia = glyphStorage.getCharIndex(firstGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        ib = glyphStorage.getCharIndex(firstGlyph + 1, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        ic = glyphStorage.getCharIndex(lastGlyph - 1, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        id = glyphStorage.getCharIndex(lastGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
        glyphStorage.setCharIndex(firstGlyph, id, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        glyphStorage.setCharIndex(firstGlyph + 1, ic, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        glyphStorage.setCharIndex(lastGlyph - 1, ia, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        glyphStorage.setCharIndex(lastGlyph, ib, success);
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
    case irvDCxBA:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        a = glyphStorage[firstGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
        b = glyphStorage[firstGlyph + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        glyphStorage[firstGlyph] = glyphStorage[lastGlyph];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
        glyphStorage[firstGlyph + 1] = glyphStorage[lastGlyph - 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
        glyphStorage[lastGlyph - 1] = b;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        glyphStorage[lastGlyph] = a;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
        ia = glyphStorage.getCharIndex(firstGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        ib = glyphStorage.getCharIndex(firstGlyph + 1, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
        ic = glyphStorage.getCharIndex(lastGlyph - 1, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
        id = glyphStorage.getCharIndex(lastGlyph, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
        glyphStorage.setCharIndex(firstGlyph, id, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
        glyphStorage.setCharIndex(firstGlyph + 1, ic, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        glyphStorage.setCharIndex(lastGlyph - 1, ib, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
        glyphStorage.setCharIndex(lastGlyph, ia, success);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
    default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
}