os/textandloc/fontservices/textshaperplugin/IcuSource/layout/AlternateSubstSubtables.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/*
sl@0
     2
 *
sl@0
     3
 * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
sl@0
     4
 *
sl@0
     5
 */
sl@0
     6
sl@0
     7
#include "LETypes.h"
sl@0
     8
#include "LEGlyphFilter.h"
sl@0
     9
#include "OpenTypeTables.h"
sl@0
    10
#include "GlyphSubstitutionTables.h"
sl@0
    11
#include "AlternateSubstSubtables.h"
sl@0
    12
#include "GlyphIterator.h"
sl@0
    13
#include "LESwaps.h"
sl@0
    14
sl@0
    15
U_NAMESPACE_BEGIN
sl@0
    16
sl@0
    17
le_uint32 AlternateSubstitutionSubtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const
sl@0
    18
{
sl@0
    19
    // NOTE: For now, we'll just pick the first alternative...
sl@0
    20
    LEGlyphID glyph = glyphIterator->getCurrGlyphID();
sl@0
    21
    le_int32 coverageIndex = getGlyphCoverage(glyph);
sl@0
    22
sl@0
    23
    if (coverageIndex >= 0) {
sl@0
    24
        le_uint16 altSetCount = SWAPW(alternateSetCount);
sl@0
    25
sl@0
    26
        if (coverageIndex < altSetCount) {
sl@0
    27
            Offset alternateSetTableOffset = SWAPW(alternateSetTableOffsetArray[coverageIndex]);
sl@0
    28
            const AlternateSetTable *alternateSetTable =
sl@0
    29
                (const AlternateSetTable *) ((char *) this + alternateSetTableOffset);
sl@0
    30
            TTGlyphID alternate = SWAPW(alternateSetTable->alternateArray[0]);
sl@0
    31
sl@0
    32
            if (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, alternate))) {
sl@0
    33
                glyphIterator->setCurrGlyphID(SWAPW(alternateSetTable->alternateArray[0]));
sl@0
    34
            }
sl@0
    35
            
sl@0
    36
            return 1;
sl@0
    37
        }
sl@0
    38
sl@0
    39
        // XXXX If we get here, the table's mal-formed...
sl@0
    40
    }
sl@0
    41
sl@0
    42
    return 0;
sl@0
    43
}
sl@0
    44
sl@0
    45
U_NAMESPACE_END