]>
git.saurik.com Git - apple/icu.git/blob - icuSources/layout/ClassDefinitionTables.cpp
3 * (C) Copyright IBM Corp. 1998-2013 - All Rights Reserved
8 #include "OpenTypeTables.h"
9 #include "OpenTypeUtilities.h"
10 #include "ClassDefinitionTables.h"
15 le_int32
ClassDefinitionTable::getGlyphClass(const LETableReference
& base
, LEGlyphID glyphID
, LEErrorCode
&success
) const
17 LEReferenceTo
<ClassDefinitionTable
> thisRef(base
, success
);
18 if (LE_FAILURE(success
)) return 0;
20 switch(SWAPW(classFormat
)) {
26 const LEReferenceTo
<ClassDefFormat1Table
> f1Table(thisRef
, success
);
27 return f1Table
->getGlyphClass(f1Table
, glyphID
, success
);
32 const LEReferenceTo
<ClassDefFormat2Table
> f2Table(thisRef
, success
);
33 return f2Table
->getGlyphClass(f2Table
, glyphID
, success
);
41 le_bool
ClassDefinitionTable::hasGlyphClass(const LETableReference
&base
, le_int32 glyphClass
, LEErrorCode
&success
) const
43 LEReferenceTo
<ClassDefinitionTable
> thisRef(base
, success
);
44 if (LE_FAILURE(success
)) return 0;
46 switch(SWAPW(classFormat
)) {
52 const LEReferenceTo
<ClassDefFormat1Table
> f1Table(thisRef
, success
);
53 return f1Table
->hasGlyphClass(f1Table
, glyphClass
, success
);
58 const LEReferenceTo
<ClassDefFormat2Table
> f2Table(thisRef
, success
);
59 return f2Table
->hasGlyphClass(f2Table
, glyphClass
, success
);
67 le_int32
ClassDefFormat1Table::getGlyphClass(const LETableReference
& base
, LEGlyphID glyphID
, LEErrorCode
&success
) const
69 if(LE_FAILURE(success
)) return 0;
71 le_uint16 count
= SWAPW(glyphCount
);
72 LEReferenceToArrayOf
<le_uint16
> classValueArrayRef(base
, success
, &classValueArray
[0], count
);
73 TTGlyphID ttGlyphID
= (TTGlyphID
) LE_GET_GLYPH(glyphID
);
74 TTGlyphID firstGlyph
= SWAPW(startGlyph
);
75 TTGlyphID lastGlyph
= firstGlyph
+ count
;
77 if (LE_SUCCESS(success
) && ttGlyphID
>= firstGlyph
&& ttGlyphID
< lastGlyph
) {
78 return SWAPW( classValueArrayRef(ttGlyphID
- firstGlyph
, success
) );
84 le_bool
ClassDefFormat1Table::hasGlyphClass(const LETableReference
&base
, le_int32 glyphClass
, LEErrorCode
&success
) const
86 if(LE_FAILURE(success
)) return 0;
87 le_uint16 count
= SWAPW(glyphCount
);
88 LEReferenceToArrayOf
<le_uint16
> classValueArrayRef(base
, success
, &classValueArray
[0], count
);
91 for (i
= 0; LE_SUCCESS(success
)&& (i
< count
); i
+= 1) {
92 if (SWAPW(classValueArrayRef(i
,success
)) == glyphClass
) {
100 le_int32
ClassDefFormat2Table::getGlyphClass(const LETableReference
& base
, LEGlyphID glyphID
, LEErrorCode
&success
) const
102 if(LE_FAILURE(success
)) return 0;
103 TTGlyphID ttGlyph
= (TTGlyphID
) LE_GET_GLYPH(glyphID
);
104 le_uint16 rangeCount
= SWAPW(classRangeCount
);
105 LEReferenceToArrayOf
<GlyphRangeRecord
> classRangeRecordArrayRef(base
, success
, &classRangeRecordArray
[0], rangeCount
);
106 le_int32 rangeIndex
=
107 OpenTypeUtilities::getGlyphRangeIndex(ttGlyph
, classRangeRecordArrayRef
, success
);
109 if (rangeIndex
< 0 || LE_FAILURE(success
)) {
113 return SWAPW(classRangeRecordArrayRef(rangeIndex
, success
).rangeValue
);
116 le_bool
ClassDefFormat2Table::hasGlyphClass(const LETableReference
&base
, le_int32 glyphClass
, LEErrorCode
&success
) const
118 if(LE_FAILURE(success
)) return 0;
119 le_uint16 rangeCount
= SWAPW(classRangeCount
);
120 LEReferenceToArrayOf
<GlyphRangeRecord
> classRangeRecordArrayRef(base
, success
, &classRangeRecordArray
[0], rangeCount
);
123 for (i
= 0; i
< rangeCount
&& LE_SUCCESS(success
); i
+= 1) {
124 if (SWAPW(classRangeRecordArrayRef(i
,success
).rangeValue
) == glyphClass
) {