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