First public contribution.
3 * (C) Copyright IBM Corp. 1998-2004 - All Rights Reserved
8 #include "OpenTypeTables.h"
9 #include "OpenTypeUtilities.h"
10 #include "CoverageTables.h"
15 le_int32 CoverageTable::getGlyphCoverage(LEGlyphID glyphID) const
17 switch(SWAPW(coverageFormat))
24 const CoverageFormat1Table *f1Table = (const CoverageFormat1Table *) this;
26 return f1Table->getGlyphCoverage(glyphID);
31 const CoverageFormat2Table *f2Table = (const CoverageFormat2Table *) this;
33 return f2Table->getGlyphCoverage(glyphID);
41 le_int32 CoverageFormat1Table::getGlyphCoverage(LEGlyphID glyphID) const
43 TTGlyphID ttGlyphID = (TTGlyphID) LE_GET_GLYPH(glyphID);
44 le_uint16 count = SWAPW(glyphCount);
45 le_uint8 bit = OpenTypeUtilities::highBit(count);
46 le_uint16 power = 1 << bit;
47 le_uint16 extra = count - power;
48 le_uint16 probe = power;
51 if (SWAPW(glyphArray[extra]) <= ttGlyphID) {
55 while (probe > (1 << 0)) {
58 if (SWAPW(glyphArray[index + probe]) <= ttGlyphID) {
63 if (SWAPW(glyphArray[index]) == ttGlyphID) {
70 le_int32 CoverageFormat2Table::getGlyphCoverage(LEGlyphID glyphID) const
72 TTGlyphID ttGlyphID = (TTGlyphID) LE_GET_GLYPH(glyphID);
73 le_uint16 count = SWAPW(rangeCount);
75 OpenTypeUtilities::getGlyphRangeIndex(ttGlyphID, rangeRecordArray, count);
81 TTGlyphID firstInRange = SWAPW(rangeRecordArray[rangeIndex].firstGlyph);
82 le_uint16 startCoverageIndex = SWAPW(rangeRecordArray[rangeIndex].rangeValue);
84 return startCoverageIndex + (ttGlyphID - firstInRange);