]> git.saurik.com Git - apple/icu.git/blob - icuSources/layout/MorphTables.cpp
ICU-531.48.tar.gz
[apple/icu.git] / icuSources / layout / MorphTables.cpp
1 /*
2 * %W% %W%
3 *
4 * (C) Copyright IBM Corp. 1998 - 2013 - All Rights Reserved
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"
18 #include "LEGlyphStorage.h"
19 #include "LESwaps.h"
20
21 U_NAMESPACE_BEGIN
22
23 void MorphTableHeader::process(const LETableReference &base, LEGlyphStorage &glyphStorage, LEErrorCode &success) const
24 {
25 le_uint32 chainCount = SWAPL(this->nChains);
26 LEReferenceTo<ChainHeader> chainHeader(base, success, chains); // moving header
27 LEReferenceToArrayOf<ChainHeader> chainHeaderArray(base, success, chains, chainCount);
28 le_uint32 chain;
29
30 for (chain = 0; LE_SUCCESS(success) && (chain < chainCount); chain += 1) {
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);
35 LEReferenceTo<MorphSubtableHeader> subtableHeader =
36 LEReferenceTo<MorphSubtableHeader>(chainHeader,success, &(chainHeader->featureTable[nFeatureEntries]));
37 le_int16 subtable;
38
39 for (subtable = 0; LE_SUCCESS(success) && (subtable < nSubtables); subtable += 1) {
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...
45 if ((coverage & scfVertical) == 0 && (subtableFeatures & defaultFlags) != 0 && LE_SUCCESS(success)) {
46 subtableHeader->process(subtableHeader, glyphStorage, success);
47 }
48
49 subtableHeader.addOffset(length, success);
50 }
51 chainHeader.addOffset(chainLength, success);
52 }
53 }
54
55 void MorphSubtableHeader::process(const LEReferenceTo<MorphSubtableHeader> &base, LEGlyphStorage &glyphStorage, LEErrorCode &success) const
56 {
57 SubtableProcessor *processor = NULL;
58
59 switch (SWAPW(coverage) & scfTypeMask)
60 {
61 case mstIndicRearrangement:
62 processor = new IndicRearrangementProcessor(base, success);
63 break;
64
65 case mstContextualGlyphSubstitution:
66 processor = new ContextualGlyphSubstitutionProcessor(base, success);
67 break;
68
69 case mstLigatureSubstitution:
70 processor = new LigatureSubstitutionProcessor(base, success);
71 break;
72
73 case mstReservedUnused:
74 break;
75
76 case mstNonContextualGlyphSubstitution:
77 processor = NonContextualGlyphSubstitutionProcessor::createInstance(base, success);
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) {
91 if(LE_SUCCESS(success)) {
92 processor->process(glyphStorage, success);
93 }
94 delete processor;
95 }
96 }
97
98 U_NAMESPACE_END