1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* 2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 3ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved 4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "LETypes.h" 8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "LEGlyphFilter.h" 9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "OpenTypeTables.h" 10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "GlyphSubstitutionTables.h" 11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "SingleSubstitutionSubtables.h" 12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "GlyphIterator.h" 13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "LESwaps.h" 14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_BEGIN 16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querule_uint32 SingleSubstitutionSubtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const 18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{ 19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru switch(SWAPW(subtableFormat)) 20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru { 21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru case 0: 22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return 0; 23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru case 1: 25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru { 26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const SingleSubstitutionFormat1Subtable *subtable = (const SingleSubstitutionFormat1Subtable *) this; 27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return subtable->process(glyphIterator, filter); 29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru case 2: 32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru { 33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru const SingleSubstitutionFormat2Subtable *subtable = (const SingleSubstitutionFormat2Subtable *) this; 34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return subtable->process(glyphIterator, filter); 36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru default: 39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return 0; 40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querule_uint32 SingleSubstitutionFormat1Subtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const 44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{ 45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru LEGlyphID glyph = glyphIterator->getCurrGlyphID(); 46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru le_int32 coverageIndex = getGlyphCoverage(glyph); 47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if (coverageIndex >= 0) { 49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru TTGlyphID substitute = ((TTGlyphID) LE_GET_GLYPH(glyph)) + SWAPW(deltaGlyphID); 50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, substitute))) { 52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru glyphIterator->setCurrGlyphID(substitute); 53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return 1; 56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return 0; 59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querule_uint32 SingleSubstitutionFormat2Subtable::process(GlyphIterator *glyphIterator, const LEGlyphFilter *filter) const 62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru{ 63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru LEGlyphID glyph = glyphIterator->getCurrGlyphID(); 64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru le_int32 coverageIndex = getGlyphCoverage(glyph); 65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if (coverageIndex >= 0) { 67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru TTGlyphID substitute = SWAPW(substituteArray[coverageIndex]); 68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru if (filter == NULL || filter->accept(LE_SET_GLYPH(glyph, substitute))) { 70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru glyphIterator->setCurrGlyphID(substitute); 71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return 1; 74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru } 75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru return 0; 77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru} 78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_END 80