2000-11-28 20:56:52 +00:00
|
|
|
/*
|
2006-10-17 19:57:33 +00:00
|
|
|
* (C) Copyright IBM Corp. 1998-2006 - All Rights Reserved
|
2000-11-28 20:56:52 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "LETypes.h"
|
|
|
|
#include "LEGlyphFilter.h"
|
|
|
|
#include "OpenTypeTables.h"
|
|
|
|
#include "GlyphSubstitutionTables.h"
|
2000-12-21 21:57:18 +00:00
|
|
|
#include "LigatureSubstSubtables.h"
|
2000-11-28 20:56:52 +00:00
|
|
|
#include "GlyphIterator.h"
|
|
|
|
#include "LESwaps.h"
|
|
|
|
|
2001-10-16 00:39:01 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2001-01-19 00:30:17 +00:00
|
|
|
le_uint32 LigatureSubstitutionSubtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-02-05 00:05:40 +00:00
|
|
|
LEGlyphID glyph = glyphIterator->getCurrGlyphID();
|
2000-11-28 20:56:52 +00:00
|
|
|
le_int32 coverageIndex = getGlyphCoverage(glyph);
|
|
|
|
|
2001-09-20 00:37:55 +00:00
|
|
|
if (coverageIndex >= 0) {
|
2000-11-28 20:56:52 +00:00
|
|
|
Offset ligSetTableOffset = SWAPW(ligSetTableOffsetArray[coverageIndex]);
|
2001-01-19 00:30:17 +00:00
|
|
|
const LigatureSetTable *ligSetTable = (const LigatureSetTable *) ((char *) this + ligSetTableOffset);
|
2000-11-28 20:56:52 +00:00
|
|
|
le_uint16 ligCount = SWAPW(ligSetTable->ligatureCount);
|
|
|
|
|
2001-09-20 00:37:55 +00:00
|
|
|
for (le_uint16 lig = 0; lig < ligCount; lig += 1) {
|
2000-11-28 20:56:52 +00:00
|
|
|
Offset ligTableOffset = SWAPW(ligSetTable->ligatureTableOffsetArray[lig]);
|
2001-01-19 00:30:17 +00:00
|
|
|
const LigatureTable *ligTable = (const LigatureTable *) ((char *)ligSetTable + ligTableOffset);
|
2000-11-28 20:56:52 +00:00
|
|
|
le_uint16 compCount = SWAPW(ligTable->compCount) - 1;
|
|
|
|
le_int32 startPosition = glyphIterator->getCurrStreamPosition();
|
2003-02-05 00:05:40 +00:00
|
|
|
TTGlyphID ligGlyph = SWAPW(ligTable->ligGlyph);
|
2000-11-28 20:56:52 +00:00
|
|
|
le_uint16 comp;
|
|
|
|
|
2001-09-20 00:37:55 +00:00
|
|
|
for (comp = 0; comp < compCount; comp += 1) {
|
|
|
|
if (! glyphIterator->next()) {
|
2000-11-28 20:56:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2003-02-05 00:05:40 +00:00
|
|
|
if (LE_GET_GLYPH(glyphIterator->getCurrGlyphID()) != SWAPW(ligTable->componentArray[comp])) {
|
2000-11-28 20:56:52 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-17 19:57:33 +00:00
|
|
|
if (comp == compCount && (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, ligGlyph)))) {
|
2000-11-28 20:56:52 +00:00
|
|
|
GlyphIterator tempIterator(*glyphIterator);
|
2003-02-05 22:08:20 +00:00
|
|
|
TTGlyphID deletedGlyph = tempIterator.ignoresMarks()? 0xFFFE : 0xFFFF;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2001-09-20 00:37:55 +00:00
|
|
|
while (comp > 0) {
|
|
|
|
tempIterator.setCurrGlyphID(deletedGlyph);
|
2000-11-28 20:56:52 +00:00
|
|
|
tempIterator.prev();
|
|
|
|
|
|
|
|
comp -= 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
tempIterator.setCurrGlyphID(ligGlyph);
|
|
|
|
|
|
|
|
return compCount + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
glyphIterator->setCurrStreamPosition(startPosition);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2001-10-16 00:39:01 +00:00
|
|
|
|
|
|
|
U_NAMESPACE_END
|