]> git.saurik.com Git - apple/icu.git/blob - icuSources/layout/SubstitutionLookups.cpp
ICU-59180.0.1.tar.gz
[apple/icu.git] / icuSources / layout / SubstitutionLookups.cpp
1 /*
2 *
3 * (C) Copyright IBM Corp. 1998-2008 - All Rights Reserved
4 *
5 */
6
7 #include "LETypes.h"
8 #include "LEFontInstance.h"
9 #include "OpenTypeTables.h"
10 #include "GlyphSubstitutionTables.h"
11 #include "GlyphIterator.h"
12 #include "LookupProcessor.h"
13 #include "SubstitutionLookups.h"
14 #include "CoverageTables.h"
15 #include "LESwaps.h"
16
17 U_NAMESPACE_BEGIN
18
19 /*
20 NOTE: This could be optimized somewhat by keeping track
21 of the previous sequenceIndex in the loop and doing next()
22 or prev() of the delta between that and the current
23 sequenceIndex instead of always resetting to the front.
24 */
25 void SubstitutionLookup::applySubstitutionLookups(
26 LookupProcessor *lookupProcessor,
27 SubstitutionLookupRecord *substLookupRecordArray,
28 le_uint16 substCount,
29 GlyphIterator *glyphIterator,
30 const LEFontInstance *fontInstance,
31 le_int32 position,
32 LEErrorCode& success)
33 {
34 if (LE_FAILURE(success)) {
35 return;
36 }
37
38 GlyphIterator tempIterator(*glyphIterator);
39
40 for (le_uint16 subst = 0; subst < substCount && LE_SUCCESS(success); subst += 1) {
41 le_uint16 sequenceIndex = SWAPW(substLookupRecordArray[subst].sequenceIndex);
42 le_uint16 lookupListIndex = SWAPW(substLookupRecordArray[subst].lookupListIndex);
43
44 tempIterator.setCurrStreamPosition(position);
45 tempIterator.next(sequenceIndex);
46
47 lookupProcessor->applySingleLookup(lookupListIndex, &tempIterator, fontInstance, success);
48 }
49 }
50
51 U_NAMESPACE_END