1/* 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. Oracle designates this 7 * particular file as subject to the "Classpath" exception as provided 8 * by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 21 * or visit www.oracle.com if you need additional information or have any 22 * 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 "ICUFeatures.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 51U_NAMESPACE_BEGIN 52 53GlyphSubstitutionLookupProcessor::GlyphSubstitutionLookupProcessor( 54 const LEReferenceTo<GlyphSubstitutionTableHeader> &glyphSubstitutionTableHeader, 55 LETag scriptTag, 56 LETag languageTag, 57 const LEGlyphFilter *filter, 58 const FeatureMap *featureMap, 59 le_int32 featureMapCount, 60 le_bool featureOrder, 61 LEErrorCode& success) 62 : LookupProcessor( 63 glyphSubstitutionTableHeader, 64 SWAPW(glyphSubstitutionTableHeader->scriptListOffset), 65 SWAPW(glyphSubstitutionTableHeader->featureListOffset), 66 SWAPW(glyphSubstitutionTableHeader->lookupListOffset), 67 scriptTag, languageTag, featureMap, featureMapCount, featureOrder, success), fFilter(filter) 68{ 69 // anything? 70} 71 72GlyphSubstitutionLookupProcessor::GlyphSubstitutionLookupProcessor() 73{ 74} 75 76le_uint32 GlyphSubstitutionLookupProcessor::applySubtable(const LEReferenceTo<LookupSubtable> &lookupSubtable, le_uint16 lookupType, 77 GlyphIterator *glyphIterator, const LEFontInstance *fontInstance, LEErrorCode& success) const 78{ 79 if (LE_FAILURE(success)) { 80 return 0; 81 } 82 83 le_uint32 delta = 0; 84 85 switch(lookupType) 86 { 87 case 0: 88 break; 89 90 case gsstSingle: 91 { 92 const LEReferenceTo<SingleSubstitutionSubtable> subtable(lookupSubtable, success); 93 94 delta = subtable->process(subtable, glyphIterator, success, fFilter); 95 break; 96 } 97 98 case gsstMultiple: 99 { 100 const LEReferenceTo<MultipleSubstitutionSubtable> subtable(lookupSubtable, success); 101 102 delta = subtable->process(subtable, glyphIterator, success, fFilter); 103 break; 104 } 105 106 case gsstAlternate: 107 { 108 const LEReferenceTo<AlternateSubstitutionSubtable> subtable(lookupSubtable, success); 109 110 delta = subtable->process(subtable, glyphIterator, success, fFilter); 111 break; 112 } 113 114 case gsstLigature: 115 { 116 const LEReferenceTo<LigatureSubstitutionSubtable> subtable(lookupSubtable, success); 117 118 delta = subtable->process(subtable, glyphIterator, success, fFilter); 119 break; 120 } 121 122 case gsstContext: 123 { 124 const LEReferenceTo<ContextualSubstitutionSubtable> subtable(lookupSubtable, success); 125 126 delta = subtable->process(subtable, this, glyphIterator, fontInstance, success); 127 break; 128 } 129 130 case gsstChainingContext: 131 { 132 const LEReferenceTo<ChainingContextualSubstitutionSubtable> subtable(lookupSubtable, success); 133 134 delta = subtable->process(subtable, this, glyphIterator, fontInstance, success); 135 break; 136 } 137 138 case gsstExtension: 139 { 140 const LEReferenceTo<ExtensionSubtable> subtable(lookupSubtable, success); 141 142 delta = subtable->process(subtable, this, lookupType, glyphIterator, fontInstance, success); 143 break; 144 } 145 146 default: 147 break; 148 } 149 150 return delta; 151} 152 153GlyphSubstitutionLookupProcessor::~GlyphSubstitutionLookupProcessor() 154{ 155} 156 157U_NAMESPACE_END 158