1 /*
2 *
3 * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved
4 *
5 */
6
7 #include "LETypes.h"
8 #include "LEGlyphFilter.h"
9 #include "LEFontInstance.h"
10 #include "OpenTypeTables.h"
11 #include "ICUFeatures.h"
12 #include "Lookups.h"
13 #include "ScriptAndLanguage.h"
14 #include "GlyphDefinitionTables.h"
15 #include "GlyphSubstitutionTables.h"
16 #include "SingleSubstitutionSubtables.h"
17 #include "MultipleSubstSubtables.h"
18 #include "AlternateSubstSubtables.h"
19 #include "LigatureSubstSubtables.h"
20 #include "ContextualSubstSubtables.h"
21 #include "ExtensionSubtables.h"
22 #include "LookupProcessor.h"
23 #include "GlyphSubstLookupProc.h"
24 #include "LESwaps.h"
25
26 U_NAMESPACE_BEGIN
27
GlyphSubstitutionLookupProcessor(const LEReferenceTo<GlyphSubstitutionTableHeader> & glyphSubstitutionTableHeader,LETag scriptTag,LETag languageTag,const LEGlyphFilter * filter,const FeatureMap * featureMap,le_int32 featureMapCount,le_bool featureOrder,LEErrorCode & success)28 GlyphSubstitutionLookupProcessor::GlyphSubstitutionLookupProcessor(
29 const LEReferenceTo<GlyphSubstitutionTableHeader> &glyphSubstitutionTableHeader,
30 LETag scriptTag,
31 LETag languageTag,
32 const LEGlyphFilter *filter,
33 const FeatureMap *featureMap,
34 le_int32 featureMapCount,
35 le_bool featureOrder,
36 LEErrorCode& success)
37 : LookupProcessor(
38 glyphSubstitutionTableHeader,
39 SWAPW(glyphSubstitutionTableHeader->scriptListOffset),
40 SWAPW(glyphSubstitutionTableHeader->featureListOffset),
41 SWAPW(glyphSubstitutionTableHeader->lookupListOffset),
42 scriptTag, languageTag, featureMap, featureMapCount, featureOrder, success), fFilter(filter)
43 {
44 // anything?
45 }
46
GlyphSubstitutionLookupProcessor()47 GlyphSubstitutionLookupProcessor::GlyphSubstitutionLookupProcessor()
48 {
49 }
50
applySubtable(const LEReferenceTo<LookupSubtable> & lookupSubtable,le_uint16 lookupType,GlyphIterator * glyphIterator,const LEFontInstance * fontInstance,LEErrorCode & success) const51 le_uint32 GlyphSubstitutionLookupProcessor::applySubtable(const LEReferenceTo<LookupSubtable> &lookupSubtable, le_uint16 lookupType,
52 GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode& success) const
53 {
54 if (LE_FAILURE(success)) {
55 return 0;
56 }
57
58 le_uint32 delta = 0;
59
60 switch(lookupType)
61 {
62 case 0:
63 break;
64
65 case gsstSingle:
66 {
67 const LEReferenceTo<SingleSubstitutionSubtable> subtable(lookupSubtable, success);
68
69 delta = subtable->process(subtable, glyphIterator, success, fFilter);
70 break;
71 }
72
73 case gsstMultiple:
74 {
75 const LEReferenceTo<MultipleSubstitutionSubtable> subtable(lookupSubtable, success);
76
77 delta = subtable->process(subtable, glyphIterator, success, fFilter);
78 break;
79 }
80
81 case gsstAlternate:
82 {
83 const LEReferenceTo<AlternateSubstitutionSubtable> subtable(lookupSubtable, success);
84
85 delta = subtable->process(subtable, glyphIterator, success, fFilter);
86 break;
87 }
88
89 case gsstLigature:
90 {
91 const LEReferenceTo<LigatureSubstitutionSubtable> subtable(lookupSubtable, success);
92
93 delta = subtable->process(subtable, glyphIterator, success, fFilter);
94 break;
95 }
96
97 case gsstContext:
98 {
99 const LEReferenceTo<ContextualSubstitutionSubtable> subtable(lookupSubtable, success);
100
101 delta = subtable->process(this, glyphIterator, fontInstance, success);
102 break;
103 }
104
105 case gsstChainingContext:
106 {
107 const LEReferenceTo<ChainingContextualSubstitutionSubtable> subtable(lookupSubtable, success);
108
109 delta = subtable->process(this, glyphIterator, fontInstance, success);
110 break;
111 }
112
113 case gsstExtension:
114 {
115 const LEReferenceTo<ExtensionSubtable> subtable(lookupSubtable, success);
116
117 delta = subtable->process(this, subtable, lookupType, glyphIterator, fontInstance, success); // Google patch: add subtable
118 break;
119 }
120
121 default:
122 break;
123 }
124
125 return delta;
126 }
127
~GlyphSubstitutionLookupProcessor()128 GlyphSubstitutionLookupProcessor::~GlyphSubstitutionLookupProcessor()
129 {
130 }
131
132 U_NAMESPACE_END
133