jdk/src/share/native/sun/font/layout/StateTableProcessor2.cpp
author prr
Thu, 07 Mar 2013 10:02:20 -0800
changeset 16891 91e99bed64ae
parent 16890 36b30720a997
permissions -rw-r--r--
8001031: Better font processing Reviewed-by: srl, vadim
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
     1
/*
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
     2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
     3
 *
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
     4
 * This code is free software; you can redistribute it and/or modify it
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
     5
 * under the terms of the GNU General Public License version 2 only, as
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
     6
 * published by the Free Software Foundation.  Oracle designates this
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
     7
 * particular file as subject to the "Classpath" exception as provided
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
     8
 * by Oracle in the LICENSE file that accompanied this code.
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
     9
 *
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    14
 * accompanied this code).
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    15
 *
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    19
 *
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    22
 * questions.
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    23
 *
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    24
 */
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    25
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    26
/*
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    27
 *
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    28
 * (C) Copyright IBM Corp.  and others 1998-2013 - All Rights Reserved
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    29
 *
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    30
 */
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    31
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    32
#include "LETypes.h"
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    33
#include "MorphTables.h"
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    34
#include "StateTables.h"
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    35
#include "MorphStateTables.h"
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    36
#include "SubtableProcessor2.h"
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    37
#include "StateTableProcessor2.h"
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    38
#include "LEGlyphStorage.h"
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    39
#include "LESwaps.h"
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    40
#include "LookupTables.h"
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    41
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    42
U_NAMESPACE_BEGIN
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    43
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    44
StateTableProcessor2::StateTableProcessor2()
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    45
{
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    46
}
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    47
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
    48
StateTableProcessor2::StateTableProcessor2(const LEReferenceTo<MorphSubtableHeader2> &morphSubtableHeader, LEErrorCode &success)
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
    49
  : SubtableProcessor2(morphSubtableHeader, success), stateTableHeader(morphSubtableHeader, success),
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
    50
    stHeader(stateTableHeader, success, (const StateTableHeader2*)&stateTableHeader->stHeader),
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
    51
    nClasses(0), classTableOffset(0), stateArrayOffset(0), entryTableOffset(0), classTable(), format(0),
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
    52
    stateArray()
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    53
{
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
    54
  if (LE_FAILURE(success)) {
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
    55
    return;
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
    56
  }
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
    57
  nClasses = SWAPL(stHeader->nClasses);
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
    58
  classTableOffset = SWAPL(stHeader->classTableOffset);
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
    59
  stateArrayOffset = SWAPL(stHeader->stateArrayOffset);
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
    60
  entryTableOffset = SWAPL(stHeader->entryTableOffset);
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    61
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
    62
  classTable = LEReferenceTo<LookupTable>(stHeader, success, classTableOffset);
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
    63
  format = SWAPW(classTable->format);
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    64
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
    65
  stateArray = LEReferenceToArrayOf<EntryTableIndex2>(stHeader, success, stateArrayOffset, LE_UNBOUNDED_ARRAY);
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    66
}
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    67
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    68
StateTableProcessor2::~StateTableProcessor2()
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    69
{
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    70
}
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    71
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
    72
