]> git.saurik.com Git - apple/icu.git/blame - icuSources/layout/ContextualGlyphSubstProc.cpp
ICU-491.11.1.tar.gz
[apple/icu.git] / icuSources / layout / ContextualGlyphSubstProc.cpp
CommitLineData
b75a7d8f 1/*
b75a7d8f 2 *
374ca955 3 * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
b75a7d8f
A
4 *
5 */
6
7#include "LETypes.h"
8#include "MorphTables.h"
9#include "StateTables.h"
10#include "MorphStateTables.h"
11#include "SubtableProcessor.h"
12#include "StateTableProcessor.h"
13#include "ContextualGlyphSubstProc.h"
374ca955 14#include "LEGlyphStorage.h"
b75a7d8f
A
15#include "LESwaps.h"
16
17U_NAMESPACE_BEGIN
18
374ca955 19UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ContextualGlyphSubstitutionProcessor)
b75a7d8f
A
20
21ContextualGlyphSubstitutionProcessor::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
30ContextualGlyphSubstitutionProcessor::~ContextualGlyphSubstitutionProcessor()
31{
32}
33
34void ContextualGlyphSubstitutionProcessor::beginStateTable()
35{
36 markGlyph = 0;
37}
38
374ca955 39ByteOffset ContextualGlyphSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index)
b75a7d8f
A
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);
374ca955
A
49 LEGlyphID mGlyph = glyphStorage[markGlyph];
50 TTGlyphID newGlyph = SWAPW(table[LE_GET_GLYPH(mGlyph)]);
b75a7d8f 51
374ca955 52 glyphStorage[markGlyph] = LE_SET_GLYPH(mGlyph, newGlyph);
b75a7d8f
A
53 }
54
55 if (currOffset != 0) {
56 const le_int16 *table = (const le_int16 *) ((char *) &stateTableHeader->stHeader + currOffset * 2);
374ca955
A
57 LEGlyphID thisGlyph = glyphStorage[currGlyph];
58 TTGlyphID newGlyph = SWAPW(table[LE_GET_GLYPH(thisGlyph)]);
b75a7d8f 59
374ca955 60 glyphStorage[currGlyph] = LE_SET_GLYPH(thisGlyph, newGlyph);
b75a7d8f
A
61 }
62
63 if (flags & cgsSetMark) {
64 markGlyph = currGlyph;
65 }
66
67 if (!(flags & cgsDontAdvance)) {
68 // should handle reverse too!
69 currGlyph += 1;
70 }
71
72 return newState;
73}
74
75void ContextualGlyphSubstitutionProcessor::endStateTable()
76{
77}
78
79U_NAMESPACE_END