2
|
1 |
/*
|
|
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
3 |
*
|
|
4 |
* This code is free software; you can redistribute it and/or modify it
|
|
5 |
* under the terms of the GNU General Public License version 2 only, as
|
5506
|
6 |
* published by the Free Software Foundation. Oracle designates this
|
2
|
7 |
* particular file as subject to the "Classpath" exception as provided
|
5506
|
8 |
* by Oracle in the LICENSE file that accompanied this code.
|
2
|
9 |
*
|
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
14 |
* accompanied this code).
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License version
|
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
19 |
*
|
5506
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
21 |
* or visit www.oracle.com if you need additional information or have any
|
|
22 |
* questions.
|
2
|
23 |
*
|
|
24 |
*/
|
|
25 |
|
|
26 |
/*
|
|
27 |
*
|
|
28 |
* (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
|
|
29 |
*
|
|
30 |
*/
|
|
31 |
|
|
32 |
#include "LETypes.h"
|
|
33 |
#include "MorphTables.h"
|
|
34 |
#include "StateTables.h"
|
|
35 |
#include "MorphStateTables.h"
|
|
36 |
#include "SubtableProcessor.h"
|
|
37 |
#include "StateTableProcessor.h"
|
|
38 |
#include "ContextualGlyphSubstProc.h"
|
|
39 |
#include "LEGlyphStorage.h"
|
|
40 |
#include "LESwaps.h"
|
|
41 |
|
3935
|
42 |
U_NAMESPACE_BEGIN
|
|
43 |
|
|
44 |
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ContextualGlyphSubstitutionProcessor)
|
|
45 |
|
16891
|
46 |
ContextualGlyphSubstitutionProcessor::ContextualGlyphSubstitutionProcessor(const LEReferenceTo<MorphSubtableHeader> &morphSubtableHeader, LEErrorCode &success)
|
|
47 |
: StateTableProcessor(morphSubtableHeader, success), entryTable(), contextualGlyphSubstitutionHeader(morphSubtableHeader, success)
|
2
|
48 |
{
|
16891
|
49 |
contextualGlyphSubstitutionHeader.orphan();
|
|
50 |
substitutionTableOffset = SWAPW(contextualGlyphSubstitutionHeader->substitutionTableOffset);
|
|
51 |
|
2
|
52 |
|
16891
|
53 |
entryTable = LEReferenceToArrayOf<ContextualGlyphSubstitutionStateEntry>(stateTableHeader, success,
|
|
54 |
(const ContextualGlyphSubstitutionStateEntry*)(&stateTableHeader->stHeader),
|
|
55 |
entryTableOffset, LE_UNBOUNDED_ARRAY);
|
|
56 |
int16Table = LEReferenceToArrayOf<le_int16>(stateTableHeader, success, (const le_int16*)(&stateTableHeader->stHeader),
|
|
57 |
0, LE_UNBOUNDED_ARRAY); // rest of the table as le_int16s
|
2
|
58 |
}
|
|
59 |
|
|
60 |
ContextualGlyphSubstitutionProcessor::~ContextualGlyphSubstitutionProcessor()
|
|
61 |
{
|
|
62 |
}
|
|
63 |
|
|
64 |
void ContextualGlyphSubstitutionProcessor::beginStateTable()
|
|
65 |
{
|
|
66 |
markGlyph = 0;
|
|
67 |
}
|
|
68 |
|
3935
|
69 |
ByteOffset ContextualGlyphSubstitutionProcessor::processStateEntry(LEGlyphStorage &glyphStorage, le_int32 &currGlyph, EntryTableIndex index)
|
2
|
70 |
{
|
16891
|
71 |
LEErrorCode success = LE_NO_ERROR;
|
|
72 |
const ContextualGlyphSubstitutionStateEntry *entry = entryTable.getAlias(index, success);
|
|
73 |
ByteOffset newState = SWAPW(entry->newStateOffset);
|
|
74 |
le_int16 flags = SWAPW(entry->flags);
|
|
75 |
WordOffset markOffset = SWAPW(entry->markOffset);
|
|
76 |
WordOffset currOffset = SWAPW(entry->currOffset);
|
2
|
77 |
|
16891
|
78 |
if (markOffset != 0 && LE_SUCCESS(success)) {
|
|
79 |
LEGlyphID mGlyph = glyphStorage[markGlyph];
|
|
80 |
TTGlyphID newGlyph = SWAPW(int16Table.getObject(markOffset + LE_GET_GLYPH(mGlyph), success)); // whew.
|
|
81 |
|
|
82 |
glyphStorage[markGlyph] = LE_SET_GLYPH(mGlyph, newGlyph);
|
|
83 |
}
|
2
|
84 |
|
16891
|
85 |
if (currOffset != 0) {
|
|
86 |
LEGlyphID thisGlyph = glyphStorage[currGlyph];
|
|
87 |
TTGlyphID newGlyph = SWAPW(int16Table.getObject(currOffset + LE_GET_GLYPH(thisGlyph), success)); // whew.
|
2
|
88 |
|
16891
|
89 |
glyphStorage[currGlyph] = LE_SET_GLYPH(thisGlyph, newGlyph);
|
|
90 |
}
|
2
|
91 |
|
|
92 |
if (flags & cgsSetMark) {
|
|
93 |
markGlyph = currGlyph;
|
|
94 |
}
|
|
95 |
|
|
96 |
if (!(flags & cgsDontAdvance)) {
|
|
97 |
// should handle reverse too!
|
|
98 |
currGlyph += 1;
|
|
99 |
}
|
|
100 |
|
|
101 |
return newState;
|
|
102 |
}
|
|
103 |
|
|
104 |
void ContextualGlyphSubstitutionProcessor::endStateTable()
|
|
105 |
{
|
|
106 |
}
|
3935
|
107 |
|
|
108 |
U_NAMESPACE_END
|