2000-11-28 20:56:52 +00:00
|
|
|
/*
|
|
|
|
*
|
2010-01-04 20:53:14 +00:00
|
|
|
* (C) Copyright IBM Corp. 1998-2010 - All Rights Reserved
|
2000-11-28 20:56:52 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "LETypes.h"
|
|
|
|
#include "OpenTypeTables.h"
|
|
|
|
#include "OpenTypeUtilities.h"
|
|
|
|
#include "ClassDefinitionTables.h"
|
|
|
|
#include "LESwaps.h"
|
|
|
|
|
2001-10-16 00:39:01 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2001-01-19 00:30:17 +00:00
|
|
|
le_int32 ClassDefinitionTable::getGlyphClass(LEGlyphID glyphID) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
|
|
|
switch(SWAPW(classFormat)) {
|
|
|
|
case 0:
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
2001-01-19 00:30:17 +00:00
|
|
|
const ClassDefFormat1Table *f1Table = (const ClassDefFormat1Table *) this;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
return f1Table->getGlyphClass(glyphID);
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
2001-01-19 00:30:17 +00:00
|
|
|
const ClassDefFormat2Table *f2Table = (const ClassDefFormat2Table *) this;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
return f2Table->getGlyphClass(glyphID);
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-19 00:30:17 +00:00
|
|
|
le_bool ClassDefinitionTable::hasGlyphClass(le_int32 glyphClass) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
|
|
|
switch(SWAPW(classFormat)) {
|
|
|
|
case 0:
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
2001-01-19 00:30:17 +00:00
|
|
|
const ClassDefFormat1Table *f1Table = (const ClassDefFormat1Table *) this;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
return f1Table->hasGlyphClass(glyphClass);
|
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
2001-01-19 00:30:17 +00:00
|
|
|
const ClassDefFormat2Table *f2Table = (const ClassDefFormat2Table *) this;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
return f2Table->hasGlyphClass(glyphClass);
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-19 00:30:17 +00:00
|
|
|
le_int32 ClassDefFormat1Table::getGlyphClass(LEGlyphID glyphID) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-02-05 00:05:40 +00:00
|
|
|
TTGlyphID ttGlyphID = (TTGlyphID) LE_GET_GLYPH(glyphID);
|
|
|
|
TTGlyphID firstGlyph = SWAPW(startGlyph);
|
|
|
|
TTGlyphID lastGlyph = firstGlyph + SWAPW(glyphCount);
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2010-01-04 20:53:14 +00:00
|
|
|
if (ttGlyphID >= firstGlyph && ttGlyphID < lastGlyph) {
|
2003-02-05 00:05:40 +00:00
|
|
|
return SWAPW(classValueArray[ttGlyphID - firstGlyph]);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-01-19 00:30:17 +00:00
|
|
|
le_bool ClassDefFormat1Table::hasGlyphClass(le_int32 glyphClass) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
|
|
|
le_uint16 count = SWAPW(glyphCount);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < count; i += 1) {
|
|
|
|
if (SWAPW(classValueArray[i]) == glyphClass) {
|
2003-12-08 22:43:41 +00:00
|
|
|
return TRUE;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-08 22:43:41 +00:00
|
|
|
return FALSE;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2001-01-19 00:30:17 +00:00
|
|
|
le_int32 ClassDefFormat2Table::getGlyphClass(LEGlyphID glyphID) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2003-02-05 00:05:40 +00:00
|
|
|
TTGlyphID ttGlyph = (TTGlyphID) LE_GET_GLYPH(glyphID);
|
2000-11-28 20:56:52 +00:00
|
|
|
le_uint16 rangeCount = SWAPW(classRangeCount);
|
|
|
|
le_int32 rangeIndex =
|
2003-02-05 00:05:40 +00:00
|
|
|
OpenTypeUtilities::getGlyphRangeIndex(ttGlyph, classRangeRecordArray, rangeCount);
|
2000-11-28 20:56:52 +00:00
|
|
|
|
|
|
|
if (rangeIndex < 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return SWAPW(classRangeRecordArray[rangeIndex].rangeValue);
|
|
|
|
}
|
|
|
|
|
2001-01-19 00:30:17 +00:00
|
|
|
le_bool ClassDefFormat2Table::hasGlyphClass(le_int32 glyphClass) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
|
|
|
le_uint16 rangeCount = SWAPW(classRangeCount);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < rangeCount; i += 1) {
|
|
|
|
if (SWAPW(classRangeRecordArray[i].rangeValue) == glyphClass) {
|
2003-12-08 22:43:41 +00:00
|
|
|
return TRUE;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-12-08 22:43:41 +00:00
|
|
|
return FALSE;
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
2001-10-16 00:39:01 +00:00
|
|
|
|
|
|
|
U_NAMESPACE_END
|