X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/374ca955a76ecab1204ca8bfa63ff9238d998416..b801cf366c7671a99bdcef84d1e9c0ec64b36723:/icuSources/layout/ContextualGlyphSubstProc.cpp?ds=sidebyside diff --git a/icuSources/layout/ContextualGlyphSubstProc.cpp b/icuSources/layout/ContextualGlyphSubstProc.cpp index 94c4a60b..4884710d 100644 --- a/icuSources/layout/ContextualGlyphSubstProc.cpp +++ b/icuSources/layout/ContextualGlyphSubstProc.cpp @@ -1,6 +1,6 @@ /* * - * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved + * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved * */ @@ -18,13 +18,18 @@ U_NAMESPACE_BEGIN UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ContextualGlyphSubstitutionProcessor) -ContextualGlyphSubstitutionProcessor::ContextualGlyphSubstitutionProcessor(const MorphSubtableHeader *morphSubtableHeader) - : StateTableProcessor(morphSubtableHeader) +ContextualGlyphSubstitutionProcessor::ContextualGlyphSubstitutionProcessor(const LEReferenceTo &morphSubtableHeader, LEErrorCode &success) + : StateTableProcessor(morphSubtableHeader, success), entryTable(), contextualGlyphSubstitutionHeader(morphSubtableHeader, success) { - contextualGlyphSubstitutionHeader = (const ContextualGlyphSubstitutionHeader *) morphSubtableHeader; - substitutionTableOffset = SWAPW(contextualGlyphSubstitutionHeader->substitutionTableOffset); - - entryTable = (const ContextualGlyphSubstitutionStateEntry *) ((char *) &stateTableHeader->stHeader + entryTableOffset); + contextualGlyphSubstitutionHeader.orphan(); + substitutionTableOffset = SWAPW(contextualGlyphSubstitutionHeader->substitutionTableOffset); + + + entryTable = LEReferenceToArrayOf(stateTableHeader, success, + (const ContextualGlyphSubstitutionStateEntry*)(&stateTableHeader->stHeader), + entryTableOffset, LE_UNBOUNDED_ARRAY); + int16Table = LEReferenceToArrayOf(stateTableHeader, success, (const le_int16*)(&stateTableHeader->stHeader), + 0, LE_UNBOUNDED_ARRAY); // rest of the table as le_int16s } ContextualGlyphSubstitutionProcessor::~ContextualGlyphSubstitutionProcessor() @@ -38,27 +43,26 @@ void ContextualGlyphSubstitutionProcessor::beginStateTable() ByteOffset ContextualGlyphSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index) { - const ContextualGlyphSubstitutionStateEntry *entry = &entryTable[index]; - ByteOffset newState = SWAPW(entry->newStateOffset); - le_int16 flags = SWAPW(entry->flags); - WordOffset markOffset = SWAPW(entry->markOffset); - WordOffset currOffset = SWAPW(entry->currOffset); - - if (markOffset != 0) { - const le_int16 *table = (const le_int16 *) ((char *) &stateTableHeader->stHeader + markOffset * 2); - LEGlyphID mGlyph = glyphStorage[markGlyph]; - TTGlyphID newGlyph = SWAPW(table[LE_GET_GLYPH(mGlyph)]); - - glyphStorage[markGlyph] = LE_SET_GLYPH(mGlyph, newGlyph); - } - - if (currOffset != 0) { - const le_int16 *table = (const le_int16 *) ((char *) &stateTableHeader->stHeader + currOffset * 2); - LEGlyphID thisGlyph = glyphStorage[currGlyph]; - TTGlyphID newGlyph = SWAPW(table[LE_GET_GLYPH(thisGlyph)]); - - glyphStorage[currGlyph] = LE_SET_GLYPH(thisGlyph, newGlyph); - } + LEErrorCode success = LE_NO_ERROR; + const ContextualGlyphSubstitutionStateEntry *entry = entryTable.getAlias(index, success); + ByteOffset newState = SWAPW(entry->newStateOffset); + le_int16 flags = SWAPW(entry->flags); + WordOffset markOffset = SWAPW(entry->markOffset); + WordOffset currOffset = SWAPW(entry->currOffset); + + if (markOffset != 0 && LE_SUCCESS(success)) { + LEGlyphID mGlyph = glyphStorage[markGlyph]; + TTGlyphID newGlyph = SWAPW(int16Table.getObject(markOffset + LE_GET_GLYPH(mGlyph), success)); // whew. + + glyphStorage[markGlyph] = LE_SET_GLYPH(mGlyph, newGlyph); + } + + if (currOffset != 0) { + LEGlyphID thisGlyph = glyphStorage[currGlyph]; + TTGlyphID newGlyph = SWAPW(int16Table.getObject(currOffset + LE_GET_GLYPH(thisGlyph), success)); // whew. + + glyphStorage[currGlyph] = LE_SET_GLYPH(thisGlyph, newGlyph); + } if (flags & cgsSetMark) { markGlyph = currGlyph;