2 * (C) Copyright IBM Corp. 1998-2015 - All Rights Reserved
7 #include "LEGlyphFilter.h"
8 #include "OpenTypeTables.h"
9 #include "GlyphSubstitutionTables.h"
10 #include "LigatureSubstSubtables.h"
11 #include "GlyphIterator.h"
16 le_uint32 LigatureSubstitutionSubtable::process(const LETableReference &base, GlyphIterator *glyphIterator, LEErrorCode &success, const LEGlyphFilter *filter) const
18 LEGlyphID glyph = glyphIterator->getCurrGlyphID();
19 le_int32 coverageIndex = getGlyphCoverage(base, glyph, success);
21 if (coverageIndex >= 0) {
22 Offset ligSetTableOffset = SWAPW(ligSetTableOffsetArray[coverageIndex]);
23 const LigatureSetTable *ligSetTable = (const LigatureSetTable *) ((char *) this + ligSetTableOffset);
24 le_uint16 ligCount = SWAPW(ligSetTable->ligatureCount);
26 for (le_uint16 lig = 0; lig < ligCount; lig += 1) {
27 Offset ligTableOffset = SWAPW(ligSetTable->ligatureTableOffsetArray[lig]);
28 const LigatureTable *ligTable = (const LigatureTable *) ((char *)ligSetTable + ligTableOffset);
29 le_uint16 compCount = SWAPW(ligTable->compCount) - 1;
30 LEReferenceToArrayOf<TTGlyphID>
31 componentArrayRef(base, success, ligTable->componentArray, compCount);
32 if (LE_FAILURE(success)) { return 0; }
33 le_int32 startPosition = glyphIterator->getCurrStreamPosition();
34 TTGlyphID ligGlyph = SWAPW(ligTable->ligGlyph);
37 for (comp = 0; comp < compCount; comp += 1) {
38 if (! glyphIterator->next()) {
42 if (LE_GET_GLYPH(glyphIterator->getCurrGlyphID()) != SWAPW(ligTable->componentArray[comp])) {
47 if (comp == compCount && (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, ligGlyph)))) {
48 GlyphIterator tempIterator(*glyphIterator);
49 TTGlyphID deletedGlyph = tempIterator.ignoresMarks()? 0xFFFE : 0xFFFF;
52 tempIterator.setCurrGlyphID(deletedGlyph);
58 tempIterator.setCurrGlyphID(ligGlyph);
63 glyphIterator->setCurrStreamPosition(startPosition);