[HB] Use OffsetTo<> for Coverage
This commit is contained in:
parent
3d54bd1293
commit
238c855fcd
|
@ -240,6 +240,7 @@ struct GDEF {
|
||||||
inline bool has_attach_list () const { return attachList != 0; }
|
inline bool has_attach_list () const { return attachList != 0; }
|
||||||
inline bool has_lig_caret_list () const { return ligCaretList != 0; }
|
inline bool has_lig_caret_list () const { return ligCaretList != 0; }
|
||||||
|
|
||||||
|
private:
|
||||||
Fixed version; /* Version of the GDEF table--initially
|
Fixed version; /* Version of the GDEF table--initially
|
||||||
* 0x00010000 */
|
* 0x00010000 */
|
||||||
OffsetTo<ClassDef>
|
OffsetTo<ClassDef>
|
||||||
|
|
|
@ -34,12 +34,6 @@
|
||||||
|
|
||||||
#include "harfbuzz-buffer-private.h" /* XXX */
|
#include "harfbuzz-buffer-private.h" /* XXX */
|
||||||
|
|
||||||
#define DEFINE_GET_GLYPH_COVERAGE(name) \
|
|
||||||
inline unsigned int get_##name (hb_codepoint_t glyph) const { \
|
|
||||||
const Coverage &c = get_coverage (); \
|
|
||||||
return c.get_coverage (glyph); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define SUBTABLE_SUBSTITUTE_ARGS_DEF \
|
#define SUBTABLE_SUBSTITUTE_ARGS_DEF \
|
||||||
hb_ot_layout_t *layout, \
|
hb_ot_layout_t *layout, \
|
||||||
hb_buffer_t *buffer, \
|
hb_buffer_t *buffer, \
|
||||||
|
@ -58,12 +52,10 @@ struct SingleSubstFormat1 {
|
||||||
friend struct SingleSubst;
|
friend struct SingleSubst;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DEFINE_GET_ACCESSOR (Coverage, coverage, coverage);
|
|
||||||
DEFINE_GET_GLYPH_COVERAGE (glyph_coverage);
|
|
||||||
|
|
||||||
inline bool single_substitute (hb_codepoint_t &glyph_id) const {
|
inline bool single_substitute (hb_codepoint_t &glyph_id) const {
|
||||||
|
|
||||||
unsigned int index = get_glyph_coverage (glyph_id);
|
unsigned int index = (this+coverage) (glyph_id);
|
||||||
if (NOT_COVERED == index)
|
if (NOT_COVERED == index)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -74,7 +66,8 @@ struct SingleSubstFormat1 {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
USHORT substFormat; /* Format identifier--format = 1 */
|
USHORT substFormat; /* Format identifier--format = 1 */
|
||||||
Offset coverage; /* Offset to Coverage table--from
|
OffsetTo<Coverage>
|
||||||
|
coverage; /* Offset to Coverage table--from
|
||||||
* beginning of Substitution table */
|
* beginning of Substitution table */
|
||||||
SHORT deltaGlyphID; /* Add to original GlyphID to get
|
SHORT deltaGlyphID; /* Add to original GlyphID to get
|
||||||
* substitute GlyphID */
|
* substitute GlyphID */
|
||||||
|
@ -86,12 +79,10 @@ struct SingleSubstFormat2 {
|
||||||
friend struct SingleSubst;
|
friend struct SingleSubst;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DEFINE_GET_ACCESSOR (Coverage, coverage, coverage);
|
|
||||||
DEFINE_GET_GLYPH_COVERAGE (glyph_coverage);
|
|
||||||
|
|
||||||
inline bool single_substitute (hb_codepoint_t &glyph_id) const {
|
inline bool single_substitute (hb_codepoint_t &glyph_id) const {
|
||||||
|
|
||||||
unsigned int index = get_glyph_coverage (glyph_id);
|
unsigned int index = (this+coverage) (glyph_id);
|
||||||
|
|
||||||
if (index >= glyphCount)
|
if (index >= glyphCount)
|
||||||
return false;
|
return false;
|
||||||
|
@ -102,7 +93,8 @@ struct SingleSubstFormat2 {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
USHORT substFormat; /* Format identifier--format = 2 */
|
USHORT substFormat; /* Format identifier--format = 2 */
|
||||||
Offset coverage; /* Offset to Coverage table--from
|
OffsetTo<Coverage>
|
||||||
|
coverage; /* Offset to Coverage table--from
|
||||||
* beginning of Substitution table */
|
* beginning of Substitution table */
|
||||||
USHORT glyphCount; /* Number of GlyphIDs in the Substitute
|
USHORT glyphCount; /* Number of GlyphIDs in the Substitute
|
||||||
* array */
|
* array */
|
||||||
|
@ -209,8 +201,6 @@ struct MultipleSubstFormat1 {
|
||||||
private:
|
private:
|
||||||
/* Sequence tables, in Coverage Index order */
|
/* Sequence tables, in Coverage Index order */
|
||||||
DEFINE_OFFSET_ARRAY_TYPE (Sequence, sequence, sequenceCount);
|
DEFINE_OFFSET_ARRAY_TYPE (Sequence, sequence, sequenceCount);
|
||||||
DEFINE_GET_ACCESSOR (Coverage, coverage, coverage);
|
|
||||||
DEFINE_GET_GLYPH_COVERAGE (glyph_coverage);
|
|
||||||
|
|
||||||
inline bool substitute (SUBTABLE_SUBSTITUTE_ARGS_DEF) const {
|
inline bool substitute (SUBTABLE_SUBSTITUTE_ARGS_DEF) const {
|
||||||
|
|
||||||
|
@ -220,7 +210,7 @@ struct MultipleSubstFormat1 {
|
||||||
|
|
||||||
hb_codepoint_t glyph_id = IN_CURGLYPH ();
|
hb_codepoint_t glyph_id = IN_CURGLYPH ();
|
||||||
|
|
||||||
unsigned int index = get_glyph_coverage (glyph_id);
|
unsigned int index = (this+coverage) (glyph_id);
|
||||||
|
|
||||||
const Sequence &seq = (*this)[index];
|
const Sequence &seq = (*this)[index];
|
||||||
return seq.substitute_sequence (SUBTABLE_SUBSTITUTE_ARGS, property);
|
return seq.substitute_sequence (SUBTABLE_SUBSTITUTE_ARGS, property);
|
||||||
|
@ -228,7 +218,8 @@ struct MultipleSubstFormat1 {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
USHORT substFormat; /* Format identifier--format = 1 */
|
USHORT substFormat; /* Format identifier--format = 1 */
|
||||||
Offset coverage; /* Offset to Coverage table--from
|
OffsetTo<Coverage>
|
||||||
|
coverage; /* Offset to Coverage table--from
|
||||||
* beginning of Substitution table */
|
* beginning of Substitution table */
|
||||||
USHORT sequenceCount; /* Number of Sequence table offsets in
|
USHORT sequenceCount; /* Number of Sequence table offsets in
|
||||||
* the Sequence array */
|
* the Sequence array */
|
||||||
|
@ -281,8 +272,6 @@ struct AlternateSubstFormat1 {
|
||||||
private:
|
private:
|
||||||
/* AlternateSet tables, in Coverage Index order */
|
/* AlternateSet tables, in Coverage Index order */
|
||||||
DEFINE_OFFSET_ARRAY_TYPE (AlternateSet, alternateSet, alternateSetCount);
|
DEFINE_OFFSET_ARRAY_TYPE (AlternateSet, alternateSet, alternateSetCount);
|
||||||
DEFINE_GET_ACCESSOR (Coverage, coverage, coverage);
|
|
||||||
DEFINE_GET_GLYPH_COVERAGE (glyph_coverage);
|
|
||||||
|
|
||||||
inline bool substitute (SUBTABLE_SUBSTITUTE_ARGS_DEF) const {
|
inline bool substitute (SUBTABLE_SUBSTITUTE_ARGS_DEF) const {
|
||||||
|
|
||||||
|
@ -292,7 +281,7 @@ struct AlternateSubstFormat1 {
|
||||||
|
|
||||||
hb_codepoint_t glyph_id = IN_CURGLYPH ();
|
hb_codepoint_t glyph_id = IN_CURGLYPH ();
|
||||||
|
|
||||||
unsigned int index = get_glyph_coverage (glyph_id);
|
unsigned int index = (this+coverage) (glyph_id);
|
||||||
|
|
||||||
const AlternateSet &alt_set = (*this)[index];
|
const AlternateSet &alt_set = (*this)[index];
|
||||||
|
|
||||||
|
@ -326,7 +315,8 @@ struct AlternateSubstFormat1 {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
USHORT substFormat; /* Format identifier--format = 1 */
|
USHORT substFormat; /* Format identifier--format = 1 */
|
||||||
Offset coverage; /* Offset to Coverage table--from
|
OffsetTo<Coverage>
|
||||||
|
coverage; /* Offset to Coverage table--from
|
||||||
* beginning of Substitution table */
|
* beginning of Substitution table */
|
||||||
USHORT alternateSetCount; /* Number of AlternateSet tables */
|
USHORT alternateSetCount; /* Number of AlternateSet tables */
|
||||||
Offset alternateSet[]; /* Array of offsets to AlternateSet
|
Offset alternateSet[]; /* Array of offsets to AlternateSet
|
||||||
|
@ -475,8 +465,6 @@ struct LigatureSubstFormat1 {
|
||||||
private:
|
private:
|
||||||
/* LigatureSet tables, in Coverage Index order */
|
/* LigatureSet tables, in Coverage Index order */
|
||||||
DEFINE_OFFSET_ARRAY_TYPE (LigatureSet, ligatureSet, ligSetCount);
|
DEFINE_OFFSET_ARRAY_TYPE (LigatureSet, ligatureSet, ligSetCount);
|
||||||
DEFINE_GET_ACCESSOR (Coverage, coverage, coverage);
|
|
||||||
DEFINE_GET_GLYPH_COVERAGE (glyph_coverage);
|
|
||||||
|
|
||||||
inline bool substitute (SUBTABLE_SUBSTITUTE_ARGS_DEF) const {
|
inline bool substitute (SUBTABLE_SUBSTITUTE_ARGS_DEF) const {
|
||||||
|
|
||||||
|
@ -486,7 +474,7 @@ struct LigatureSubstFormat1 {
|
||||||
|
|
||||||
hb_codepoint_t glyph_id = IN_CURGLYPH ();
|
hb_codepoint_t glyph_id = IN_CURGLYPH ();
|
||||||
|
|
||||||
unsigned int index = get_glyph_coverage (glyph_id);
|
unsigned int index = (this+coverage) (glyph_id);
|
||||||
|
|
||||||
bool first_is_mark = (property == HB_OT_LAYOUT_GLYPH_CLASS_MARK ||
|
bool first_is_mark = (property == HB_OT_LAYOUT_GLYPH_CLASS_MARK ||
|
||||||
property & LookupFlag::MarkAttachmentType);
|
property & LookupFlag::MarkAttachmentType);
|
||||||
|
@ -497,7 +485,8 @@ struct LigatureSubstFormat1 {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
USHORT substFormat; /* Format identifier--format = 1 */
|
USHORT substFormat; /* Format identifier--format = 1 */
|
||||||
Offset coverage; /* Offset to Coverage table--from
|
OffsetTo<Coverage>
|
||||||
|
coverage; /* Offset to Coverage table--from
|
||||||
* beginning of Substitution table */
|
* beginning of Substitution table */
|
||||||
USHORT ligSetCount; /* Number of LigatureSet tables */
|
USHORT ligSetCount; /* Number of LigatureSet tables */
|
||||||
Offset ligatureSet[]; /* Array of offsets to LigatureSet
|
Offset ligatureSet[]; /* Array of offsets to LigatureSet
|
||||||
|
@ -648,8 +637,6 @@ struct ContextSubstFormat1 {
|
||||||
private:
|
private:
|
||||||
/* SubRuleSet tables, in Coverage Index order */
|
/* SubRuleSet tables, in Coverage Index order */
|
||||||
DEFINE_OFFSET_ARRAY_TYPE (SubRuleSet, subRuleSet, subRuleSetCount);
|
DEFINE_OFFSET_ARRAY_TYPE (SubRuleSet, subRuleSet, subRuleSetCount);
|
||||||
DEFINE_GET_ACCESSOR (Coverage, coverage, coverage);
|
|
||||||
DEFINE_GET_GLYPH_COVERAGE (glyph_coverage);
|
|
||||||
|
|
||||||
inline bool substitute (SUBTABLE_SUBSTITUTE_ARGS_DEF) const {
|
inline bool substitute (SUBTABLE_SUBSTITUTE_ARGS_DEF) const {
|
||||||
|
|
||||||
|
@ -659,7 +646,7 @@ struct ContextSubstFormat1 {
|
||||||
|
|
||||||
hb_codepoint_t glyph_id = IN_CURGLYPH ();
|
hb_codepoint_t glyph_id = IN_CURGLYPH ();
|
||||||
|
|
||||||
unsigned int index = get_glyph_coverage (glyph_id);
|
unsigned int index = (this+coverage) (glyph_id);
|
||||||
|
|
||||||
const SubRuleSet &rule_set = (*this)[index];
|
const SubRuleSet &rule_set = (*this)[index];
|
||||||
return rule_set.substitute (SUBTABLE_SUBSTITUTE_ARGS);
|
return rule_set.substitute (SUBTABLE_SUBSTITUTE_ARGS);
|
||||||
|
@ -667,7 +654,8 @@ struct ContextSubstFormat1 {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
USHORT substFormat; /* Format identifier--format = 1 */
|
USHORT substFormat; /* Format identifier--format = 1 */
|
||||||
Offset coverage; /* Offset to Coverage table--from
|
OffsetTo<Coverage>
|
||||||
|
coverage; /* Offset to Coverage table--from
|
||||||
* beginning of Substitution table */
|
* beginning of Substitution table */
|
||||||
USHORT subRuleSetCount; /* Number of SubRuleSet tables--must
|
USHORT subRuleSetCount; /* Number of SubRuleSet tables--must
|
||||||
* equal GlyphCount in Coverage table */
|
* equal GlyphCount in Coverage table */
|
||||||
|
@ -792,8 +780,6 @@ struct ContextSubstFormat2 {
|
||||||
private:
|
private:
|
||||||
/* SubClassSet tables, in Coverage Index order */
|
/* SubClassSet tables, in Coverage Index order */
|
||||||
DEFINE_OFFSET_ARRAY_TYPE (SubClassSet, subClassSet, subClassSetCnt);
|
DEFINE_OFFSET_ARRAY_TYPE (SubClassSet, subClassSet, subClassSetCnt);
|
||||||
DEFINE_GET_ACCESSOR (Coverage, coverage, coverage);
|
|
||||||
DEFINE_GET_GLYPH_COVERAGE (glyph_coverage);
|
|
||||||
|
|
||||||
inline bool substitute (SUBTABLE_SUBSTITUTE_ARGS_DEF) const {
|
inline bool substitute (SUBTABLE_SUBSTITUTE_ARGS_DEF) const {
|
||||||
|
|
||||||
|
@ -803,7 +789,7 @@ struct ContextSubstFormat2 {
|
||||||
|
|
||||||
hb_codepoint_t glyph_id = IN_CURGLYPH ();
|
hb_codepoint_t glyph_id = IN_CURGLYPH ();
|
||||||
|
|
||||||
unsigned int index = get_glyph_coverage (glyph_id);
|
unsigned int index = (this+coverage) (glyph_id);
|
||||||
|
|
||||||
const SubClassSet &class_set = (*this)[index];
|
const SubClassSet &class_set = (*this)[index];
|
||||||
return class_set.substitute_class (SUBTABLE_SUBSTITUTE_ARGS, this+classDef);
|
return class_set.substitute_class (SUBTABLE_SUBSTITUTE_ARGS, this+classDef);
|
||||||
|
@ -811,7 +797,8 @@ struct ContextSubstFormat2 {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
USHORT substFormat; /* Format identifier--format = 2 */
|
USHORT substFormat; /* Format identifier--format = 2 */
|
||||||
Offset coverage; /* Offset to Coverage table--from
|
OffsetTo<Coverage>
|
||||||
|
coverage; /* Offset to Coverage table--from
|
||||||
* beginning of Substitution table */
|
* beginning of Substitution table */
|
||||||
OffsetTo<ClassDef>
|
OffsetTo<ClassDef>
|
||||||
classDef; /* Offset to glyph ClassDef table--from
|
classDef; /* Offset to glyph ClassDef table--from
|
||||||
|
|
|
@ -69,7 +69,7 @@
|
||||||
inline unsigned int get_len(void) const { return num; } \
|
inline unsigned int get_len(void) const { return num; } \
|
||||||
|
|
||||||
/* An array type is one that contains a variable number of objects
|
/* An array type is one that contains a variable number of objects
|
||||||
* as its last item. An array object is extended with len() and size()
|
* as its last item. An array object is extended with get_len()
|
||||||
* methods, as well as overloaded [] operator. */
|
* methods, as well as overloaded [] operator. */
|
||||||
#define DEFINE_ARRAY_TYPE(Type, array, num) \
|
#define DEFINE_ARRAY_TYPE(Type, array, num) \
|
||||||
DEFINE_INDEX_OPERATOR(Type, array, num) \
|
DEFINE_INDEX_OPERATOR(Type, array, num) \
|
||||||
|
@ -237,14 +237,6 @@ struct Null <Type> { \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define DEFINE_GET_ACCESSOR(Type, name, Name) \
|
|
||||||
inline const Type& get_##name (void) const { \
|
|
||||||
if (HB_UNLIKELY (!Name)) return Null(Type); \
|
|
||||||
return *(const Type*)((const char*)this + Name); \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue