2000-11-28 20:56:52 +00:00
|
|
|
/*
|
|
|
|
*
|
2013-04-18 21:24:51 +00:00
|
|
|
* (C) Copyright IBM Corp. 1998-2013 - 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
|
|
|
|
|
2013-04-18 21:24:51 +00:00
|
|
|
le_int32 ClassDefinitionTable::getGlyphClass(const LETableReference& base, LEGlyphID glyphID, LEErrorCode &success) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2013-04-18 21:24:51 +00:00
|
|
|
LEReferenceTo<ClassDefinitionTable> thisRef(base, success);
|
|
|
|
if (LE_FAILURE(success)) return 0;
|
|
|
|
|
|
|
|
switch(SWAPW(classFormat)) {
|
2000-11-28 20:56:52 +00:00
|
|
|
case 0:
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
2013-04-18 21:24:51 +00:00
|
|
|
const LEReferenceTo<ClassDefFormat1Table> f1Table(thisRef, success);
|
|
|
|
return f1Table->getGlyphClass(f1Table, glyphID, success);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
2013-04-18 21:24:51 +00:00
|
|
|
const LEReferenceTo<ClassDefFormat2Table> f2Table(thisRef, success);
|
|
|
|
return f2Table->getGlyphClass(f2Table, glyphID, success);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return 0;
|
2013-04-18 21:24:51 +00:00
|
|
|
}
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2013-04-18 21:24:51 +00:00
|
|
|
le_bool ClassDefinitionTable::hasGlyphClass(const LETableReference &base, le_int32 glyphClass, LEErrorCode &success) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2013-04-18 21:24:51 +00:00
|
|
|
LEReferenceTo<ClassDefinitionTable> thisRef(base, success);
|
|
|
|
if (LE_FAILURE(success)) return 0;
|
|
|
|
|
2000-11-28 20:56:52 +00:00
|
|
|
switch(SWAPW(classFormat)) {
|
|
|
|
case 0:
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
{
|
2013-04-18 21:24:51 +00:00
|
|
|
const LEReferenceTo<ClassDefFormat1Table> f1Table(thisRef, success);
|
|
|
|
return f1Table->hasGlyphClass(f1Table, glyphClass, success);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
{
|
2013-04-18 21:24:51 +00:00
|
|
|
const LEReferenceTo<ClassDefFormat2Table> f2Table(thisRef, success);
|
|
|
|
return f2Table->hasGlyphClass(f2Table, glyphClass, success);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-18 21:24:51 +00:00
|
|
|
le_int32 ClassDefFormat1Table::getGlyphClass(const LETableReference& base, LEGlyphID glyphID, LEErrorCode &success) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2013-04-18 21:24:51 +00:00
|
|
|
if(LE_FAILURE(success)) return 0;
|
|
|
|
|
|
|
|
le_uint16 count = SWAPW(glyphCount);
|
|
|
|
LEReferenceToArrayOf<le_uint16> classValueArrayRef(base, success, &classValueArray[0], count);
|
2003-02-05 00:05:40 +00:00
|
|
|
TTGlyphID ttGlyphID = (TTGlyphID) LE_GET_GLYPH(glyphID);
|
|
|
|
TTGlyphID firstGlyph = SWAPW(startGlyph);
|
2013-04-18 21:24:51 +00:00
|
|
|
TTGlyphID lastGlyph = firstGlyph + count;
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2013-04-18 21:24:51 +00:00
|
|
|
if (LE_SUCCESS(success) && ttGlyphID >= firstGlyph && ttGlyphID < lastGlyph) {
|
|
|
|
return SWAPW( classValueArrayRef(ttGlyphID - firstGlyph, success) );
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-04-18 21:24:51 +00:00
|
|
|
le_bool ClassDefFormat1Table::hasGlyphClass(const LETableReference &base, le_int32 glyphClass, LEErrorCode &success) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2013-04-18 21:24:51 +00:00
|
|
|
if(LE_FAILURE(success)) return 0;
|
|
|
|
le_uint16 count = SWAPW(glyphCount);
|
|
|
|
LEReferenceToArrayOf<le_uint16> classValueArrayRef(base, success, &classValueArray[0], count);
|
2000-11-28 20:56:52 +00:00
|
|
|
int i;
|
|
|
|
|
2013-04-18 21:24:51 +00:00
|
|
|
for (i = 0; LE_SUCCESS(success)&& (i < count); i += 1) {
|
|
|
|
if (SWAPW(classValueArrayRef(i,success)) == 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
|
|
|
}
|
|
|
|
|
2013-04-18 21:24:51 +00:00
|
|
|
le_int32 ClassDefFormat2Table::getGlyphClass(const LETableReference& base, LEGlyphID glyphID, LEErrorCode &success) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2013-04-18 21:24:51 +00:00
|
|
|
if(LE_FAILURE(success)) return 0;
|
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);
|
2013-04-18 21:24:51 +00:00
|
|
|
LEReferenceToArrayOf<GlyphRangeRecord> classRangeRecordArrayRef(base, success, &classRangeRecordArray[0], rangeCount);
|
2000-11-28 20:56:52 +00:00
|
|
|
le_int32 rangeIndex =
|
2013-04-18 21:24:51 +00:00
|
|
|
OpenTypeUtilities::getGlyphRangeIndex(ttGlyph, classRangeRecordArrayRef, success);
|
2000-11-28 20:56:52 +00:00
|
|
|
|
2013-04-18 21:24:51 +00:00
|
|
|
if (rangeIndex < 0 || LE_FAILURE(success)) {
|
2000-11-28 20:56:52 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-04-18 21:24:51 +00:00
|
|
|
return SWAPW(classRangeRecordArrayRef(rangeIndex, success).rangeValue);
|
2000-11-28 20:56:52 +00:00
|
|
|
}
|
|
|
|
|
2013-04-18 21:24:51 +00:00
|
|
|
le_bool ClassDefFormat2Table::hasGlyphClass(const LETableReference &base, le_int32 glyphClass, LEErrorCode &success) const
|
2000-11-28 20:56:52 +00:00
|
|
|
{
|
2013-04-18 21:24:51 +00:00
|
|
|
if(LE_FAILURE(success)) return 0;
|
2000-11-28 20:56:52 +00:00
|
|
|
le_uint16 rangeCount = SWAPW(classRangeCount);
|
2013-04-18 21:24:51 +00:00
|
|
|
LEReferenceToArrayOf<GlyphRangeRecord> classRangeRecordArrayRef(base, success, &classRangeRecordArray[0], rangeCount);
|
2000-11-28 20:56:52 +00:00
|
|
|
int i;
|
|
|
|
|
2013-04-18 21:24:51 +00:00
|
|
|
for (i = 0; i < rangeCount && LE_SUCCESS(success); i += 1) {
|
|
|
|
if (SWAPW(classRangeRecordArrayRef(i,success).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
|