2000-11-28 20:56:52 +00:00
|
|
|
/*
|
|
|
|
*
|
2013-04-18 21:24:51 +00:00
|
|
|
* (C) Copyright IBM Corp. 1998-2013 - 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
|
|
|
|
|
2013-04-18 21:24:51 +00:00
|
|
|
le_uint32 AlternateSubstitutionSubtable::process(const LEReferenceTo<AlternateSubstitutionSubtable> &base,
|
|
|
|
GlyphIterator *glyphIterator, LEErrorCode &success, 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();
|
2013-04-18 21:24:51 +00:00
|
|
|
le_int32 coverageIndex = getGlyphCoverage(base, glyph, success);
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2013-04-18 21:24:51 +00:00
|
|
|
if (coverageIndex >= 0 && LE_SUCCESS(success)) {
|
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]);
|
2013-04-18 21:24:51 +00:00
|
|
|
const LEReferenceTo<AlternateSetTable> alternateSetTable(base, success,
|
|
|
|
(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]));
|
|
|
|
}
|
2013-04-18 21:24:51 +00:00
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
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
|