blob: 0b65f72c081d908c0a381620b676476d046ff545 [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001/*
2 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3 *
4 * This code is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License version 2 only, as
6 * published by the Free Software Foundation. Sun designates this
7 * particular file as subject to the "Classpath" exception as provided
8 * by Sun in the LICENSE file that accompanied this code.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
21 * CA 95054 USA or visit www.sun.com if you need additional information or
22 * have any questions.
23 *
24 */
25
26/*
27 *
28 * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
29 *
30 */
31
32#include "LETypes.h"
33#include "LEGlyphFilter.h"
34#include "LEFontInstance.h"
35#include "OpenTypeTables.h"
36#include "Features.h"
37#include "Lookups.h"
38#include "ScriptAndLanguage.h"
39#include "GlyphDefinitionTables.h"
40#include "GlyphSubstitutionTables.h"
41#include "SingleSubstitutionSubtables.h"
42#include "MultipleSubstSubtables.h"
43#include "AlternateSubstSubtables.h"
44#include "LigatureSubstSubtables.h"
45#include "ContextualSubstSubtables.h"
46#include "ExtensionSubtables.h"
47#include "LookupProcessor.h"
48#include "GlyphSubstLookupProc.h"
49#include "LESwaps.h"
50
51GlyphSubstitutionLookupProcessor::GlyphSubstitutionLookupProcessor(
52 const GlyphSubstitutionTableHeader *glyphSubstitutionTableHeader,
53 LETag scriptTag, LETag languageTag, const LEGlyphFilter *filter,
54 const FeatureMap *featureMap, le_int32 featureMapCount, le_bool featureOrder)
55 : LookupProcessor(
56 (char *) glyphSubstitutionTableHeader,
57 SWAPW(glyphSubstitutionTableHeader->scriptListOffset),
58 SWAPW(glyphSubstitutionTableHeader->featureListOffset),
59 SWAPW(glyphSubstitutionTableHeader->lookupListOffset),
60 scriptTag, languageTag, featureMap, featureMapCount, featureOrder)
61 , fFilter(filter)
62{
63 // anything?
64}
65
66GlyphSubstitutionLookupProcessor::GlyphSubstitutionLookupProcessor()
67{
68}
69
70le_uint32 GlyphSubstitutionLookupProcessor::applySubtable(const LookupSubtable *lookupSubtable, le_uint16 lookupType,
71 GlyphIterator *glyphIterator, const LEFontInstance *fontInstance) const
72{
73 le_uint32 delta = 0;
74
75 switch(lookupType)
76 {
77 case 0:
78 break;
79
80 case gsstSingle:
81 {
82 const SingleSubstitutionSubtable *subtable = (const SingleSubstitutionSubtable *) lookupSubtable;
83
84 delta = subtable->process(glyphIterator, fFilter);
85 break;
86 }
87
88 case gsstMultiple:
89 {
90 const MultipleSubstitutionSubtable *subtable = (const MultipleSubstitutionSubtable *) lookupSubtable;
91
92 delta = subtable->process(glyphIterator, fFilter);
93 break;
94 }
95
96 case gsstAlternate:
97 {
98 const AlternateSubstitutionSubtable *subtable = (const AlternateSubstitutionSubtable *) lookupSubtable;
99
100 delta = subtable->process(glyphIterator, fFilter);
101 break;
102 }
103
104 case gsstLigature:
105 {
106 const LigatureSubstitutionSubtable *subtable = (const LigatureSubstitutionSubtable *) lookupSubtable;
107
108 delta = subtable->process(glyphIterator, fFilter);
109 break;
110 }
111
112 case gsstContext:
113 {
114 const ContextualSubstitutionSubtable *subtable = (const ContextualSubstitutionSubtable *) lookupSubtable;
115
116 delta = subtable->process(this, glyphIterator, fontInstance);
117 break;
118 }
119
120 case gsstChainingContext:
121 {
122 const ChainingContextualSubstitutionSubtable *subtable = (const ChainingContextualSubstitutionSubtable *) lookupSubtable;
123
124 delta = subtable->process(this, glyphIterator, fontInstance);
125 break;
126 }
127
128 case gsstExtension:
129 {
130 const ExtensionSubtable *subtable = (const ExtensionSubtable *) lookupSubtable;
131
132 delta = subtable->process(this, lookupType, glyphIterator, fontInstance);
133 break;
134 }
135
136 default:
137 break;
138 }
139
140 return delta;
141}
142
143GlyphSubstitutionLookupProcessor::~GlyphSubstitutionLookupProcessor()
144{
145}