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 - 2004 - All Rights Reserved 29 * 30 */ 31 32 33 #include "LETypes.h" 34 #include "LayoutTables.h" 35 #include "MorphTables.h" 36 #include "SubtableProcessor.h" 37 #include "IndicRearrangementProcessor.h" 38 #include "ContextualGlyphSubstProc.h" 39 #include "LigatureSubstProc.h" 40 #include "NonContextualGlyphSubstProc.h" 41 //#include "ContextualGlyphInsertionProcessor.h" 42 #include "LEGlyphStorage.h" 43 #include "LESwaps.h" 44 45 void MorphTableHeader::process(LEGlyphStorage &glyphStorage) const 46 { 47 const ChainHeader *chainHeader = chains; 48 le_uint32 chainCount = SWAPL(this->nChains); 49 le_uint32 chain; 50 51 for (chain = 0; chain < chainCount; chain += 1) { 52 FeatureFlags defaultFlags = SWAPL(chainHeader->defaultFlags); 53 le_uint32 chainLength = SWAPL(chainHeader->chainLength); 54 le_int16 nFeatureEntries = SWAPW(chainHeader->nFeatureEntries); 55 le_int16 nSubtables = SWAPW(chainHeader->nSubtables); 56 const MorphSubtableHeader *subtableHeader = 57 (const MorphSubtableHeader *)&chainHeader->featureTable[nFeatureEntries]; 58 le_int16 subtable; 59 60 for (subtable = 0; subtable < nSubtables; subtable += 1) { 61 le_int16 length = SWAPW(subtableHeader->length); 62 SubtableCoverage coverage = SWAPW(subtableHeader->coverage); 63 FeatureFlags subtableFeatures = SWAPL(subtableHeader->subtableFeatures); 64 65 // should check coverage more carefully... 66 if ((coverage & scfVertical) == 0 && (subtableFeatures & defaultFlags) != 0) { 67 subtableHeader->process(glyphStorage); 68 } 69 70 subtableHeader = (const MorphSubtableHeader *) ((char *)subtableHeader + length); 71 } 72 73 chainHeader = (const ChainHeader *)((char *)chainHeader + chainLength); 74 } 75 } 76 77 void MorphSubtableHeader::process(LEGlyphStorage &glyphStorage) const 78 { 79 SubtableProcessor *processor = NULL; 80 81 switch (SWAPW(coverage) & scfTypeMask) 82 { 83 case mstIndicRearrangement: 84 processor = new IndicRearrangementProcessor(this); 85 break; 86 87 case mstContextualGlyphSubstitution: 88 processor = new ContextualGlyphSubstitutionProcessor(this); 89 break; 90 91 case mstLigatureSubstitution: 92 processor = new LigatureSubstitutionProcessor(this); 93 break; 94 95 case mstReservedUnused: 96 break; 97 98 case mstNonContextualGlyphSubstitution: 99 processor = NonContextualGlyphSubstitutionProcessor::createInstance(this); 100 break; 101 102 /* 103 case mstContextualGlyphInsertion: 104 processor = new ContextualGlyphInsertionProcessor(this); 105 break; 106 */ 107 108 default: 109 break; 110 } 111 112 if (processor != NULL) { 113 processor->process(glyphStorage); 114 delete processor; 115 } 116 }