2000-11-28 20:56:52 +00:00
|
|
|
/*
|
|
|
|
*
|
2004-05-07 23:29:16 +00:00
|
|
|
* (C) Copyright IBM Corp. 1998-2004 - 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 02:44:45 +00:00
|
|
|
#include "AlternateSubstSubtables.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 AlternateSubstitutionSubtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
|
|
|
// NOTE: For now, we'll just pick the first alternative...
|
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);
|
|
|
|
|
2003-02-05 00:05:40 +00:00
|
|
|
if (coverageIndex >= 0) {
|
2000-11-28 20:56:52 +00:00
|
|
|
le_uint16 altSetCount = SWAPW(alternateSetCount);
|
|
|
|
|
2003-02-05 00:05:40 +00:00
|
|
|
if (coverageIndex < altSetCount) {
|
2000-11-28 20:56:52 +00:00
|
|
|
Offset alternateSetTableOffset = SWAPW(alternateSetTableOffsetArray[coverageIndex]);
|
2001-01-19 00:30:17 +00:00
|
|
|
const AlternateSetTable *alternateSetTable =
|
|
|
|
(const AlternateSetTable *) ((char *) this + alternateSetTableOffset);
|
2003-02-05 22:08:20 +00:00
|
|
|
TTGlyphID alternate = SWAPW(alternateSetTable->alternateArray[0]);
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2003-02-05 22:08:20 +00:00
|
|
|
if (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, alternate))) {
|
2000-11-28 20:56:52 +00:00
|
|
|
glyphIterator->setCurrGlyphID(SWAPW(alternateSetTable->alternateArray[0]));
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// XXXX If we get here, the table's mal-formed...
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2001-10-16 00:39:01 +00:00
|
|
|
|
|
|
|
U_NAMESPACE_END
|