os/textandloc/fontservices/textshaperplugin/IcuSource/layout/ContextualGlyphSubstProc.cpp
Update contrib.
3 * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
8 #include "MorphTables.h"
9 #include "StateTables.h"
10 #include "MorphStateTables.h"
11 #include "SubtableProcessor.h"
12 #include "StateTableProcessor.h"
13 #include "ContextualGlyphSubstProc.h"
14 #include "LEGlyphStorage.h"
19 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ContextualGlyphSubstitutionProcessor)
21 ContextualGlyphSubstitutionProcessor::ContextualGlyphSubstitutionProcessor(const MorphSubtableHeader *morphSubtableHeader)
22 : StateTableProcessor(morphSubtableHeader)
24 contextualGlyphSubstitutionHeader = (const ContextualGlyphSubstitutionHeader *) morphSubtableHeader;
25 substitutionTableOffset = SWAPW(contextualGlyphSubstitutionHeader->substitutionTableOffset);
27 entryTable = (const ContextualGlyphSubstitutionStateEntry *) ((char *) &stateTableHeader->stHeader + entryTableOffset);
30 ContextualGlyphSubstitutionProcessor::~ContextualGlyphSubstitutionProcessor()
34 void ContextualGlyphSubstitutionProcessor::beginStateTable()
39 ByteOffset ContextualGlyphSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index)
41 const ContextualGlyphSubstitutionStateEntry *entry = &entryTable[index];
42 ByteOffset newState = SWAPW(entry->newStateOffset);
43 le_int16 flags = SWAPW(entry->flags);
44 WordOffset markOffset = SWAPW(entry->markOffset);
45 WordOffset currOffset = SWAPW(entry->currOffset);
47 if (markOffset != 0) {
48 const le_int16 *table = (const le_int16 *) ((char *) &stateTableHeader->stHeader + markOffset * 2);
49 LEGlyphID mGlyph = glyphStorage[markGlyph];
50 TTGlyphID newGlyph = SWAPW(table[LE_GET_GLYPH(mGlyph)]);
52 glyphStorage[markGlyph] = LE_SET_GLYPH(mGlyph, newGlyph);
55 if (currOffset != 0) {
56 const le_int16 *table = (const le_int16 *) ((char *) &stateTableHeader->stHeader + currOffset * 2);
57 LEGlyphID thisGlyph = glyphStorage[currGlyph];
58 TTGlyphID newGlyph = SWAPW(table[LE_GET_GLYPH(thisGlyph)]);
60 glyphStorage[currGlyph] = LE_SET_GLYPH(thisGlyph, newGlyph);
63 if (flags & cgsSetMark) {
64 markGlyph = currGlyph;
67 if (!(flags & cgsDontAdvance)) {
68 // should handle reverse too!
75 void ContextualGlyphSubstitutionProcessor::endStateTable()