]>
Commit | Line | Data |
---|---|---|
b75a7d8f | 1 | /* |
b75a7d8f | 2 | * |
57a6839d | 3 | * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved |
b75a7d8f A |
4 | * |
5 | */ | |
6 | ||
7 | #include "LETypes.h" | |
8 | #include "LEGlyphFilter.h" | |
9 | #include "OpenTypeTables.h" | |
10 | #include "GlyphSubstitutionTables.h" | |
11 | #include "AlternateSubstSubtables.h" | |
12 | #include "GlyphIterator.h" | |
13 | #include "LESwaps.h" | |
14 | ||
15 | U_NAMESPACE_BEGIN | |
16 | ||
57a6839d A |
17 | le_uint32 AlternateSubstitutionSubtable::process(const LEReferenceTo<AlternateSubstitutionSubtable> &base, |
18 | GlyphIterator *glyphIterator, LEErrorCode &success, const LEGlyphFilter *filter) const | |
b75a7d8f A |
19 | { |
20 | // NOTE: For now, we'll just pick the first alternative... | |
21 | LEGlyphID glyph = glyphIterator->getCurrGlyphID(); | |
57a6839d | 22 | le_int32 coverageIndex = getGlyphCoverage(base, glyph, success); |
b75a7d8f | 23 | |
57a6839d | 24 | if (coverageIndex >= 0 && LE_SUCCESS(success)) { |
b75a7d8f A |
25 | le_uint16 altSetCount = SWAPW(alternateSetCount); |
26 | ||
27 | if (coverageIndex < altSetCount) { | |
28 | Offset alternateSetTableOffset = SWAPW(alternateSetTableOffsetArray[coverageIndex]); | |
57a6839d A |
29 | const LEReferenceTo<AlternateSetTable> alternateSetTable(base, success, |
30 | (const AlternateSetTable *) ((char *) this + alternateSetTableOffset)); | |
b75a7d8f A |
31 | TTGlyphID alternate = SWAPW(alternateSetTable->alternateArray[0]); |
32 | ||
33 | if (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, alternate))) { | |
34 | glyphIterator->setCurrGlyphID(SWAPW(alternateSetTable->alternateArray[0])); | |
35 | } | |
57a6839d | 36 | |
b75a7d8f A |
37 | return 1; |
38 | } | |
39 | ||
40 | // XXXX If we get here, the table's mal-formed... | |
41 | } | |
42 | ||
43 | return 0; | |
44 | } | |
45 | ||
46 | U_NAMESPACE_END |