os/textandloc/fontservices/textshaperplugin/IcuSource/layout/AlternateSubstSubtables.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/textandloc/fontservices/textshaperplugin/IcuSource/layout/AlternateSubstSubtables.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,45 @@
1.4 +/*
1.5 + *
1.6 + * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
1.7 + *
1.8 + */
1.9 +
1.10 +#include "LETypes.h"
1.11 +#include "LEGlyphFilter.h"
1.12 +#include "OpenTypeTables.h"
1.13 +#include "GlyphSubstitutionTables.h"
1.14 +#include "AlternateSubstSubtables.h"
1.15 +#include "GlyphIterator.h"
1.16 +#include "LESwaps.h"
1.17 +
1.18 +U_NAMESPACE_BEGIN
1.19 +
1.20 +le_uint32 AlternateSubstitutionSubtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const
1.21 +{
1.22 + // NOTE: For now, we'll just pick the first alternative...
1.23 + LEGlyphID glyph = glyphIterator->getCurrGlyphID();
1.24 + le_int32 coverageIndex = getGlyphCoverage(glyph);
1.25 +
1.26 + if (coverageIndex >= 0) {
1.27 + le_uint16 altSetCount = SWAPW(alternateSetCount);
1.28 +
1.29 + if (coverageIndex < altSetCount) {
1.30 + Offset alternateSetTableOffset = SWAPW(alternateSetTableOffsetArray[coverageIndex]);
1.31 + const AlternateSetTable *alternateSetTable =
1.32 + (const AlternateSetTable *) ((char *) this + alternateSetTableOffset);
1.33 + TTGlyphID alternate = SWAPW(alternateSetTable->alternateArray[0]);
1.34 +
1.35 + if (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, alternate))) {
1.36 + glyphIterator->setCurrGlyphID(SWAPW(alternateSetTable->alternateArray[0]));
1.37 + }
1.38 +
1.39 + return 1;
1.40 + }
1.41 +
1.42 + // XXXX If we get here, the table's mal-formed...
1.43 + }
1.44 +
1.45 + return 0;
1.46 +}
1.47 +
1.48 +U_NAMESPACE_END