]> git.saurik.com Git - apple/icu.git/blob - icuSources/layout/MultipleSubstSubtables.cpp
ICU-3.13.tar.gz
[apple/icu.git] / icuSources / layout / MultipleSubstSubtables.cpp
1 /*
2 * %W% %E%
3 *
4 * (C) Copyright IBM Corp. 1998-2003 - All Rights Reserved
5 *
6 */
7
8 #include "LETypes.h"
9 #include "LEGlyphFilter.h"
10 #include "OpenTypeTables.h"
11 #include "GlyphSubstitutionTables.h"
12 #include "MultipleSubstSubtables.h"
13 #include "GlyphIterator.h"
14 #include "LESwaps.h"
15
16 U_NAMESPACE_BEGIN
17
18 le_uint32 MultipleSubstitutionSubtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const
19 {
20 LEGlyphID glyph = glyphIterator->getCurrGlyphID();
21 le_int32 coverageIndex = getGlyphCoverage(glyph);
22 le_uint16 seqCount = SWAPW(sequenceCount);
23
24 if (coverageIndex >= 0 && coverageIndex < seqCount) {
25 Offset sequenceTableOffset = SWAPW(sequenceTableOffsetArray[coverageIndex]);
26 const SequenceTable *sequenceTable = (const SequenceTable *) ((char *) this + sequenceTableOffset);
27 le_uint16 glyphCount = SWAPW(sequenceTable->glyphCount);
28
29 if (glyphCount == 0) {
30 glyphIterator->setCurrGlyphID(0xFFFF);
31 return 1;
32 } else if (glyphCount >= 1) {
33 TTGlyphID substitute = SWAPW(sequenceTable->substituteArray[0]);
34
35 if (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, substitute))) {
36 glyphIterator->setCurrGlyphID(substitute);
37 }
38
39 return 1;
40 } else {
41 // Can't do this 'till there's a way to
42 // grow the glyph array...
43 return 1;
44 }
45 }
46
47 return 0;
48 }
49
50 U_NAMESPACE_END