42 #include "LEGlyphStorage.h" |
42 #include "LEGlyphStorage.h" |
43 #include "LESwaps.h" |
43 #include "LESwaps.h" |
44 |
44 |
45 U_NAMESPACE_BEGIN |
45 U_NAMESPACE_BEGIN |
46 |
46 |
47 void MorphTableHeader::process(LEGlyphStorage &glyphStorage) const |
47 void MorphTableHeader::process(const LETableReference &base, LEGlyphStorage &glyphStorage, LEErrorCode &success) const |
48 { |
48 { |
49 const ChainHeader *chainHeader = chains; |
49 le_uint32 chainCount = SWAPL(this->nChains); |
50 le_uint32 chainCount = SWAPL(this->nChains); |
50 LEReferenceTo<ChainHeader> chainHeader(base, success, chains); // moving header |
|
51 LEReferenceToArrayOf<ChainHeader> chainHeaderArray(base, success, chains, chainCount); |
51 le_uint32 chain; |
52 le_uint32 chain; |
52 |
53 |
53 for (chain = 0; chain < chainCount; chain += 1) { |
54 for (chain = 0; LE_SUCCESS(success) && (chain < chainCount); chain += 1) { |
54 FeatureFlags defaultFlags = SWAPL(chainHeader->defaultFlags); |
55 FeatureFlags defaultFlags = SWAPL(chainHeader->defaultFlags); |
55 le_uint32 chainLength = SWAPL(chainHeader->chainLength); |
56 le_uint32 chainLength = SWAPL(chainHeader->chainLength); |
56 le_int16 nFeatureEntries = SWAPW(chainHeader->nFeatureEntries); |
57 le_int16 nFeatureEntries = SWAPW(chainHeader->nFeatureEntries); |
57 le_int16 nSubtables = SWAPW(chainHeader->nSubtables); |
58 le_int16 nSubtables = SWAPW(chainHeader->nSubtables); |
58 const MorphSubtableHeader *subtableHeader = |
59 LEReferenceTo<MorphSubtableHeader> subtableHeader = |
59 (const MorphSubtableHeader *)&chainHeader->featureTable[nFeatureEntries]; |
60 LEReferenceTo<MorphSubtableHeader>(chainHeader,success, &(chainHeader->featureTable[nFeatureEntries])); |
60 le_int16 subtable; |
61 le_int16 subtable; |
61 |
62 |
62 for (subtable = 0; subtable < nSubtables; subtable += 1) { |
63 for (subtable = 0; LE_SUCCESS(success) && (subtable < nSubtables); subtable += 1) { |
63 le_int16 length = SWAPW(subtableHeader->length); |
64 le_int16 length = SWAPW(subtableHeader->length); |
64 SubtableCoverage coverage = SWAPW(subtableHeader->coverage); |
65 SubtableCoverage coverage = SWAPW(subtableHeader->coverage); |
65 FeatureFlags subtableFeatures = SWAPL(subtableHeader->subtableFeatures); |
66 FeatureFlags subtableFeatures = SWAPL(subtableHeader->subtableFeatures); |
66 |
67 |
67 // should check coverage more carefully... |
68 // should check coverage more carefully... |
68 if ((coverage & scfVertical) == 0 && (subtableFeatures & defaultFlags) != 0) { |
69 if ((coverage & scfVertical) == 0 && (subtableFeatures & defaultFlags) != 0 && LE_SUCCESS(success)) { |
69 subtableHeader->process(glyphStorage); |
70 subtableHeader->process(subtableHeader, glyphStorage, success); |
70 } |
71 } |
71 |
72 |
72 subtableHeader = (const MorphSubtableHeader *) ((char *)subtableHeader + length); |
73 subtableHeader.addOffset(length, success); |
73 } |
74 } |
74 |
75 chainHeader.addOffset(chainLength, success); |
75 chainHeader = (const ChainHeader *)((char *)chainHeader + chainLength); |
|
76 } |
76 } |
77 } |
77 } |
78 |
78 |
79 void MorphSubtableHeader::process(LEGlyphStorage &glyphStorage) const |
79 void MorphSubtableHeader::process(const LEReferenceTo<MorphSubtableHeader> &base, LEGlyphStorage &glyphStorage, LEErrorCode &success) const |
80 { |
80 { |
81 SubtableProcessor *processor = NULL; |
81 SubtableProcessor *processor = NULL; |
82 |
82 |
83 switch (SWAPW(coverage) & scfTypeMask) |
83 switch (SWAPW(coverage) & scfTypeMask) |
84 { |
84 { |
85 case mstIndicRearrangement: |
85 case mstIndicRearrangement: |
86 processor = new IndicRearrangementProcessor(this); |
86 processor = new IndicRearrangementProcessor(base, success); |
87 break; |
87 break; |
88 |
88 |
89 case mstContextualGlyphSubstitution: |
89 case mstContextualGlyphSubstitution: |
90 processor = new ContextualGlyphSubstitutionProcessor(this); |
90 processor = new ContextualGlyphSubstitutionProcessor(base, success); |
91 break; |
91 break; |
92 |
92 |
93 case mstLigatureSubstitution: |
93 case mstLigatureSubstitution: |
94 processor = new LigatureSubstitutionProcessor(this); |
94 processor = new LigatureSubstitutionProcessor(base, success); |
95 break; |
95 break; |
96 |
96 |
97 case mstReservedUnused: |
97 case mstReservedUnused: |
98 break; |
98 break; |
99 |
99 |
100 case mstNonContextualGlyphSubstitution: |
100 case mstNonContextualGlyphSubstitution: |
101 processor = NonContextualGlyphSubstitutionProcessor::createInstance(this); |
101 processor = NonContextualGlyphSubstitutionProcessor::createInstance(base, success); |
102 break; |
102 break; |
103 |
103 |
104 /* |
104 /* |
105 case mstContextualGlyphInsertion: |
105 case mstContextualGlyphInsertion: |
106 processor = new ContextualGlyphInsertionProcessor(this); |
106 processor = new ContextualGlyphInsertionProcessor(this); |