]> git.saurik.com Git - apple/icu.git/blame - icuSources/layout/GlyphSubstLookupProc.cpp
ICU-59180.0.1.tar.gz
[apple/icu.git] / icuSources / layout / GlyphSubstLookupProc.cpp
CommitLineData
b75a7d8f 1/*
b75a7d8f 2 *
57a6839d 3 * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved
b75a7d8f
A
4 *
5 */
6
7#include "LETypes.h"
8#include "LEGlyphFilter.h"
9#include "LEFontInstance.h"
10#include "OpenTypeTables.h"
729e4ab9 11#include "ICUFeatures.h"
b75a7d8f
A
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
26U_NAMESPACE_BEGIN
27
28GlyphSubstitutionLookupProcessor::GlyphSubstitutionLookupProcessor(
57a6839d 29 const LEReferenceTo<GlyphSubstitutionTableHeader> &glyphSubstitutionTableHeader,
729e4ab9
A
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)
b75a7d8f 37 : LookupProcessor(
57a6839d 38 glyphSubstitutionTableHeader,
b75a7d8f
A
39 SWAPW(glyphSubstitutionTableHeader->scriptListOffset),
40 SWAPW(glyphSubstitutionTableHeader->featureListOffset),
41 SWAPW(glyphSubstitutionTableHeader->lookupListOffset),
729e4ab9 42 scriptTag, languageTag, featureMap, featureMapCount, featureOrder, success), fFilter(filter)
b75a7d8f
A
43{
44 // anything?
45}
46
47GlyphSubstitutionLookupProcessor::GlyphSubstitutionLookupProcessor()
48{
49}
50
57a6839d 51le_uint32 GlyphSubstitutionLookupProcessor::applySubtable(const LEReferenceTo<LookupSubtable> &lookupSubtable, le_uint16 lookupType,
729e4ab9 52 GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode& success) const
b75a7d8f 53{
729e4ab9
A
54 if (LE_FAILURE(success)) {
55 return 0;
56 }
57
b75a7d8f
A
58 le_uint32 delta = 0;
59
60 switch(lookupType)
61 {
62 case 0:
63 break;
64
65 case gsstSingle:
66 {
57a6839d 67 const LEReferenceTo<SingleSubstitutionSubtable> subtable(lookupSubtable, success);
b75a7d8f 68
57a6839d 69 delta = subtable->process(subtable, glyphIterator, success, fFilter);
b75a7d8f
A
70 break;
71 }
72
73 case gsstMultiple:
74 {
57a6839d 75 const LEReferenceTo<MultipleSubstitutionSubtable> subtable(lookupSubtable, success);
b75a7d8f 76
57a6839d 77 delta = subtable->process(subtable, glyphIterator, success, fFilter);
b75a7d8f
A
78 break;
79 }
80
81 case gsstAlternate:
82 {
57a6839d 83 const LEReferenceTo<AlternateSubstitutionSubtable> subtable(lookupSubtable, success);
b75a7d8f 84
57a6839d 85 delta = subtable->process(subtable, glyphIterator, success, fFilter);
b75a7d8f
A
86 break;
87 }
88
89 case gsstLigature:
90 {
57a6839d 91 const LEReferenceTo<LigatureSubstitutionSubtable> subtable(lookupSubtable, success);
b75a7d8f 92
57a6839d 93 delta = subtable->process(subtable, glyphIterator, success, fFilter);
b75a7d8f
A
94 break;
95 }
96
97 case gsstContext:
98 {
57a6839d 99 const LEReferenceTo<ContextualSubstitutionSubtable> subtable(lookupSubtable, success);
b75a7d8f 100
729e4ab9 101 delta = subtable->process(this, glyphIterator, fontInstance, success);
b75a7d8f
A
102 break;
103 }
104
105 case gsstChainingContext:
106 {
57a6839d 107 const LEReferenceTo<ChainingContextualSubstitutionSubtable> subtable(lookupSubtable, success);
b75a7d8f 108
729e4ab9 109 delta = subtable->process(this, glyphIterator, fontInstance, success);
b75a7d8f
A
110 break;
111 }
112
113 case gsstExtension:
114 {
57a6839d 115 const LEReferenceTo<ExtensionSubtable> subtable(lookupSubtable, success);
b75a7d8f 116
729e4ab9 117 delta = subtable->process(this, lookupType, glyphIterator, fontInstance, success);
b75a7d8f
A
118 break;
119 }
120
121 default:
122 break;
123 }
124
125 return delta;
126}
127
128GlyphSubstitutionLookupProcessor::~GlyphSubstitutionLookupProcessor()
129{
130}
131
132U_NAMESPACE_END