]>
Commit | Line | Data |
---|---|---|
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" | |
374ca955 | 13 | #include "LEGlyphStorage.h" |
b75a7d8f A |
14 | #include "LESwaps.h" |
15 | ||
16 | U_NAMESPACE_BEGIN | |
17 | ||
18 | StateTableProcessor::StateTableProcessor() | |
19 | { | |
20 | } | |
21 | ||
22 | StateTableProcessor::StateTableProcessor(const MorphSubtableHeader *morphSubtableHeader) | |
23 | : SubtableProcessor(morphSubtableHeader) | |
24 | { | |
25 | stateTableHeader = (const MorphStateTableHeader *) morphSubtableHeader; | |
26 | ||
27 | stateSize = SWAPW(stateTableHeader->stHeader.stateSize); | |
28 | classTableOffset = SWAPW(stateTableHeader->stHeader.classTableOffset); | |
29 | stateArrayOffset = SWAPW(stateTableHeader->stHeader.stateArrayOffset); | |
30 | entryTableOffset = SWAPW(stateTableHeader->stHeader.entryTableOffset); | |
31 | ||
32 | classTable = (const ClassTable *) ((char *) &stateTableHeader->stHeader + classTableOffset); | |
33 | firstGlyph = SWAPW(classTable->firstGlyph); | |
34 | lastGlyph = firstGlyph + SWAPW(classTable->nGlyphs); | |
35 | } | |
36 | ||
37 | StateTableProcessor::~StateTableProcessor() | |
38 | { | |
39 | } | |
40 | ||
374ca955 | 41 | void StateTableProcessor::process(LEGlyphStorage &glyphStorage) |
b75a7d8f A |
42 | { |
43 | // Start at state 0 | |
44 | // XXX: How do we know when to start at state 1? | |
45 | ByteOffset currentState = stateArrayOffset; | |
46 | ||
47 | // XXX: reverse? | |
48 | le_int32 currGlyph = 0; | |
374ca955 | 49 | le_int32 glyphCount = glyphStorage.getGlyphCount(); |
b75a7d8f A |
50 | |
51 | beginStateTable(); | |
52 | ||
53 | while (currGlyph <= glyphCount) { | |
54 | ClassCode classCode = classCodeOOB; | |
55 | if (currGlyph == glyphCount) { | |
56 | // XXX: How do we handle EOT vs. EOL? | |
57 | classCode = classCodeEOT; | |
58 | } else { | |
374ca955 | 59 | TTGlyphID glyphCode = (TTGlyphID) LE_GET_GLYPH(glyphStorage[currGlyph]); |
b75a7d8f A |
60 | |
61 | if (glyphCode == 0xFFFF) { | |
62 | classCode = classCodeDEL; | |
63 | } else if ((glyphCode >= firstGlyph) && (glyphCode < lastGlyph)) { | |
64 | classCode = classTable->classArray[glyphCode - firstGlyph]; | |
65 | } | |
66 | } | |
67 | ||
68 | const EntryTableIndex *stateArray = (const EntryTableIndex *) ((char *) &stateTableHeader->stHeader + currentState); | |
69 | EntryTableIndex entryTableIndex = stateArray[(le_uint8)classCode]; | |
70 | ||
374ca955 | 71 | currentState = processStateEntry(glyphStorage, currGlyph, entryTableIndex); |
b75a7d8f A |
72 | } |
73 | ||
74 | endStateTable(); | |
75 | } | |
76 | ||
77 | U_NAMESPACE_END |