2000-12-21 20:01:18 +00:00
|
|
|
/*
|
|
|
|
* %W% %E%
|
|
|
|
*
|
2003-06-03 20:58:22 +00:00
|
|
|
* (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved
|
2000-12-21 20:01:18 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "LETypes.h"
|
|
|
|
#include "LEGlyphFilter.h"
|
|
|
|
#include "OpenTypeTables.h"
|
|
|
|
#include "GlyphSubstitutionTables.h"
|
2000-12-21 21:57:18 +00:00
|
|
|
#include "MultipleSubstSubtables.h"
|
2000-12-21 20:01:18 +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 MultipleSubstitutionSubtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const
|
2000-12-21 20:01:18 +00:00
|
|
|
{
|
2003-02-05 00:05:40 +00:00
|
|
|
LEGlyphID glyph = glyphIterator->getCurrGlyphID();
|
2000-12-21 20:01:18 +00:00
|
|
|
le_int32 coverageIndex = getGlyphCoverage(glyph);
|
|
|
|
le_uint16 seqCount = SWAPW(sequenceCount);
|
|
|
|
|
2003-02-05 00:05:40 +00:00
|
|
|
if (coverageIndex >= 0 && coverageIndex < seqCount) {
|
2000-12-21 20:01:18 +00:00
|
|
|
Offset sequenceTableOffset = SWAPW(sequenceTableOffsetArray[coverageIndex]);
|
2001-01-19 00:30:17 +00:00
|
|
|
const SequenceTable *sequenceTable = (const SequenceTable *) ((char *) this + sequenceTableOffset);
|
2000-12-21 20:01:18 +00:00
|
|
|
le_uint16 glyphCount = SWAPW(sequenceTable->glyphCount);
|
|
|
|
|
|
|
|
if (glyphCount == 0) {
|
|
|
|
glyphIterator->setCurrGlyphID(0xFFFF);
|
|
|
|
return 1;
|
2003-09-24 21:05:40 +00:00
|
|
|
} else if (glyphCount == 1) {
|
2003-03-04 00:03:17 +00:00
|
|
|
TTGlyphID substitute = SWAPW(sequenceTable->substituteArray[0]);
|
|
|
|
|
|
|
|
if (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, substitute))) {
|
|
|
|
glyphIterator->setCurrGlyphID(substitute);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
} else {
|
2003-09-24 21:05:40 +00:00
|
|
|
LEGlyphID *newGlyphs = glyphIterator->insertGlyphs(glyphCount);
|
|
|
|
le_int32 insert = 0, direction = 1;
|
|
|
|
|
|
|
|
if (glyphIterator->isRightToLeft()) {
|
|
|
|
insert = glyphCount - 1;
|
|
|
|
direction = -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (le_int32 i = 0; i < glyphCount; i += 1) {
|
|
|
|
TTGlyphID substitute = SWAPW(sequenceTable->substituteArray[i]);
|
|
|
|
|
|
|
|
newGlyphs[insert] = LE_SET_GLYPH(glyph, substitute);
|
|
|
|
insert += direction;
|
|
|
|
}
|
|
|
|
|
2000-12-21 20:01:18 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2001-10-16 00:39:01 +00:00
|
|
|
|
|
|
|
U_NAMESPACE_END
|