]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | /* |
2 | * %W% %W% | |
3 | * | |
57a6839d | 4 | * (C) Copyright IBM Corp. 1998 - 2013 - All Rights Reserved |
b75a7d8f A |
5 | * |
6 | */ | |
7 | ||
8 | ||
9 | #include "LETypes.h" | |
10 | #include "LayoutTables.h" | |
11 | #include "MorphTables.h" | |
12 | #include "SubtableProcessor.h" | |
13 | #include "IndicRearrangementProcessor.h" | |
14 | #include "ContextualGlyphSubstProc.h" | |
15 | #include "LigatureSubstProc.h" | |
16 | #include "NonContextualGlyphSubstProc.h" | |
17 | //#include "ContextualGlyphInsertionProcessor.h" | |
374ca955 | 18 | #include "LEGlyphStorage.h" |
b75a7d8f A |
19 | #include "LESwaps.h" |
20 | ||
21 | U_NAMESPACE_BEGIN | |
22 | ||
57a6839d | 23 | void MorphTableHeader::process(const LETableReference &base, LEGlyphStorage &glyphStorage, LEErrorCode &success) const |
b75a7d8f | 24 | { |
57a6839d A |
25 | le_uint32 chainCount = SWAPL(this->nChains); |
26 | LEReferenceTo<ChainHeader> chainHeader(base, success, chains); // moving header | |
27 | LEReferenceToArrayOf<ChainHeader> chainHeaderArray(base, success, chains, chainCount); | |
b75a7d8f A |
28 | le_uint32 chain; |
29 | ||
57a6839d | 30 | for (chain = 0; LE_SUCCESS(success) && (chain < chainCount); chain += 1) { |
b75a7d8f A |
31 | FeatureFlags defaultFlags = SWAPL(chainHeader->defaultFlags); |
32 | le_uint32 chainLength = SWAPL(chainHeader->chainLength); | |
33 | le_int16 nFeatureEntries = SWAPW(chainHeader->nFeatureEntries); | |
34 | le_int16 nSubtables = SWAPW(chainHeader->nSubtables); | |
57a6839d A |
35 | LEReferenceTo<MorphSubtableHeader> subtableHeader = |
36 | LEReferenceTo<MorphSubtableHeader>(chainHeader,success, &(chainHeader->featureTable[nFeatureEntries])); | |
b75a7d8f A |
37 | le_int16 subtable; |
38 | ||
57a6839d | 39 | for (subtable = 0; LE_SUCCESS(success) && (subtable < nSubtables); subtable += 1) { |
b75a7d8f A |
40 | le_int16 length = SWAPW(subtableHeader->length); |
41 | SubtableCoverage coverage = SWAPW(subtableHeader->coverage); | |
42 | FeatureFlags subtableFeatures = SWAPL(subtableHeader->subtableFeatures); | |
43 | ||
44 | // should check coverage more carefully... | |
57a6839d A |
45 | if ((coverage & scfVertical) == 0 && (subtableFeatures & defaultFlags) != 0 && LE_SUCCESS(success)) { |
46 | subtableHeader->process(subtableHeader, glyphStorage, success); | |
b75a7d8f A |
47 | } |
48 | ||
57a6839d | 49 | subtableHeader.addOffset(length, success); |
b75a7d8f | 50 | } |
57a6839d | 51 | chainHeader.addOffset(chainLength, success); |
b75a7d8f A |
52 | } |
53 | } | |
54 | ||
57a6839d | 55 | void MorphSubtableHeader::process(const LEReferenceTo<MorphSubtableHeader> &base, LEGlyphStorage &glyphStorage, LEErrorCode &success) const |
b75a7d8f A |
56 | { |
57 | SubtableProcessor *processor = NULL; | |
58 | ||
59 | switch (SWAPW(coverage) & scfTypeMask) | |
60 | { | |
61 | case mstIndicRearrangement: | |
57a6839d | 62 | processor = new IndicRearrangementProcessor(base, success); |
b75a7d8f A |
63 | break; |
64 | ||
65 | case mstContextualGlyphSubstitution: | |
57a6839d | 66 | processor = new ContextualGlyphSubstitutionProcessor(base, success); |
b75a7d8f A |
67 | break; |
68 | ||
69 | case mstLigatureSubstitution: | |
57a6839d | 70 | processor = new LigatureSubstitutionProcessor(base, success); |
b75a7d8f A |
71 | break; |
72 | ||
73 | case mstReservedUnused: | |
74 | break; | |
75 | ||
76 | case mstNonContextualGlyphSubstitution: | |
57a6839d | 77 | processor = NonContextualGlyphSubstitutionProcessor::createInstance(base, success); |
b75a7d8f A |
78 | break; |
79 | ||
80 | /* | |
81 | case mstContextualGlyphInsertion: | |
82 | processor = new ContextualGlyphInsertionProcessor(this); | |
83 | break; | |
84 | */ | |
85 | ||
86 | default: | |
87 | break; | |
88 | } | |
89 | ||
90 | if (processor != NULL) { | |
57a6839d A |
91 | if(LE_SUCCESS(success)) { |
92 | processor->process(glyphStorage, success); | |
93 | } | |
94 | delete processor; | |
b75a7d8f A |
95 | } |
96 | } | |
97 | ||
98 | U_NAMESPACE_END |