os/textandloc/fontservices/textshaperplugin/IcuSource/layout/SubstitutionLookups.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 "LEFontInstance.h"
sl@0
     9
#include "OpenTypeTables.h"
sl@0
    10
#include "GlyphSubstitutionTables.h"
sl@0
    11
#include "GlyphIterator.h"
sl@0
    12
#include "LookupProcessor.h"
sl@0
    13
#include "SubstitutionLookups.h"
sl@0
    14
#include "CoverageTables.h"
sl@0
    15
#include "LESwaps.h"
sl@0
    16
sl@0
    17
U_NAMESPACE_BEGIN
sl@0
    18
sl@0
    19
/*
sl@0
    20
    NOTE: This could be optimized somewhat by keeping track
sl@0
    21
    of the previous sequenceIndex in the loop and doing next()
sl@0
    22
    or prev() of the delta between that and the current
sl@0
    23
    sequenceIndex instead of always resetting to the front.
sl@0
    24
*/
sl@0
    25
void SubstitutionLookup::applySubstitutionLookups(
sl@0
    26
        LookupProcessor *lookupProcessor,
sl@0
    27
        SubstitutionLookupRecord *substLookupRecordArray,
sl@0
    28
        le_uint16 substCount,
sl@0
    29
        GlyphIterator *glyphIterator,
sl@0
    30
        const LEFontInstance *fontInstance,
sl@0
    31
        le_int32 position,
sl@0
    32
        LEErrorCode& success)
sl@0
    33
{
sl@0
    34
    if (LE_FAILURE(success)) {
sl@0
    35
        return;
sl@0
    36
    }
sl@0
    37
sl@0
    38
    GlyphIterator tempIterator(*glyphIterator);
sl@0
    39
sl@0
    40
    for (le_uint16 subst = 0; subst < substCount && LE_SUCCESS(success); subst += 1) {
sl@0
    41
        le_uint16 sequenceIndex = SWAPW(substLookupRecordArray[subst].sequenceIndex);
sl@0
    42
        le_uint16 lookupListIndex = SWAPW(substLookupRecordArray[subst].lookupListIndex);
sl@0
    43
sl@0
    44
        tempIterator.setCurrStreamPosition(position);
sl@0
    45
        tempIterator.next(sequenceIndex);
sl@0
    46
sl@0
    47
        lookupProcessor->applySingleLookup(lookupListIndex, &tempIterator,
sl@0
    48
            fontInstance, success);
sl@0
    49
    }
sl@0
    50
}
sl@0
    51
sl@0
    52
U_NAMESPACE_END