2000-11-28 20:56:52 +00:00
|
|
|
/*
|
2000-12-21 02:44:45 +00:00
|
|
|
* @(#)AlternateSubstSubtables.cpp 1.7 00/03/15
|
2000-11-28 20:56:52 +00:00
|
|
|
*
|
2001-01-19 00:30:17 +00:00
|
|
|
* (C) Copyright IBM Corp. 1998, 1999, 2000, 2001 - 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...
|
|
|
|
LEGlyphID glyph = (LEGlyphID) glyphIterator->getCurrGlyphID();
|
|
|
|
le_int32 coverageIndex = getGlyphCoverage(glyph);
|
|
|
|
|
|
|
|
if (coverageIndex >= 0)
|
|
|
|
{
|
|
|
|
le_uint16 altSetCount = SWAPW(alternateSetCount);
|
|
|
|
|
|
|
|
if (coverageIndex < altSetCount)
|
|
|
|
{
|
|
|
|
Offset alternateSetTableOffset = SWAPW(alternateSetTableOffsetArray[coverageIndex]);
|
2001-01-19 00:30:17 +00:00
|
|
|
const AlternateSetTable *alternateSetTable =
|
|
|
|
(const AlternateSetTable *) ((char *) this + alternateSetTableOffset);
|
2000-11-28 20:56:52 +00:00
|
|
|
LEGlyphID alternate = SWAPW(alternateSetTable->alternateArray[0]);
|
|
|
|
|
|
|
|
if (filter != NULL || filter->accept(alternate)) {
|
|
|
|
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
|