GlyphSubstLookupProc.cpp 4.7 KB
Newer Older
D
duke 已提交
1 2 3 4 5
/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
6
 * published by the Free Software Foundation.  Oracle designates this
D
duke 已提交
7
 * particular file as subject to the "Classpath" exception as provided
8
 * by Oracle in the LICENSE file that accompanied this code.
D
duke 已提交
9 10 11 12 13 14 15 16 17 18 19
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
20 21 22
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
D
duke 已提交
23 24 25 26 27 28 29 30 31 32 33 34 35
 *
 */

/*
 *
 * (C) Copyright IBM Corp. 1998-2005 - All Rights Reserved
 *
 */

#include "LETypes.h"
#include "LEGlyphFilter.h"
#include "LEFontInstance.h"
#include "OpenTypeTables.h"
S
srl 已提交
36
#include "ICUFeatures.h"
D
duke 已提交
37 38 39 40 41 42 43 44 45 46 47 48 49 50
#include "Lookups.h"
#include "ScriptAndLanguage.h"
#include "GlyphDefinitionTables.h"
#include "GlyphSubstitutionTables.h"
#include "SingleSubstitutionSubtables.h"
#include "MultipleSubstSubtables.h"
#include "AlternateSubstSubtables.h"
#include "LigatureSubstSubtables.h"
#include "ContextualSubstSubtables.h"
#include "ExtensionSubtables.h"
#include "LookupProcessor.h"
#include "GlyphSubstLookupProc.h"
#include "LESwaps.h"

51 52
U_NAMESPACE_BEGIN

D
duke 已提交
53
GlyphSubstitutionLookupProcessor::GlyphSubstitutionLookupProcessor(
P
prr 已提交
54
        const LEReferenceTo<GlyphSubstitutionTableHeader> &glyphSubstitutionTableHeader,
S
srl 已提交
55 56 57 58 59 60 61
        LETag scriptTag,
        LETag languageTag,
        const LEGlyphFilter *filter,
        const FeatureMap *featureMap,
        le_int32 featureMapCount,
        le_bool featureOrder,
        LEErrorCode& success)
D
duke 已提交
62
    : LookupProcessor(
P
prr 已提交
63
                      glyphSubstitutionTableHeader,
D
duke 已提交
64 65 66
                      SWAPW(glyphSubstitutionTableHeader->scriptListOffset),
                      SWAPW(glyphSubstitutionTableHeader->featureListOffset),
                      SWAPW(glyphSubstitutionTableHeader->lookupListOffset),
S
srl 已提交
67
                      scriptTag, languageTag, featureMap, featureMapCount, featureOrder, success), fFilter(filter)
D
duke 已提交
68 69 70 71 72 73 74 75
{
    // anything?
}

GlyphSubstitutionLookupProcessor::GlyphSubstitutionLookupProcessor()
{
}

P
prr 已提交
76
le_uint32 GlyphSubstitutionLookupProcessor::applySubtable(const LEReferenceTo<LookupSubtable> &lookupSubtable, le_uint16 lookupType,
S
srl 已提交
77
                                                       GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode& success) const
D
duke 已提交
78
{
S
srl 已提交
79 80 81 82
    if (LE_FAILURE(success)) {
        return 0;
    }

D
duke 已提交
83 84 85 86 87 88 89 90 91
    le_uint32 delta = 0;

    switch(lookupType)
    {
    case 0:
        break;

    case gsstSingle:
    {
P
prr 已提交
92
        const LEReferenceTo<SingleSubstitutionSubtable> subtable(lookupSubtable, success);
D
duke 已提交
93

P
prr 已提交
94
        delta = subtable->process(subtable, glyphIterator, success, fFilter);
D
duke 已提交
95 96 97 98 99
        break;
    }

    case gsstMultiple:
    {
P
prr 已提交
100
        const LEReferenceTo<MultipleSubstitutionSubtable> subtable(lookupSubtable, success);
D
duke 已提交
101

P
prr 已提交
102
        delta = subtable->process(subtable, glyphIterator, success, fFilter);
D
duke 已提交
103 104 105 106 107
        break;
    }

    case gsstAlternate:
    {
P
prr 已提交
108
        const LEReferenceTo<AlternateSubstitutionSubtable> subtable(lookupSubtable, success);
D
duke 已提交
109

P
prr 已提交
110
        delta = subtable->process(subtable, glyphIterator, success, fFilter);
D
duke 已提交
111 112 113 114 115
        break;
    }

    case gsstLigature:
    {
P
prr 已提交
116
        const LEReferenceTo<LigatureSubstitutionSubtable> subtable(lookupSubtable, success);
D
duke 已提交
117

P
prr 已提交
118
        delta = subtable->process(subtable, glyphIterator, success, fFilter);
D
duke 已提交
119 120 121 122 123
        break;
    }

    case gsstContext:
    {
P
prr 已提交
124
        const LEReferenceTo<ContextualSubstitutionSubtable> subtable(lookupSubtable, success);
D
duke 已提交
125

S
srl 已提交
126
        delta = subtable->process(this, glyphIterator, fontInstance, success);
D
duke 已提交
127 128 129 130 131
        break;
    }

    case gsstChainingContext:
    {
P
prr 已提交
132
        const LEReferenceTo<ChainingContextualSubstitutionSubtable> subtable(lookupSubtable, success);
D
duke 已提交
133

S
srl 已提交
134
        delta = subtable->process(this, glyphIterator, fontInstance, success);
D
duke 已提交
135 136 137 138 139
        break;
    }

    case gsstExtension:
    {
P
prr 已提交
140
        const LEReferenceTo<ExtensionSubtable> subtable(lookupSubtable, success);
D
duke 已提交
141

S
srl 已提交
142
        delta = subtable->process(this, lookupType, glyphIterator, fontInstance, success);
D
duke 已提交
143 144 145 146 147 148 149 150 151 152 153 154 155
        break;
    }

    default:
        break;
    }

    return delta;
}

GlyphSubstitutionLookupProcessor::~GlyphSubstitutionLookupProcessor()
{
}
156 157

U_NAMESPACE_END