sl@0: /* sl@0: * %W% %E% sl@0: * sl@0: * (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved sl@0: * sl@0: */ sl@0: sl@0: #include "LETypes.h" sl@0: #include "LEGlyphFilter.h" sl@0: #include "OpenTypeTables.h" sl@0: #include "GlyphSubstitutionTables.h" sl@0: #include "LigatureSubstSubtables.h" sl@0: #include "GlyphIterator.h" sl@0: #include "LESwaps.h" sl@0: sl@0: U_NAMESPACE_BEGIN sl@0: sl@0: le_uint32 LigatureSubstitutionSubtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const sl@0: { sl@0: LEGlyphID glyph = glyphIterator->getCurrGlyphID(); sl@0: le_int32 coverageIndex = getGlyphCoverage(glyph); sl@0: sl@0: if (coverageIndex >= 0) { sl@0: Offset ligSetTableOffset = SWAPW(ligSetTableOffsetArray[coverageIndex]); sl@0: const LigatureSetTable *ligSetTable = (const LigatureSetTable *) ((char *) this + ligSetTableOffset); sl@0: le_uint16 ligCount = SWAPW(ligSetTable->ligatureCount); sl@0: sl@0: for (le_uint16 lig = 0; lig < ligCount; lig += 1) { sl@0: Offset ligTableOffset = SWAPW(ligSetTable->ligatureTableOffsetArray[lig]); sl@0: const LigatureTable *ligTable = (const LigatureTable *) ((char *)ligSetTable + ligTableOffset); sl@0: le_uint16 compCount = SWAPW(ligTable->compCount) - 1; sl@0: le_int32 startPosition = glyphIterator->getCurrStreamPosition(); sl@0: TTGlyphID ligGlyph = SWAPW(ligTable->ligGlyph); sl@0: le_uint16 comp; sl@0: sl@0: if (filter != NULL && ! filter->accept(LE_SET_GLYPH(glyph, ligGlyph))) { sl@0: continue; sl@0: } sl@0: sl@0: for (comp = 0; comp < compCount; comp += 1) { sl@0: if (! glyphIterator->next()) { sl@0: break; sl@0: } sl@0: sl@0: if (LE_GET_GLYPH(glyphIterator->getCurrGlyphID()) != SWAPW(ligTable->componentArray[comp])) { sl@0: break; sl@0: } sl@0: } sl@0: sl@0: if (comp == compCount) { sl@0: GlyphIterator tempIterator(*glyphIterator); sl@0: TTGlyphID deletedGlyph = tempIterator.ignoresMarks()? 0xFFFE : 0xFFFF; sl@0: sl@0: while (comp > 0) { sl@0: tempIterator.setCurrGlyphID(deletedGlyph); sl@0: tempIterator.prev(); sl@0: sl@0: comp -= 1; sl@0: } sl@0: sl@0: tempIterator.setCurrGlyphID(ligGlyph); sl@0: sl@0: return compCount + 1; sl@0: } sl@0: sl@0: glyphIterator->setCurrStreamPosition(startPosition); sl@0: } sl@0: sl@0: } sl@0: sl@0: return 0; sl@0: } sl@0: sl@0: U_NAMESPACE_END