3 * (C) Copyright IBM Corp. 1998-2006 - 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
;
55 if (SWAPW(glyphArray
[extra
]) <= ttGlyphID
) {
59 while (probe
> (1 << 0)) {
62 if (SWAPW(glyphArray
[index
+ probe
]) <= ttGlyphID
) {
67 if (SWAPW(glyphArray
[index
]) == ttGlyphID
) {
74 le_int32
CoverageFormat2Table::getGlyphCoverage(LEGlyphID glyphID
) const
76 TTGlyphID ttGlyphID
= (TTGlyphID
) LE_GET_GLYPH(glyphID
);
77 le_uint16 count
= SWAPW(rangeCount
);
79 OpenTypeUtilities::getGlyphRangeIndex(ttGlyphID
, rangeRecordArray
, count
);
85 TTGlyphID firstInRange
= SWAPW(rangeRecordArray
[rangeIndex
].firstGlyph
);
86 le_uint16 startCoverageIndex
= SWAPW(rangeRecordArray
[rangeIndex
].rangeValue
);
88 return startCoverageIndex
+ (ttGlyphID
- firstInRange
);