• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *
3  * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved
4  *
5  */
6 
7 #include "LETypes.h"
8 #include "LEGlyphFilter.h"
9 #include "OpenTypeTables.h"
10 #include "GlyphSubstitutionTables.h"
11 #include "AlternateSubstSubtables.h"
12 #include "GlyphIterator.h"
13 #include "LESwaps.h"
14 
15 U_NAMESPACE_BEGIN
16 
process(const LEReferenceTo<AlternateSubstitutionSubtable> & base,GlyphIterator * glyphIterator,LEErrorCode & success,const LEGlyphFilter * filter) const17 le_uint32 AlternateSubstitutionSubtable::process(const LEReferenceTo<AlternateSubstitutionSubtable> &base,
18                                        GlyphIterator *glyphIterator, LEErrorCode &success, const LEGlyphFilter *filter) const
19 {
20     // NOTE: For now, we'll just pick the first alternative...
21     LEGlyphID glyph = glyphIterator->getCurrGlyphID();
22     le_int32 coverageIndex = getGlyphCoverage(base, glyph, success);
23 
24     if (coverageIndex >= 0 && LE_SUCCESS(success)) {
25         le_uint16 altSetCount = SWAPW(alternateSetCount);
26 
27         if (coverageIndex < altSetCount) {
28             Offset alternateSetTableOffset = SWAPW(alternateSetTableOffsetArray[coverageIndex]);
29             const LEReferenceTo<AlternateSetTable> alternateSetTable(base, success,
30                                   (const AlternateSetTable *) ((char *) this + alternateSetTableOffset));
31             TTGlyphID alternate = SWAPW(alternateSetTable->alternateArray[0]);
32 
33             if (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, alternate))) {
34                 glyphIterator->setCurrGlyphID(SWAPW(alternateSetTable->alternateArray[0]));
35             }
36 
37             return 1;
38         }
39 
40         // XXXX If we get here, the table's mal-formed...
41     }
42 
43     return 0;
44 }
45 
46 U_NAMESPACE_END
47