Home | History | Annotate | Download | only in layout
      1 /*
      2  *
      3  * (C) Copyright IBM Corp. 1998-2004 - 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 
     17 le_uint32 AlternateSubstitutionSubtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const
     18 {
     19     // NOTE: For now, we'll just pick the first alternative...
     20     LEGlyphID glyph = glyphIterator->getCurrGlyphID();
     21     le_int32 coverageIndex = getGlyphCoverage(glyph);
     22 
     23     if (coverageIndex >= 0) {
     24         le_uint16 altSetCount = SWAPW(alternateSetCount);
     25 
     26         if (coverageIndex < altSetCount) {
     27             Offset alternateSetTableOffset = SWAPW(alternateSetTableOffsetArray[coverageIndex]);
     28             const AlternateSetTable *alternateSetTable =
     29                 (const AlternateSetTable *) ((char *) this + alternateSetTableOffset);
     30             TTGlyphID alternate = SWAPW(alternateSetTable->alternateArray[0]);
     31 
     32             if (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, alternate))) {
     33                 glyphIterator->setCurrGlyphID(SWAPW(alternateSetTable->alternateArray[0]));
     34             }
     35 
     36             return 1;
     37         }
     38 
     39         // XXXX If we get here, the table's mal-formed...
     40     }
     41 
     42     return 0;
     43 }
     44 
     45 U_NAMESPACE_END
     46