sl@0: /* sl@0: * sl@0: * (C) Copyright IBM Corp. 1998-2004 - 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 "SingleSubstitutionSubtables.h" sl@0: #include "GlyphIterator.h" sl@0: #include "LESwaps.h" sl@0: sl@0: U_NAMESPACE_BEGIN sl@0: sl@0: le_uint32 SingleSubstitutionSubtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const sl@0: { sl@0: switch(SWAPW(subtableFormat)) sl@0: { sl@0: case 0: sl@0: return 0; sl@0: sl@0: case 1: sl@0: { sl@0: const SingleSubstitutionFormat1Subtable *subtable = (const SingleSubstitutionFormat1Subtable *) this; sl@0: sl@0: return subtable->process(glyphIterator, filter); sl@0: } sl@0: sl@0: case 2: sl@0: { sl@0: const SingleSubstitutionFormat2Subtable *subtable = (const SingleSubstitutionFormat2Subtable *) this; sl@0: sl@0: return subtable->process(glyphIterator, filter); sl@0: } sl@0: sl@0: default: sl@0: return 0; sl@0: } sl@0: } sl@0: sl@0: le_uint32 SingleSubstitutionFormat1Subtable::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: TTGlyphID substitute = ((TTGlyphID) LE_GET_GLYPH(glyph)) + SWAPW(deltaGlyphID); sl@0: sl@0: if (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, substitute))) { sl@0: glyphIterator->setCurrGlyphID(substitute); sl@0: } sl@0: sl@0: return 1; sl@0: } sl@0: sl@0: return 0; sl@0: } sl@0: sl@0: le_uint32 SingleSubstitutionFormat2Subtable::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: TTGlyphID substitute = SWAPW(substituteArray[coverageIndex]); sl@0: sl@0: if (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, substitute))) { sl@0: glyphIterator->setCurrGlyphID(substitute); sl@0: } sl@0: sl@0: return 1; sl@0: } sl@0: sl@0: return 0; sl@0: } sl@0: sl@0: U_NAMESPACE_END