Home | History | Annotate | Download | only in layout
      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 "SingleSubstitutionSubtables.h"
     12 #include "GlyphIterator.h"
     13 #include "LESwaps.h"
     14 
     15 U_NAMESPACE_BEGIN
     16 
     17 le_uint32 SingleSubstitutionSubtable::process(const LEReferenceTo<SingleSubstitutionSubtable> &base, GlyphIterator *glyphIterator, LEErrorCode &success, const LEGlyphFilter *filter) const
     18 {
     19     switch(SWAPW(subtableFormat))
     20     {
     21     case 0:
     22         return 0;
     23 
     24     case 1:
     25     {
     26       const LEReferenceTo<SingleSubstitutionFormat1Subtable> subtable(base, success, (const SingleSubstitutionFormat1Subtable *) this);
     27 
     28       return subtable->process(subtable, glyphIterator, success, filter);
     29     }
     30 
     31     case 2:
     32     {
     33       const LEReferenceTo<SingleSubstitutionFormat2Subtable> subtable(base, success, (const SingleSubstitutionFormat2Subtable *) this);
     34 
     35       return subtable->process(subtable, glyphIterator, success, filter);
     36     }
     37 
     38     default:
     39         return 0;
     40     }
     41 }
     42 
     43 le_uint32 SingleSubstitutionFormat1Subtable::process(const LEReferenceTo<SingleSubstitutionFormat1Subtable> &base, GlyphIterator *glyphIterator, LEErrorCode &success, const LEGlyphFilter *filter) const
     44 {
     45     LEGlyphID glyph = glyphIterator->getCurrGlyphID();
     46     le_int32 coverageIndex = getGlyphCoverage(base, glyph, success);
     47 
     48     if (coverageIndex >= 0) {
     49         TTGlyphID substitute = ((TTGlyphID) LE_GET_GLYPH(glyph)) + SWAPW(deltaGlyphID);
     50 
     51         if (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, substitute))) {
     52             glyphIterator->setCurrGlyphID(substitute);
     53         }
     54 
     55         return 1;
     56     }
     57 
     58     return 0;
     59 }
     60 
     61 le_uint32 SingleSubstitutionFormat2Subtable::process(const LEReferenceTo<SingleSubstitutionFormat2Subtable> &base, GlyphIterator *glyphIterator, LEErrorCode &success, const LEGlyphFilter *filter) const
     62 {
     63     LEGlyphID glyph = glyphIterator->getCurrGlyphID();
     64     le_int32 coverageIndex = getGlyphCoverage(base, glyph, success);
     65 
     66     if (coverageIndex >= 0) {
     67         TTGlyphID substitute = SWAPW(substituteArray[coverageIndex]);
     68 
     69         if (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, substitute))) {
     70             glyphIterator->setCurrGlyphID(substitute);
     71         }
     72 
     73         return 1;
     74     }
     75 
     76     return 0;
     77 }
     78 
     79 U_NAMESPACE_END
     80