fontservices/textshaperplugin/IcuSource/layout/MorphTables.cpp
changeset 0 1fb32624e06b
equal deleted inserted replaced
-1:000000000000 0:1fb32624e06b
       
     1 /*
       
     2  * %W% %W%
       
     3  *
       
     4  * (C) Copyright IBM Corp. 1998 - 2004 - All Rights Reserved
       
     5  *
       
     6  */
       
     7 
       
     8 
       
     9 #include "LETypes.h"
       
    10 #include "LayoutTables.h"
       
    11 #include "MorphTables.h"
       
    12 #include "SubtableProcessor.h"
       
    13 #include "IndicRearrangementProcessor.h"
       
    14 #include "ContextualGlyphSubstProc.h"
       
    15 #include "LigatureSubstProc.h"
       
    16 #include "NonContextualGlyphSubstProc.h"
       
    17 //#include "ContextualGlyphInsertionProcessor.h"
       
    18 #include "LEGlyphStorage.h"
       
    19 #include "LESwaps.h"
       
    20 
       
    21 U_NAMESPACE_BEGIN
       
    22 
       
    23 void MorphTableHeader::process(LEGlyphStorage &glyphStorage) const
       
    24 {
       
    25     const ChainHeader *chainHeader = chains;
       
    26     le_uint32 chainCount = SWAPL(this->nChains);
       
    27     le_uint32 chain;
       
    28 
       
    29     for (chain = 0; chain < chainCount; chain += 1) {
       
    30         FeatureFlags defaultFlags = SWAPL(chainHeader->defaultFlags);
       
    31         le_uint32 chainLength = SWAPL(chainHeader->chainLength);
       
    32         le_int16 nFeatureEntries = SWAPW(chainHeader->nFeatureEntries);
       
    33         le_int16 nSubtables = SWAPW(chainHeader->nSubtables);
       
    34         const MorphSubtableHeader *subtableHeader =
       
    35             (const MorphSubtableHeader *)&chainHeader->featureTable[nFeatureEntries];
       
    36         le_int16 subtable;
       
    37 
       
    38         for (subtable = 0; subtable < nSubtables; subtable += 1) {
       
    39             le_int16 length = SWAPW(subtableHeader->length);
       
    40             SubtableCoverage coverage = SWAPW(subtableHeader->coverage);
       
    41             FeatureFlags subtableFeatures = SWAPL(subtableHeader->subtableFeatures);
       
    42 
       
    43             // should check coverage more carefully...
       
    44             if ((coverage & scfVertical) == 0 && (subtableFeatures & defaultFlags) != 0) {
       
    45                 subtableHeader->process(glyphStorage);
       
    46             }
       
    47 
       
    48             subtableHeader = (const MorphSubtableHeader *) ((char *)subtableHeader + length);
       
    49         }
       
    50 
       
    51         chainHeader = (const ChainHeader *)((char *)chainHeader + chainLength);
       
    52     }
       
    53 }
       
    54 
       
    55 void MorphSubtableHeader::process(LEGlyphStorage &glyphStorage) const
       
    56 {
       
    57     SubtableProcessor *processor = NULL;
       
    58 
       
    59     switch (SWAPW(coverage) & scfTypeMask)
       
    60     {
       
    61     case mstIndicRearrangement:
       
    62         processor = new IndicRearrangementProcessor(this);
       
    63         break;
       
    64 
       
    65     case mstContextualGlyphSubstitution:
       
    66         processor = new ContextualGlyphSubstitutionProcessor(this);
       
    67         break;
       
    68 
       
    69     case mstLigatureSubstitution:
       
    70         processor = new LigatureSubstitutionProcessor(this);
       
    71         break;
       
    72 
       
    73     case mstReservedUnused:
       
    74         break;
       
    75 
       
    76     case mstNonContextualGlyphSubstitution:
       
    77         processor = NonContextualGlyphSubstitutionProcessor::createInstance(this);
       
    78         break;
       
    79 
       
    80     /*
       
    81     case mstContextualGlyphInsertion:
       
    82         processor = new ContextualGlyphInsertionProcessor(this);
       
    83         break;
       
    84     */
       
    85 
       
    86     default:
       
    87         break;
       
    88     }
       
    89 
       
    90     if (processor != NULL) {
       
    91         processor->process(glyphStorage);
       
    92         delete processor;
       
    93     }
       
    94 }
       
    95 
       
    96 U_NAMESPACE_END