]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | /* |
2 | * @(#)ContextualGlyphSubstProc.cpp 1.6 00/03/15 | |
3 | * | |
4 | * (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved | |
5 | * | |
6 | */ | |
7 | ||
8 | #include "LETypes.h" | |
9 | #include "MorphTables.h" | |
10 | #include "StateTables.h" | |
11 | #include "MorphStateTables.h" | |
12 | #include "SubtableProcessor.h" | |
13 | #include "StateTableProcessor.h" | |
14 | #include "ContextualGlyphSubstProc.h" | |
15 | #include "LESwaps.h" | |
16 | ||
17 | U_NAMESPACE_BEGIN | |
18 | ||
19 | const char ContextualGlyphSubstitutionProcessor::fgClassID=0; | |
20 | ||
21 | ContextualGlyphSubstitutionProcessor::ContextualGlyphSubstitutionProcessor(const MorphSubtableHeader *morphSubtableHeader) | |
22 | : StateTableProcessor(morphSubtableHeader) | |
23 | { | |
24 | contextualGlyphSubstitutionHeader = (const ContextualGlyphSubstitutionHeader *) morphSubtableHeader; | |
25 | substitutionTableOffset = SWAPW(contextualGlyphSubstitutionHeader->substitutionTableOffset); | |
26 | ||
27 | entryTable = (const ContextualGlyphSubstitutionStateEntry *) ((char *) &stateTableHeader->stHeader + entryTableOffset); | |
28 | } | |
29 | ||
30 | ContextualGlyphSubstitutionProcessor::~ContextualGlyphSubstitutionProcessor() | |
31 | { | |
32 | } | |
33 | ||
34 | void ContextualGlyphSubstitutionProcessor::beginStateTable() | |
35 | { | |
36 | markGlyph = 0; | |
37 | } | |
38 | ||
39 | ByteOffset ContextualGlyphSubstitutionProcessor::processStateEntry(LEGlyphID *glyphs, le_int32 * /*charIndices*/, le_int32 &currGlyph, le_int32 /*glyphCount*/, EntryTableIndex index) | |
40 | { | |
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); | |
46 | ||
47 | if (markOffset != 0) { | |
48 | const le_int16 *table = (const le_int16 *) ((char *) &stateTableHeader->stHeader + markOffset * 2); | |
49 | TTGlyphID newGlyph = SWAPW(table[LE_GET_GLYPH(glyphs[markGlyph])]); | |
50 | ||
51 | glyphs[markGlyph] = LE_SET_GLYPH(glyphs[markGlyph], newGlyph); | |
52 | } | |
53 | ||
54 | if (currOffset != 0) { | |
55 | const le_int16 *table = (const le_int16 *) ((char *) &stateTableHeader->stHeader + currOffset * 2); | |
56 | le_int16 newGlyph = SWAPW(table[LE_GET_GLYPH(glyphs[currGlyph])]); | |
57 | ||
58 | glyphs[currGlyph] = LE_SET_GLYPH(glyphs[currGlyph], newGlyph); | |
59 | } | |
60 | ||
61 | if (flags & cgsSetMark) { | |
62 | markGlyph = currGlyph; | |
63 | } | |
64 | ||
65 | if (!(flags & cgsDontAdvance)) { | |
66 | // should handle reverse too! | |
67 | currGlyph += 1; | |
68 | } | |
69 | ||
70 | return newState; | |
71 | } | |
72 | ||
73 | void ContextualGlyphSubstitutionProcessor::endStateTable() | |
74 | { | |
75 | } | |
76 | ||
77 | U_NAMESPACE_END |