sl@0: /* sl@0: * sl@0: * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved sl@0: * sl@0: */ sl@0: sl@0: #include "LETypes.h" sl@0: #include "OpenTypeTables.h" sl@0: #include "OpenTypeUtilities.h" sl@0: #include "ClassDefinitionTables.h" sl@0: #include "LESwaps.h" sl@0: sl@0: U_NAMESPACE_BEGIN sl@0: sl@0: le_int32 ClassDefinitionTable::getGlyphClass(LEGlyphID glyphID) const sl@0: { sl@0: switch(SWAPW(classFormat)) { sl@0: case 0: sl@0: return 0; sl@0: sl@0: case 1: sl@0: { sl@0: const ClassDefFormat1Table *f1Table = (const ClassDefFormat1Table *) this; sl@0: sl@0: return f1Table->getGlyphClass(glyphID); sl@0: } sl@0: sl@0: case 2: sl@0: { sl@0: const ClassDefFormat2Table *f2Table = (const ClassDefFormat2Table *) this; sl@0: sl@0: return f2Table->getGlyphClass(glyphID); sl@0: } sl@0: sl@0: default: sl@0: return 0; sl@0: } sl@0: } sl@0: sl@0: le_bool ClassDefinitionTable::hasGlyphClass(le_int32 glyphClass) const sl@0: { sl@0: switch(SWAPW(classFormat)) { sl@0: case 0: sl@0: return 0; sl@0: sl@0: case 1: sl@0: { sl@0: const ClassDefFormat1Table *f1Table = (const ClassDefFormat1Table *) this; sl@0: sl@0: return f1Table->hasGlyphClass(glyphClass); sl@0: } sl@0: sl@0: case 2: sl@0: { sl@0: const ClassDefFormat2Table *f2Table = (const ClassDefFormat2Table *) this; sl@0: sl@0: return f2Table->hasGlyphClass(glyphClass); sl@0: } sl@0: sl@0: default: sl@0: return 0; sl@0: } sl@0: } sl@0: sl@0: le_int32 ClassDefFormat1Table::getGlyphClass(LEGlyphID glyphID) const sl@0: { sl@0: TTGlyphID ttGlyphID = (TTGlyphID) LE_GET_GLYPH(glyphID); sl@0: TTGlyphID firstGlyph = SWAPW(startGlyph); sl@0: TTGlyphID lastGlyph = firstGlyph + SWAPW(glyphCount); sl@0: sl@0: if (ttGlyphID > firstGlyph && ttGlyphID < lastGlyph) { sl@0: return SWAPW(classValueArray[ttGlyphID - firstGlyph]); sl@0: } sl@0: sl@0: return 0; sl@0: } sl@0: sl@0: le_bool ClassDefFormat1Table::hasGlyphClass(le_int32 glyphClass) const sl@0: { sl@0: le_uint16 count = SWAPW(glyphCount); sl@0: int i; sl@0: sl@0: for (i = 0; i < count; i += 1) { sl@0: if (SWAPW(classValueArray[i]) == glyphClass) { sl@0: return TRUE; sl@0: } sl@0: } sl@0: sl@0: return FALSE; sl@0: } sl@0: sl@0: le_int32 ClassDefFormat2Table::getGlyphClass(LEGlyphID glyphID) const sl@0: { sl@0: TTGlyphID ttGlyph = (TTGlyphID) LE_GET_GLYPH(glyphID); sl@0: le_uint16 rangeCount = SWAPW(classRangeCount); sl@0: le_int32 rangeIndex = sl@0: OpenTypeUtilities::getGlyphRangeIndex(ttGlyph, classRangeRecordArray, rangeCount); sl@0: sl@0: if (rangeIndex < 0) { sl@0: return 0; sl@0: } sl@0: sl@0: return SWAPW(classRangeRecordArray[rangeIndex].rangeValue); sl@0: } sl@0: sl@0: le_bool ClassDefFormat2Table::hasGlyphClass(le_int32 glyphClass) const sl@0: { sl@0: le_uint16 rangeCount = SWAPW(classRangeCount); sl@0: int i; sl@0: sl@0: for (i = 0; i < rangeCount; i += 1) { sl@0: if (SWAPW(classRangeRecordArray[i].rangeValue) == glyphClass) { sl@0: return TRUE; sl@0: } sl@0: } sl@0: sl@0: return FALSE; sl@0: } sl@0: sl@0: U_NAMESPACE_END