1c9f0bf8a3
X-SVN-Rev: 3021
78 lines
2.3 KiB
C++
78 lines
2.3 KiB
C++
/*
|
|
* @(#)LigatureSubstitutionSubtables.cpp 1.7 00/03/15
|
|
*
|
|
* (C) Copyright IBM Corp. 1998, 1999, 2000 - All Rights Reserved
|
|
*
|
|
*/
|
|
|
|
#include "LETypes.h"
|
|
#include "LEGlyphFilter.h"
|
|
#include "OpenTypeTables.h"
|
|
#include "GlyphSubstitutionTables.h"
|
|
#include "LigatureSubstitutionSubtables.h"
|
|
#include "GlyphIterator.h"
|
|
#include "LESwaps.h"
|
|
|
|
le_uint32 LigatureSubstitutionSubtable::process(GlyphIterator *glyphIterator, LEGlyphFilter *filter)
|
|
{
|
|
LEGlyphID glyph = (LEGlyphID) glyphIterator->getCurrGlyphID();
|
|
le_int32 coverageIndex = getGlyphCoverage(glyph);
|
|
|
|
if (coverageIndex >= 0)
|
|
{
|
|
Offset ligSetTableOffset = SWAPW(ligSetTableOffsetArray[coverageIndex]);
|
|
LigatureSetTable *ligSetTable = (LigatureSetTable *) ((char *) this + ligSetTableOffset);
|
|
le_uint16 ligCount = SWAPW(ligSetTable->ligatureCount);
|
|
|
|
for (le_uint16 lig = 0; lig < ligCount; lig += 1)
|
|
{
|
|
Offset ligTableOffset = SWAPW(ligSetTable->ligatureTableOffsetArray[lig]);
|
|
LigatureTable *ligTable = (LigatureTable *) ((char *)ligSetTable + ligTableOffset);
|
|
le_uint16 compCount = SWAPW(ligTable->compCount) - 1;
|
|
le_int32 startPosition = glyphIterator->getCurrStreamPosition();
|
|
LEGlyphID ligGlyph = SWAPW(ligTable->ligGlyph);
|
|
le_uint16 comp;
|
|
|
|
if (filter != NULL && ! filter->accept(ligGlyph))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
for (comp = 0; comp < compCount; comp += 1)
|
|
{
|
|
if (! glyphIterator->next())
|
|
{
|
|
break;
|
|
}
|
|
|
|
if ((LEGlyphID) glyphIterator->getCurrGlyphID() != SWAPW(ligTable->componentArray[comp]))
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (comp == compCount)
|
|
{
|
|
GlyphIterator tempIterator(*glyphIterator);
|
|
|
|
while (comp > 0)
|
|
{
|
|
tempIterator.setCurrGlyphID(0xFFFF);
|
|
tempIterator.prev();
|
|
|
|
comp -= 1;
|
|
}
|
|
|
|
tempIterator.setCurrGlyphID(ligGlyph);
|
|
|
|
return compCount + 1;
|
|
}
|
|
|
|
glyphIterator->setCurrStreamPosition(startPosition);
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
}
|