3 * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
8 #include "LEGlyphFilter.h"
9 #include "OpenTypeTables.h"
10 #include "GlyphSubstitutionTables.h"
11 #include "MultipleSubstSubtables.h"
12 #include "GlyphIterator.h"
17 le_uint32
MultipleSubstitutionSubtable::process(GlyphIterator
*glyphIterator
, const LEGlyphFilter
*filter
) const
19 LEGlyphID glyph
= glyphIterator
->getCurrGlyphID();
21 // If there's a filter, we only want to do the
22 // substitution if the *input* glyphs doesn't
25 // FIXME: is this always the right thing to do?
26 // FIXME: should this only be done for a non-zero
28 if (filter
!= NULL
&& filter
->accept(glyph
)) {
32 le_int32 coverageIndex
= getGlyphCoverage(glyph
);
33 le_uint16 seqCount
= SWAPW(sequenceCount
);
35 if (coverageIndex
>= 0 && coverageIndex
< seqCount
) {
36 Offset sequenceTableOffset
= SWAPW(sequenceTableOffsetArray
[coverageIndex
]);
37 const SequenceTable
*sequenceTable
= (const SequenceTable
*) ((char *) this + sequenceTableOffset
);
38 le_uint16 glyphCount
= SWAPW(sequenceTable
->glyphCount
);
40 if (glyphCount
== 0) {
41 glyphIterator
->setCurrGlyphID(0xFFFF);
43 } else if (glyphCount
== 1) {
44 TTGlyphID substitute
= SWAPW(sequenceTable
->substituteArray
[0]);
46 if (filter
!= NULL
&& ! filter
->accept(LE_SET_GLYPH(glyph
, substitute
))) {
50 glyphIterator
->setCurrGlyphID(substitute
);
53 // If there's a filter, make sure all of the output glyphs
56 for (le_int32 i
= 0; i
< glyphCount
; i
+= 1) {
57 TTGlyphID substitute
= SWAPW(sequenceTable
->substituteArray
[i
]);
59 if (! filter
->accept(substitute
)) {
65 LEGlyphID
*newGlyphs
= glyphIterator
->insertGlyphs(glyphCount
);
66 le_int32 insert
= 0, direction
= 1;
68 if (glyphIterator
->isRightToLeft()) {
69 insert
= glyphCount
- 1;
73 for (le_int32 i
= 0; i
< glyphCount
; i
+= 1) {
74 TTGlyphID substitute
= SWAPW(sequenceTable
->substituteArray
[i
]);
76 newGlyphs
[insert
] = LE_SET_GLYPH(glyph
, substitute
);