Home | History | Annotate | Download | only in layout
      1 /*
      2  * (C) Copyright IBM Corp. 1998 - 2010 - All Rights Reserved
      3  *
      4  */
      5 
      6 #include "LETypes.h"
      7 #include "LEFontInstance.h"
      8 #include "OpenTypeTables.h"
      9 #include "ICUFeatures.h"
     10 #include "Lookups.h"
     11 #include "ScriptAndLanguage.h"
     12 #include "GlyphDefinitionTables.h"
     13 #include "GlyphPositioningTables.h"
     14 #include "SinglePositioningSubtables.h"
     15 #include "PairPositioningSubtables.h"
     16 #include "CursiveAttachmentSubtables.h"
     17 #include "MarkToBasePosnSubtables.h"
     18 #include "MarkToLigaturePosnSubtables.h"
     19 #include "MarkToMarkPosnSubtables.h"
     20 //#include "ContextualPositioningSubtables.h"
     21 #include "ContextualSubstSubtables.h"
     22 #include "ExtensionSubtables.h"
     23 #include "LookupProcessor.h"
     24 #include "GlyphPosnLookupProc.h"
     25 #include "LESwaps.h"
     26 
     27 U_NAMESPACE_BEGIN
     28 
     29 // Aside from the names, the contextual positioning subtables are
     30 // the same as the contextual substitution subtables.
     31 typedef ContextualSubstitutionSubtable ContextualPositioningSubtable;
     32 typedef ChainingContextualSubstitutionSubtable ChainingContextualPositioningSubtable;
     33 
     34 GlyphPositioningLookupProcessor::GlyphPositioningLookupProcessor(
     35         const GlyphPositioningTableHeader *glyphPositioningTableHeader,
     36         LETag scriptTag,
     37         LETag languageTag,
     38         const FeatureMap *featureMap,
     39         le_int32 featureMapCount,
     40         le_bool featureOrder,
     41         LEErrorCode& success)
     42     : LookupProcessor(
     43                       (char *) glyphPositioningTableHeader,
     44                       SWAPW(glyphPositioningTableHeader->scriptListOffset),
     45                       SWAPW(glyphPositioningTableHeader->featureListOffset),
     46                       SWAPW(glyphPositioningTableHeader->lookupListOffset),
     47                       scriptTag,
     48                       languageTag,
     49                       featureMap,
     50                       featureMapCount,
     51                       featureOrder,
     52                       success
     53                       )
     54 {
     55     // anything?
     56 }
     57 
     58 GlyphPositioningLookupProcessor::GlyphPositioningLookupProcessor()
     59 {
     60 }
     61 
     62 le_uint32 GlyphPositioningLookupProcessor::applySubtable(const LookupSubtable *lookupSubtable, le_uint16 lookupType,
     63                                                        GlyphIterator *glyphIterator,
     64                                                        const LEFontInstance *fontInstance,
     65                                                        LEErrorCode& success) const
     66 {
     67     if (LE_FAILURE(success)) {
     68         return 0;
     69     }
     70 
     71     le_uint32 delta = 0;
     72 
     73     switch(lookupType)
     74     {
     75     case 0:
     76         break;
     77 
     78     case gpstSingle:
     79     {
     80         const SinglePositioningSubtable *subtable = (const SinglePositioningSubtable *) lookupSubtable;
     81 
     82         delta = subtable->process(glyphIterator, fontInstance);
     83         break;
     84     }
     85 
     86     case gpstPair:
     87     {
     88         const PairPositioningSubtable *subtable = (const PairPositioningSubtable *) lookupSubtable;
     89 
     90         delta = subtable->process(glyphIterator, fontInstance);
     91         break;
     92     }
     93 
     94     case gpstCursive:
     95     {
     96         const CursiveAttachmentSubtable *subtable = (const CursiveAttachmentSubtable *) lookupSubtable;
     97 
     98         delta = subtable->process(glyphIterator, fontInstance);
     99         break;
    100     }
    101 
    102     case gpstMarkToBase:
    103     {
    104         const MarkToBasePositioningSubtable *subtable = (const MarkToBasePositioningSubtable *) lookupSubtable;
    105 
    106         delta = subtable->process(glyphIterator, fontInstance);
    107         break;
    108     }
    109 
    110      case gpstMarkToLigature:
    111     {
    112         const MarkToLigaturePositioningSubtable *subtable = (const MarkToLigaturePositioningSubtable *) lookupSubtable;
    113 
    114         delta = subtable->process(glyphIterator, fontInstance);
    115         break;
    116     }
    117 
    118     case gpstMarkToMark:
    119     {
    120         const MarkToMarkPositioningSubtable *subtable = (const MarkToMarkPositioningSubtable *) lookupSubtable;
    121 
    122         delta = subtable->process(glyphIterator, fontInstance);
    123         break;
    124     }
    125 
    126    case gpstContext:
    127     {
    128         const ContextualPositioningSubtable *subtable = (const ContextualPositioningSubtable *) lookupSubtable;
    129 
    130         delta = subtable->process(this, glyphIterator, fontInstance, success);
    131         break;
    132     }
    133 
    134     case gpstChainedContext:
    135     {
    136         const ChainingContextualPositioningSubtable *subtable = (const ChainingContextualPositioningSubtable *) lookupSubtable;
    137 
    138         delta = subtable->process(this, glyphIterator, fontInstance, success);
    139         break;
    140     }
    141 
    142     case gpstExtension:
    143     {
    144         const ExtensionSubtable *subtable = (const ExtensionSubtable *) lookupSubtable;
    145 
    146         delta = subtable->process(this, lookupType, glyphIterator, fontInstance, success);
    147         break;
    148     }
    149 
    150     default:
    151         break;
    152     }
    153 
    154     return delta;
    155 }
    156 
    157 GlyphPositioningLookupProcessor::~GlyphPositioningLookupProcessor()
    158 {
    159 }
    160 
    161 U_NAMESPACE_END
    162