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