void StateTableProcessor2::process(LEGlyphStorage &glyphStorage, LEErrorCode &success)
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    73
{
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
    74
    if (LE_FAILURE(success)) return;
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    75
    // Start at state 0
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    76
    // XXX: How do we know when to start at state 1?
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    77
    le_uint16 currentState = 0;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    78
    le_int32 glyphCount = glyphStorage.getGlyphCount();
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    79
16890
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    80
    LE_STATE_PATIENCE_INIT();
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    81
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    82
    le_int32 currGlyph = 0;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    83
    if ((coverage & scfReverse2) != 0) {  // process glyphs in descending order
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    84
        currGlyph = glyphCount - 1;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    85
        dir = -1;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    86
    } else {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    87
        dir = 1;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    88
    }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    89
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    90
    beginStateTable();
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    91
    switch (format) {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    92
        case ltfSimpleArray: {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    93
#ifdef TEST_FORMAT
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
    94
          LEReferenceTo<SimpleArrayLookupTable> lookupTable0(classTable, success);
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
    95
          if(LE_FAILURE(success)) break;
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
    96
            while ((dir == 1 && currGlyph <= glyphCount) || (dir == -1 && currGlyph >= -1)) {
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
    97
                if (LE_FAILURE(success)) break;
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
    98
                if (LE_STATE_PATIENCE_DECR()) {
16890
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
    99
                  LE_DEBUG_BAD_FONT("patience exceeded - state table not moving")
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   100
                  break; // patience exceeded.
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   101
                }
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   102
                LookupValue classCode = classCodeOOB;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   103
                if (currGlyph == glyphCount || currGlyph == -1) {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   104
                    // XXX: How do we handle EOT vs. EOL?
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   105
                    classCode = classCodeEOT;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   106
                } else {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   107
                    LEGlyphID gid = glyphStorage[currGlyph];
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   108
                    TTGlyphID glyphCode = (TTGlyphID) LE_GET_GLYPH(gid);
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   109
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   110
                    if (glyphCode == 0xFFFF) {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   111
                        classCode = classCodeDEL;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   112
                    } else {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   113
                        classCode = SWAPW(lookupTable0->valueArray[gid]);
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   114
                    }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   115
                }
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   116
                EntryTableIndex2 entryTableIndex = SWAPW(stateArray(classCode + currentState * nClasses, success));
16890
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   117
                LE_STATE_PATIENCE_CURR(le_int32, currGlyph);
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   118
                currentState = processStateEntry(glyphStorage, currGlyph, entryTableIndex); // return a zero-based index instead of a byte offset
16890
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   119
                LE_STATE_PATIENCE_INCR(currGlyph);
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   120
            }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   121
#endif
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   122
            break;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   123
        }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   124
        case ltfSegmentSingle: {
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   125
          LEReferenceTo<SegmentSingleLookupTable> lookupTable2(classTable, success);
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   126
          if(LE_FAILURE(success)) break;
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   127
            while ((dir == 1 && currGlyph <= glyphCount) || (dir == -1 && currGlyph >= -1)) {
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   128
                if (LE_FAILURE(success)) break;
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   129
                if (LE_STATE_PATIENCE_DECR()) {
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   130
                  LE_DEBUG_BAD_FONT("patience exceeded  - state table not moving")
16890
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   131
                  break; // patience exceeded.
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   132
                }
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   133
                LookupValue classCode = classCodeOOB;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   134
                if (currGlyph == glyphCount || currGlyph == -1) {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   135
                    // XXX: How do we handle EOT vs. EOL?
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   136
                    classCode = classCodeEOT;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   137
                } else {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   138
                    LEGlyphID gid = glyphStorage[currGlyph];
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   139
                    TTGlyphID glyphCode = (TTGlyphID) LE_GET_GLYPH(gid);
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   140
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   141
                    if (glyphCode == 0xFFFF) {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   142
                        classCode = classCodeDEL;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   143
                    } else {
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   144
                      const LookupSegment *segment =
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   145
                        lookupTable2->lookupSegment(lookupTable2, lookupTable2->segments, gid, success);
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   146
                        if (segment != NULL && LE_SUCCESS(success)) {
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   147
                            classCode = SWAPW(segment->value);
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   148
                        }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   149
                    }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   150
                }
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   151
                EntryTableIndex2 entryTableIndex = SWAPW(stateArray(classCode + currentState * nClasses,success));
16890
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   152
                LE_STATE_PATIENCE_CURR(le_int32, currGlyph);
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   153
                currentState = processStateEntry(glyphStorage, currGlyph, entryTableIndex, success);
16890
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   154
                LE_STATE_PATIENCE_INCR(currGlyph);
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   155
            }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   156
            break;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   157
        }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   158
        case ltfSegmentArray: {
16890
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   159
          //printf("Lookup Table Format4: specific interpretation needed!\n");
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   160
            break;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   161
        }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   162
        case ltfSingleTable: {
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   163
            LEReferenceTo<SingleTableLookupTable> lookupTable6(classTable, success);
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   164
            while ((dir == 1 && currGlyph <= glyphCount) || (dir == -1 && currGlyph >= -1)) {
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   165
                if (LE_FAILURE(success)) break;
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   166
                if (LE_STATE_PATIENCE_DECR()) {
16890
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   167
                  LE_DEBUG_BAD_FONT("patience exceeded - state table not moving")
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   168
                  break; // patience exceeded.
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   169
                }
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   170
                LookupValue classCode = classCodeOOB;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   171
                if (currGlyph == glyphCount || currGlyph == -1) {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   172
                    // XXX: How do we handle EOT vs. EOL?
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   173
                    classCode = classCodeEOT;
16890
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   174
                } else if(currGlyph > glyphCount) {
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   175
                  // note if > glyphCount, we've run off the end (bad font)
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   176
                  currGlyph = glyphCount;
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   177
                  classCode = classCodeEOT;
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   178
                } else {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   179
                    LEGlyphID gid = glyphStorage[currGlyph];
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   180
                    TTGlyphID glyphCode = (TTGlyphID) LE_GET_GLYPH(gid);
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   181
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   182
                    if (glyphCode == 0xFFFF) {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   183
                        classCode = classCodeDEL;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   184
                    } else {
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   185
                      const LookupSingle *segment = lookupTable6->lookupSingle(lookupTable6, lookupTable6->entries, gid, success);
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   186
                        if (segment != NULL) {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   187
                            classCode = SWAPW(segment->value);
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   188
                        }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   189
                    }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   190
                }
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   191
                EntryTableIndex2 entryTableIndex = SWAPW(stateArray(classCode + currentState * nClasses, success));
16890
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   192
                LE_STATE_PATIENCE_CURR(le_int32, currGlyph);
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   193
                currentState = processStateEntry(glyphStorage, currGlyph, entryTableIndex, success);
16890
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   194
                LE_STATE_PATIENCE_INCR(currGlyph);
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   195
            }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   196
            break;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   197
        }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   198
        case ltfTrimmedArray: {
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   199
            LEReferenceTo<TrimmedArrayLookupTable> lookupTable8(classTable, success);
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   200
            if (LE_FAILURE(success)) break;
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   201
            TTGlyphID firstGlyph = SWAPW(lookupTable8->firstGlyph);
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   202
            TTGlyphID lastGlyph  = firstGlyph + SWAPW(lookupTable8->glyphCount);
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   203
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   204
            while ((dir == 1 && currGlyph <= glyphCount) || (dir == -1 && currGlyph >= -1)) {
16890
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   205
                if(LE_STATE_PATIENCE_DECR()) {
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   206
                  LE_DEBUG_BAD_FONT("patience exceeded - state table not moving")
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   207
                  break; // patience exceeded.
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   208
                }
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   209
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   210
                LookupValue classCode = classCodeOOB;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   211
                if (currGlyph == glyphCount || currGlyph == -1) {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   212
                    // XXX: How do we handle EOT vs. EOL?
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   213
                    classCode = classCodeEOT;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   214
                } else {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   215
                    TTGlyphID glyphCode = (TTGlyphID) LE_GET_GLYPH(glyphStorage[currGlyph]);
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   216
                    if (glyphCode == 0xFFFF) {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   217
                        classCode = classCodeDEL;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   218
                    } else if ((glyphCode >= firstGlyph) && (glyphCode < lastGlyph)) {
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   219
                        classCode = SWAPW(lookupTable8->valueArray[glyphCode - firstGlyph]);
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   220
                    }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   221
                }
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   222
                EntryTableIndex2 entryTableIndex = SWAPW(stateArray(classCode + currentState * nClasses, success));
16890
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   223
                LE_STATE_PATIENCE_CURR(le_int32, currGlyph);
16891
91e99bed64ae 8001031: Better font processing
prr
parents: 16890
diff changeset
   224
                currentState = processStateEntry(glyphStorage, currGlyph, entryTableIndex, success);
16890
36b30720a997 8004986: Better handling of glyph table
prr
parents: 16889
diff changeset
   225
                LE_STATE_PATIENCE_INCR(currGlyph);
16889
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   226
            }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   227
            break;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   228
        }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   229
        default:
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   230
            break;
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   231
    }
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   232
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   233
    endStateTable();
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   234
}
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   235
3df90f344221 8008249: Sync ICU into JDK
prr
parents:
diff changeset
   236
U_NAMESPACE_END