os/textandloc/fontservices/textshaperplugin/IcuSource/layout/LigatureSubstSubtables.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/layout/LigatureSubstSubtables.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,74 @@
     1.4 +/*
     1.5 + * %W% %E%
     1.6 + *
     1.7 + * (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved
     1.8 + *
     1.9 + */
    1.10 +
    1.11 +#include "LETypes.h"
    1.12 +#include "LEGlyphFilter.h"
    1.13 +#include "OpenTypeTables.h"
    1.14 +#include "GlyphSubstitutionTables.h"
    1.15 +#include "LigatureSubstSubtables.h"
    1.16 +#include "GlyphIterator.h"
    1.17 +#include "LESwaps.h"
    1.18 +
    1.19 +U_NAMESPACE_BEGIN
    1.20 +
    1.21 +le_uint32 LigatureSubstitutionSubtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const
    1.22 +{
    1.23 +    LEGlyphID glyph = glyphIterator->getCurrGlyphID();
    1.24 +    le_int32 coverageIndex = getGlyphCoverage(glyph);
    1.25 +
    1.26 +    if (coverageIndex >= 0) {
    1.27 +        Offset ligSetTableOffset = SWAPW(ligSetTableOffsetArray[coverageIndex]);
    1.28 +        const LigatureSetTable *ligSetTable = (const LigatureSetTable *) ((char *) this + ligSetTableOffset);
    1.29 +        le_uint16 ligCount = SWAPW(ligSetTable->ligatureCount);
    1.30 +
    1.31 +        for (le_uint16 lig = 0; lig < ligCount; lig += 1) {
    1.32 +            Offset ligTableOffset = SWAPW(ligSetTable->ligatureTableOffsetArray[lig]);
    1.33 +            const LigatureTable *ligTable = (const LigatureTable *) ((char *)ligSetTable + ligTableOffset);
    1.34 +            le_uint16 compCount = SWAPW(ligTable->compCount) - 1;
    1.35 +            le_int32 startPosition = glyphIterator->getCurrStreamPosition();
    1.36 +            TTGlyphID ligGlyph = SWAPW(ligTable->ligGlyph);
    1.37 +            le_uint16 comp;
    1.38 +
    1.39 +            if (filter != NULL && ! filter->accept(LE_SET_GLYPH(glyph, ligGlyph))) {
    1.40 +                continue;
    1.41 +            }
    1.42 +
    1.43 +            for (comp = 0; comp < compCount; comp += 1) {
    1.44 +                if (! glyphIterator->next()) {
    1.45 +                    break;
    1.46 +                }
    1.47 +
    1.48 +                if (LE_GET_GLYPH(glyphIterator->getCurrGlyphID()) != SWAPW(ligTable->componentArray[comp])) {
    1.49 +                    break;
    1.50 +                }
    1.51 +            }
    1.52 +
    1.53 +            if (comp == compCount) {
    1.54 +                GlyphIterator tempIterator(*glyphIterator);
    1.55 +                TTGlyphID deletedGlyph = tempIterator.ignoresMarks()? 0xFFFE : 0xFFFF;
    1.56 +
    1.57 +                while (comp > 0) {
    1.58 +                    tempIterator.setCurrGlyphID(deletedGlyph);
    1.59 +                    tempIterator.prev();
    1.60 +
    1.61 +                    comp -= 1;
    1.62 +                }
    1.63 +
    1.64 +                tempIterator.setCurrGlyphID(ligGlyph);
    1.65 +
    1.66 +                return compCount + 1;
    1.67 +            }
    1.68 +
    1.69 +            glyphIterator->setCurrStreamPosition(startPosition);
    1.70 +        }
    1.71 +
    1.72 +    }
    1.73 +
    1.74 +    return 0;
    1.75 +}
    1.76 +
    1.77 +U_NAMESPACE_END