[HB] Remove clumsy macros and improve API
This commit is contained in:
parent
d0b657379b
commit
bff3c0fde5
2
src/TODO
2
src/TODO
|
@ -4,6 +4,4 @@
|
||||||
- Rename LookupFlag::MarkAttachmentType to LookupFlag:IgnoreSpecialMarks
|
- Rename LookupFlag::MarkAttachmentType to LookupFlag:IgnoreSpecialMarks
|
||||||
- cmap14 support in get_glyph callback
|
- cmap14 support in get_glyph callback
|
||||||
- size_t?
|
- size_t?
|
||||||
- change get_XXX_count / get_XXX_tag to be more like
|
|
||||||
hb_ot_layout_get_lig_carets (IN/OUT)?
|
|
||||||
- Figure out compiler selection (add test for link to libstdc++)
|
- Figure out compiler selection (add test for link to libstdc++)
|
||||||
|
|
|
@ -67,15 +67,44 @@ typedef struct OffsetTable
|
||||||
friend struct TTCHeader;
|
friend struct TTCHeader;
|
||||||
|
|
||||||
STATIC_DEFINE_GET_FOR_DATA (OffsetTable);
|
STATIC_DEFINE_GET_FOR_DATA (OffsetTable);
|
||||||
DEFINE_TAG_ARRAY_INTERFACE (OpenTypeTable, table); /* get_table_count(), get_table(i), get_table_tag(i) */
|
|
||||||
DEFINE_TAG_FIND_INTERFACE (OpenTypeTable, table); /* find_table_index(tag), get_table_by_tag(tag) */
|
inline unsigned int get_table_count (void) const
|
||||||
|
{ return numTables; }
|
||||||
|
inline const Tag& get_table_tag (unsigned int i) const
|
||||||
|
{
|
||||||
|
if (HB_UNLIKELY (i >= numTables)) return Null(Tag);
|
||||||
|
return tableDir[i].tag;
|
||||||
|
}
|
||||||
|
inline const TableDirectory& get_table (unsigned int i) const
|
||||||
|
{
|
||||||
|
if (HB_UNLIKELY (i >= numTables)) return Null(TableDirectory);
|
||||||
|
return tableDir[i];
|
||||||
|
}
|
||||||
|
inline bool find_table_index (hb_tag_t tag, unsigned int *table_index) const
|
||||||
|
{
|
||||||
|
const Tag t = tag;
|
||||||
|
// TODO bsearch
|
||||||
|
unsigned int count = numTables;
|
||||||
|
for (unsigned int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
if (t == tableDir[i].tag)
|
||||||
|
{
|
||||||
|
if (table_index) *table_index = i;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (table_index) *table_index = NO_INDEX;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
inline const TableDirectory& get_table_by_tag (hb_tag_t tag) const
|
||||||
|
{
|
||||||
|
unsigned int table_index;
|
||||||
|
find_table_index (tag, &table_index);
|
||||||
|
return get_table (table_index);
|
||||||
|
}
|
||||||
|
|
||||||
unsigned int get_face_count (void) const { return 1; }
|
unsigned int get_face_count (void) const { return 1; }
|
||||||
|
|
||||||
private:
|
|
||||||
/* OpenTypeTables, in no particular order */
|
|
||||||
DEFINE_ARRAY_TYPE (TableDirectory, tableDir, numTables);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline bool sanitize (SANITIZE_ARG_DEF, const void *base) {
|
inline bool sanitize (SANITIZE_ARG_DEF, const void *base) {
|
||||||
SANITIZE_DEBUG ();
|
SANITIZE_DEBUG ();
|
||||||
|
|
|
@ -51,99 +51,6 @@
|
||||||
#define CAST(T,X,Ofs) (*(reinterpret_cast<T *>(CHARP(&(X)) + Ofs)))
|
#define CAST(T,X,Ofs) (*(reinterpret_cast<T *>(CHARP(&(X)) + Ofs)))
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Array types
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* get_len() is a method returning the number of items in an array-like object */
|
|
||||||
#define DEFINE_LEN(Type, array, num) \
|
|
||||||
inline unsigned int get_len(void) const { return num; } \
|
|
||||||
|
|
||||||
/* An array type is one that contains a variable number of objects
|
|
||||||
* as its last item. An array object is extended with get_len()
|
|
||||||
* methods, as well as overloaded [] operator. */
|
|
||||||
#define DEFINE_ARRAY_TYPE(Type, array, num) \
|
|
||||||
DEFINE_INDEX_OPERATOR(Type, array, num) \
|
|
||||||
DEFINE_LEN(Type, array, num)
|
|
||||||
#define DEFINE_INDEX_OPERATOR(Type, array, num) \
|
|
||||||
inline const Type& operator[] (unsigned int i) const \
|
|
||||||
{ \
|
|
||||||
if (HB_UNLIKELY (i >= num)) return Null(Type); \
|
|
||||||
return array[i]; \
|
|
||||||
}
|
|
||||||
|
|
||||||
/* An offset array type is like an array type, but it contains a table
|
|
||||||
* of offsets to the objects, relative to the beginning of the current
|
|
||||||
* object. */
|
|
||||||
#define DEFINE_OFFSET_ARRAY_TYPE(Type, array, num) \
|
|
||||||
DEFINE_OFFSET_INDEX_OPERATOR(Type, array, num) \
|
|
||||||
DEFINE_LEN(Offset, array, num)
|
|
||||||
#define DEFINE_OFFSET_INDEX_OPERATOR(Type, array, num) \
|
|
||||||
inline const Type& operator[] (unsigned int i) const \
|
|
||||||
{ \
|
|
||||||
if (HB_UNLIKELY (i >= num)) return Null(Type); \
|
|
||||||
if (HB_UNLIKELY (!array[i])) return Null(Type); \
|
|
||||||
return *(const Type)((const char*)this + array[i]); \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#define DEFINE_ARRAY_INTERFACE(Type, name) \
|
|
||||||
inline const Type& get_##name (unsigned int i) const { return (*this)[i]; } \
|
|
||||||
inline unsigned int get_##name##_count (void) const { return this->get_len (); }
|
|
||||||
#define DEFINE_INDEX_ARRAY_INTERFACE(name) \
|
|
||||||
inline unsigned int get_##name##_index (unsigned int i) const \
|
|
||||||
{ \
|
|
||||||
if (HB_UNLIKELY (i >= get_len ())) return NO_INDEX; \
|
|
||||||
return (*this)[i]; \
|
|
||||||
} \
|
|
||||||
inline unsigned int get_##name##_count (void) const { return get_len (); }
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* List types
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define DEFINE_LIST_INTERFACE(Type, name) \
|
|
||||||
inline const Type& get_##name (unsigned int i) const { return (this+name##List)[i]; } \
|
|
||||||
inline unsigned int get_##name##_count (void) const { return (this+name##List).len; }
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Tag types
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define DEFINE_TAG_ARRAY_INTERFACE(Type, name) \
|
|
||||||
DEFINE_ARRAY_INTERFACE (Type, name); \
|
|
||||||
inline const Tag& get_##name##_tag (unsigned int i) const { return (*this)[i].tag; }
|
|
||||||
#define DEFINE_TAG_LIST_INTERFACE(Type, name) \
|
|
||||||
DEFINE_LIST_INTERFACE (Type, name); \
|
|
||||||
inline const Tag& get_##name##_tag (unsigned int i) const { return (this+name##List).get_tag (i); }
|
|
||||||
|
|
||||||
#define DEFINE_TAG_FIND_INTERFACE(Type, name) \
|
|
||||||
inline bool find_##name##_index (hb_tag_t tag, unsigned int *index) const { \
|
|
||||||
const Tag t = tag; \
|
|
||||||
for (unsigned int i = 0; i < get_##name##_count (); i++) \
|
|
||||||
{ \
|
|
||||||
if (t == get_##name##_tag (i)) \
|
|
||||||
{ \
|
|
||||||
if (index) *index = i; \
|
|
||||||
return true; \
|
|
||||||
} \
|
|
||||||
} \
|
|
||||||
if (index) *index = NO_INDEX; \
|
|
||||||
return false; \
|
|
||||||
} \
|
|
||||||
inline const Type& get_##name##_by_tag (hb_tag_t tag) const \
|
|
||||||
{ \
|
|
||||||
unsigned int i; \
|
|
||||||
if (find_##name##_index (tag, &i)) \
|
|
||||||
return get_##name (i); \
|
|
||||||
else \
|
|
||||||
return Null(Type); \
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Class features
|
* Class features
|
||||||
*/
|
*/
|
||||||
|
@ -379,13 +286,7 @@ struct Sanitizer
|
||||||
|
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* The OpenType Font File
|
* The OpenType Font File: Data Types
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Data Types
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -433,6 +334,7 @@ DEFINE_INT_TYPE (SHORT, , 16); /* 16-bit signed integer. */
|
||||||
DEFINE_INT_TYPE (ULONG, u, 32); /* 32-bit unsigned integer. */
|
DEFINE_INT_TYPE (ULONG, u, 32); /* 32-bit unsigned integer. */
|
||||||
DEFINE_INT_TYPE (LONG, , 32); /* 32-bit signed integer. */
|
DEFINE_INT_TYPE (LONG, , 32); /* 32-bit signed integer. */
|
||||||
|
|
||||||
|
|
||||||
/* Array of four uint8s (length = 32 bits) used to identify a script, language
|
/* Array of four uint8s (length = 32 bits) used to identify a script, language
|
||||||
* system, feature, or baseline */
|
* system, feature, or baseline */
|
||||||
struct Tag : ULONG
|
struct Tag : ULONG
|
||||||
|
@ -550,6 +452,8 @@ struct OffsetTo : GenericOffsetTo<Offset, Type> {};
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
struct LongOffsetTo : GenericOffsetTo<LongOffset, Type> {};
|
struct LongOffsetTo : GenericOffsetTo<LongOffset, Type> {};
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Array Types
|
* Array Types
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -58,21 +58,45 @@ struct Record
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Type>
|
template <typename Type>
|
||||||
struct RecordArrayOf : ArrayOf<Record<Type> > {};
|
struct RecordArrayOf : ArrayOf<Record<Type> > {
|
||||||
|
|
||||||
template <typename Type>
|
|
||||||
struct RecordListOf : RecordArrayOf<Type>
|
|
||||||
{
|
|
||||||
inline const Type& operator [] (unsigned int i) const
|
|
||||||
{
|
|
||||||
if (HB_UNLIKELY (i >= this->len)) return Null(Type);
|
|
||||||
return this+this->array[i].offset;
|
|
||||||
}
|
|
||||||
inline const Tag& get_tag (unsigned int i) const
|
inline const Tag& get_tag (unsigned int i) const
|
||||||
{
|
{
|
||||||
if (HB_UNLIKELY (i >= this->len)) return Null(Tag);
|
if (HB_UNLIKELY (i >= this->len)) return Null(Tag);
|
||||||
return this->array[i].tag;
|
return this->array[i].tag;
|
||||||
}
|
}
|
||||||
|
inline bool get_tags (unsigned int *record_count /* IN/OUT */,
|
||||||
|
hb_tag_t *record_tags /* OUT */) const
|
||||||
|
{
|
||||||
|
unsigned int count = MIN (this->len, *record_count);
|
||||||
|
for (unsigned int i = 0; i < count; i++)
|
||||||
|
record_tags[i] = this->array[i].tag;
|
||||||
|
|
||||||
|
*record_count = this->len;
|
||||||
|
return !!this->len;
|
||||||
|
}
|
||||||
|
inline bool find_index (hb_tag_t tag, unsigned int *index) const
|
||||||
|
{
|
||||||
|
const Tag t = tag;
|
||||||
|
// TODO bsearch
|
||||||
|
unsigned int count = this->len;
|
||||||
|
for (unsigned int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
if (t == this->array[i].tag)
|
||||||
|
{
|
||||||
|
if (index) *index = i;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (index) *index = NO_INDEX;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <typename Type>
|
||||||
|
struct RecordListOf : RecordArrayOf<Type>
|
||||||
|
{
|
||||||
|
inline const Type& operator [] (unsigned int i) const
|
||||||
|
{ return this+RecordArrayOf<Type>::operator[](i).offset; }
|
||||||
|
|
||||||
inline bool sanitize (SANITIZE_ARG_DEF) {
|
inline bool sanitize (SANITIZE_ARG_DEF) {
|
||||||
SANITIZE_DEBUG ();
|
SANITIZE_DEBUG ();
|
||||||
|
@ -81,6 +105,27 @@ struct RecordListOf : RecordArrayOf<Type>
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct IndexArray : ArrayOf<USHORT>
|
||||||
|
{
|
||||||
|
inline unsigned int operator [] (unsigned int i) const
|
||||||
|
{
|
||||||
|
if (HB_UNLIKELY (i >= this->len))
|
||||||
|
return NO_INDEX;
|
||||||
|
return this->array[i];
|
||||||
|
}
|
||||||
|
inline bool get_indexes (unsigned int *_count /* IN/OUT */,
|
||||||
|
unsigned int *_indexes /* OUT */) const
|
||||||
|
{
|
||||||
|
unsigned int count = MIN (this->len, *_count);
|
||||||
|
for (unsigned int i = 0; i < count; i++)
|
||||||
|
_indexes[i] = this->array[i];
|
||||||
|
|
||||||
|
*_count = this->len;
|
||||||
|
return !!this->len;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
struct Script;
|
struct Script;
|
||||||
struct LangSys;
|
struct LangSys;
|
||||||
struct Feature;
|
struct Feature;
|
||||||
|
@ -88,8 +133,13 @@ struct Feature;
|
||||||
|
|
||||||
struct LangSys
|
struct LangSys
|
||||||
{
|
{
|
||||||
inline unsigned int get_feature_index (unsigned int i) const { return featureIndex[i]; }
|
inline unsigned int get_feature_count (void) const
|
||||||
inline unsigned int get_feature_count (void) const { return featureIndex.len; }
|
{ return featureIndex.len; }
|
||||||
|
inline hb_tag_t get_feature_index (unsigned int i) const
|
||||||
|
{ return featureIndex[i]; }
|
||||||
|
inline bool get_feature_indexes (unsigned int *feature_count /* IN/OUT */,
|
||||||
|
hb_tag_t *feature_tags /* OUT */) const
|
||||||
|
{ return featureIndex.get_indexes (feature_count, feature_tags); }
|
||||||
|
|
||||||
inline bool has_required_feature (void) const { return reqFeatureIndex != 0xffff; }
|
inline bool has_required_feature (void) const { return reqFeatureIndex != 0xffff; }
|
||||||
inline int get_required_feature_index (void) const
|
inline int get_required_feature_index (void) const
|
||||||
|
@ -109,24 +159,27 @@ struct LangSys
|
||||||
USHORT reqFeatureIndex;/* Index of a feature required for this
|
USHORT reqFeatureIndex;/* Index of a feature required for this
|
||||||
* language system--if no required features
|
* language system--if no required features
|
||||||
* = 0xFFFF */
|
* = 0xFFFF */
|
||||||
ArrayOf<USHORT>
|
IndexArray featureIndex; /* Array of indices into the FeatureList */
|
||||||
featureIndex; /* Array of indices into the FeatureList */
|
|
||||||
};
|
};
|
||||||
ASSERT_SIZE_DATA (LangSys, 6, "\0\0\xFF\xFF");
|
ASSERT_SIZE_DATA (LangSys, 6, "\0\0\xFF\xFF");
|
||||||
|
|
||||||
|
|
||||||
struct Script
|
struct Script
|
||||||
{
|
{
|
||||||
|
inline unsigned int get_lang_sys_count (void) const
|
||||||
|
{ return langSys.len; }
|
||||||
|
inline const Tag& get_lang_sys_tag (unsigned int i) const
|
||||||
|
{ return langSys.get_tag (i); }
|
||||||
|
inline bool get_lang_sys_tags (unsigned int *lang_sys_count /* IN/OUT */,
|
||||||
|
hb_tag_t *lang_sys_tags /* OUT */) const
|
||||||
|
{ return langSys.get_tags (lang_sys_count, lang_sys_tags); }
|
||||||
inline const LangSys& get_lang_sys (unsigned int i) const
|
inline const LangSys& get_lang_sys (unsigned int i) const
|
||||||
{
|
{
|
||||||
if (i == NO_INDEX) return get_default_lang_sys ();
|
if (i == NO_INDEX) return get_default_lang_sys ();
|
||||||
return this+langSys[i].offset;
|
return this+langSys[i].offset;
|
||||||
}
|
}
|
||||||
inline unsigned int get_lang_sys_count (void) const { return langSys.len; }
|
inline bool find_lang_sys_index (hb_tag_t tag, unsigned int *index) const
|
||||||
inline const Tag& get_lang_sys_tag (unsigned int i) const { return langSys[i].tag; }
|
{ return langSys.find_index (tag, index); }
|
||||||
|
|
||||||
// LONGTERMTODO bsearch
|
|
||||||
DEFINE_TAG_FIND_INTERFACE (LangSys, lang_sys); /* find_lang_sys_index (), get_lang_sys_by_tag (tag) */
|
|
||||||
|
|
||||||
inline bool has_default_lang_sys (void) const { return defaultLangSys != 0; }
|
inline bool has_default_lang_sys (void) const { return defaultLangSys != 0; }
|
||||||
inline const LangSys& get_default_lang_sys (void) const { return this+defaultLangSys; }
|
inline const LangSys& get_default_lang_sys (void) const { return this+defaultLangSys; }
|
||||||
|
@ -152,8 +205,13 @@ ASSERT_SIZE (ScriptList, 2);
|
||||||
|
|
||||||
struct Feature
|
struct Feature
|
||||||
{
|
{
|
||||||
inline unsigned int get_lookup_index (unsigned int i) const { return lookupIndex[i]; }
|
inline unsigned int get_lookup_count (void) const
|
||||||
inline unsigned int get_lookup_count (void) const { return lookupIndex.len; }
|
{ return lookupIndex.len; }
|
||||||
|
inline hb_tag_t get_lookup_index (unsigned int i) const
|
||||||
|
{ return lookupIndex[i]; }
|
||||||
|
inline bool get_lookup_indexes (unsigned int *lookup_count /* IN/OUT */,
|
||||||
|
hb_tag_t *lookup_tags /* OUT */) const
|
||||||
|
{ return lookupIndex.get_indexes (lookup_count, lookup_tags); }
|
||||||
|
|
||||||
inline bool sanitize (SANITIZE_ARG_DEF) {
|
inline bool sanitize (SANITIZE_ARG_DEF) {
|
||||||
SANITIZE_DEBUG ();
|
SANITIZE_DEBUG ();
|
||||||
|
@ -166,8 +224,7 @@ struct Feature
|
||||||
* has been defined for the feature), relative
|
* has been defined for the feature), relative
|
||||||
* to the beginning of the Feature Table; = Null
|
* to the beginning of the Feature Table; = Null
|
||||||
* if not required */
|
* if not required */
|
||||||
ArrayOf<USHORT>
|
IndexArray lookupIndex; /* Array of LookupList indices */
|
||||||
lookupIndex; /* Array of LookupList indices */
|
|
||||||
};
|
};
|
||||||
ASSERT_SIZE (Feature, 4);
|
ASSERT_SIZE (Feature, 4);
|
||||||
|
|
||||||
|
|
|
@ -855,13 +855,34 @@ struct GSUBGPOS
|
||||||
|
|
||||||
STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GSUBGPOS, 1, 1);
|
STATIC_DEFINE_GET_FOR_DATA_CHECK_MAJOR_VERSION (GSUBGPOS, 1, 1);
|
||||||
|
|
||||||
DEFINE_TAG_LIST_INTERFACE (Script, script ); /* get_script_count (), get_script (i), get_script_tag (i) */
|
inline unsigned int get_script_count (void) const
|
||||||
DEFINE_TAG_LIST_INTERFACE (Feature, feature); /* get_feature_count(), get_feature(i), get_feature_tag(i) */
|
{ return (this+scriptList).len; }
|
||||||
DEFINE_LIST_INTERFACE (Lookup, lookup ); /* get_lookup_count (), get_lookup (i) */
|
inline const Tag& get_script_tag (unsigned int i) const
|
||||||
|
{ return (this+scriptList).get_tag (i); }
|
||||||
|
inline bool get_script_tags (unsigned int *script_count /* IN/OUT */,
|
||||||
|
hb_tag_t *script_tags /* OUT */) const
|
||||||
|
{ return (this+scriptList).get_tags (script_count, script_tags); }
|
||||||
|
inline const Script& get_script (unsigned int i) const
|
||||||
|
{ return (this+scriptList)[i]; }
|
||||||
|
inline bool find_script_index (hb_tag_t tag, unsigned int *index) const
|
||||||
|
{ return (this+scriptList).find_index (tag, index); }
|
||||||
|
|
||||||
// LONGTERMTODO bsearch
|
inline unsigned int get_feature_count (void) const
|
||||||
DEFINE_TAG_FIND_INTERFACE (Script, script ); /* find_script_index (), get_script_by_tag (tag) */
|
{ return (this+featureList).len; }
|
||||||
DEFINE_TAG_FIND_INTERFACE (Feature, feature); /* find_feature_index(), get_feature_by_tag(tag) */
|
inline const Tag& get_feature_tag (unsigned int i) const
|
||||||
|
{ return (this+featureList).get_tag (i); }
|
||||||
|
inline bool get_feature_tags (unsigned int *feature_count /* IN/OUT */,
|
||||||
|
hb_tag_t *feature_tags /* OUT */) const
|
||||||
|
{ return (this+featureList).get_tags (feature_count, feature_tags); }
|
||||||
|
inline const Feature& get_feature (unsigned int i) const
|
||||||
|
{ return (this+featureList)[i]; }
|
||||||
|
inline bool find_feature_index (hb_tag_t tag, unsigned int *index) const
|
||||||
|
{ return (this+featureList).find_index (tag, index); }
|
||||||
|
|
||||||
|
inline unsigned int get_lookup_count (void) const
|
||||||
|
{ return (this+lookupList).len; }
|
||||||
|
inline const Lookup& get_lookup (unsigned int i) const
|
||||||
|
{ return (this+lookupList)[i]; }
|
||||||
|
|
||||||
bool sanitize (SANITIZE_ARG_DEF) {
|
bool sanitize (SANITIZE_ARG_DEF) {
|
||||||
SANITIZE_DEBUG ();
|
SANITIZE_DEBUG ();
|
||||||
|
|
|
@ -336,23 +336,15 @@ get_gsubgpos_table (hb_face_t *face,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
unsigned int
|
hb_bool_t
|
||||||
hb_ot_layout_table_get_script_count (hb_face_t *face,
|
hb_ot_layout_table_get_script_tags (hb_face_t *face,
|
||||||
hb_tag_t table_tag)
|
|
||||||
{
|
|
||||||
const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
|
|
||||||
|
|
||||||
return g.get_script_count ();
|
|
||||||
}
|
|
||||||
|
|
||||||
hb_tag_t
|
|
||||||
hb_ot_layout_table_get_script_tag (hb_face_t *face,
|
|
||||||
hb_tag_t table_tag,
|
hb_tag_t table_tag,
|
||||||
unsigned int script_index)
|
unsigned int *script_count /* IN/OUT */,
|
||||||
|
hb_tag_t *script_tags /* OUT */)
|
||||||
{
|
{
|
||||||
const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
|
const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
|
||||||
|
|
||||||
return g.get_script_tag (script_index);
|
return g.get_script_tags (script_count, script_tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
hb_bool_t
|
hb_bool_t
|
||||||
|
@ -379,23 +371,15 @@ hb_ot_layout_table_find_script (hb_face_t *face,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
hb_bool_t
|
||||||
hb_ot_layout_table_get_feature_count (hb_face_t *face,
|
hb_ot_layout_table_get_feature_tags (hb_face_t *face,
|
||||||
hb_tag_t table_tag)
|
|
||||||
{
|
|
||||||
const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
|
|
||||||
|
|
||||||
return g.get_feature_count ();
|
|
||||||
}
|
|
||||||
|
|
||||||
hb_tag_t
|
|
||||||
hb_ot_layout_table_get_feature_tag (hb_face_t *face,
|
|
||||||
hb_tag_t table_tag,
|
hb_tag_t table_tag,
|
||||||
unsigned int feature_index)
|
unsigned int *feature_count /* IN/OUT */,
|
||||||
|
hb_tag_t *feature_tags /* OUT */)
|
||||||
{
|
{
|
||||||
const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
|
const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
|
||||||
|
|
||||||
return g.get_feature_tag (feature_index);
|
return g.get_feature_tags (feature_count, feature_tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
hb_bool_t
|
hb_bool_t
|
||||||
|
@ -414,35 +398,17 @@ hb_ot_layout_table_find_feature (hb_face_t *face,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
|
||||||
hb_ot_layout_table_get_lookup_count (hb_face_t *face,
|
|
||||||
hb_tag_t table_tag)
|
|
||||||
{
|
|
||||||
const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
|
|
||||||
|
|
||||||
return g.get_lookup_count ();
|
hb_bool_t
|
||||||
}
|
hb_ot_layout_script_get_language_tags (hb_face_t *face,
|
||||||
|
|
||||||
|
|
||||||
unsigned int
|
|
||||||
hb_ot_layout_script_get_language_count (hb_face_t *face,
|
|
||||||
hb_tag_t table_tag,
|
|
||||||
unsigned int script_index)
|
|
||||||
{
|
|
||||||
const Script &s = get_gsubgpos_table (face, table_tag).get_script (script_index);
|
|
||||||
|
|
||||||
return s.get_lang_sys_count ();
|
|
||||||
}
|
|
||||||
|
|
||||||
hb_tag_t
|
|
||||||
hb_ot_layout_script_get_language_tag (hb_face_t *face,
|
|
||||||
hb_tag_t table_tag,
|
hb_tag_t table_tag,
|
||||||
unsigned int script_index,
|
unsigned int script_index,
|
||||||
unsigned int language_index)
|
unsigned int *language_count /* IN/OUT */,
|
||||||
|
hb_tag_t *language_tags /* OUT */)
|
||||||
{
|
{
|
||||||
const Script &s = get_gsubgpos_table (face, table_tag).get_script (script_index);
|
const Script &s = get_gsubgpos_table (face, table_tag).get_script (script_index);
|
||||||
|
|
||||||
return s.get_lang_sys_tag (language_index);
|
return s.get_lang_sys_tags (language_count, language_tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
hb_bool_t
|
hb_bool_t
|
||||||
|
@ -480,42 +446,40 @@ hb_ot_layout_language_get_required_feature_index (hb_face_t *face,
|
||||||
return l.has_required_feature ();
|
return l.has_required_feature ();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
hb_bool_t
|
||||||
hb_ot_layout_language_get_feature_count (hb_face_t *face,
|
hb_ot_layout_language_get_feature_indexes (hb_face_t *face,
|
||||||
hb_tag_t table_tag,
|
|
||||||
unsigned int script_index,
|
|
||||||
unsigned int language_index)
|
|
||||||
{
|
|
||||||
const LangSys &l = get_gsubgpos_table (face, table_tag).get_script (script_index).get_lang_sys (language_index);
|
|
||||||
|
|
||||||
return l.get_feature_count ();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int
|
|
||||||
hb_ot_layout_language_get_feature_index (hb_face_t *face,
|
|
||||||
hb_tag_t table_tag,
|
hb_tag_t table_tag,
|
||||||
unsigned int script_index,
|
unsigned int script_index,
|
||||||
unsigned int language_index,
|
unsigned int language_index,
|
||||||
unsigned int num_feature)
|
unsigned int *feature_count /* IN/OUT */,
|
||||||
|
unsigned int *feature_indexes /* OUT */)
|
||||||
{
|
{
|
||||||
const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
|
const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
|
||||||
const LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
|
const LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
|
||||||
|
|
||||||
return l.get_feature_index (num_feature);
|
return l.get_feature_indexes (feature_count, feature_indexes);
|
||||||
}
|
}
|
||||||
|
|
||||||
hb_tag_t
|
hb_bool_t
|
||||||
hb_ot_layout_language_get_feature_tag (hb_face_t *face,
|
hb_ot_layout_language_get_feature_tags (hb_face_t *face,
|
||||||
hb_tag_t table_tag,
|
hb_tag_t table_tag,
|
||||||
unsigned int script_index,
|
unsigned int script_index,
|
||||||
unsigned int language_index,
|
unsigned int language_index,
|
||||||
unsigned int num_feature)
|
unsigned int *feature_count /* IN/OUT */,
|
||||||
|
hb_tag_t *feature_tags /* OUT */)
|
||||||
{
|
{
|
||||||
const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
|
const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
|
||||||
const LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
|
const LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
|
||||||
unsigned int feature_index = l.get_feature_index (num_feature);
|
|
||||||
|
|
||||||
return g.get_feature_tag (feature_index);
|
ASSERT_STATIC (sizeof (unsigned int) == sizeof (hb_tag_t));
|
||||||
|
unsigned int count = feature_count ? *feature_count : 0;
|
||||||
|
hb_bool_t ret = l.get_feature_indexes (feature_count, (unsigned int *) feature_tags);
|
||||||
|
|
||||||
|
count = feature_count ? MIN (count, *feature_count) : 0;
|
||||||
|
for (unsigned int i = 0; i < count; i++)
|
||||||
|
feature_tags[i] = g.get_feature_tag ((unsigned int) feature_tags[i]);
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -545,29 +509,20 @@ hb_ot_layout_language_find_feature (hb_face_t *face,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int
|
hb_bool_t
|
||||||
hb_ot_layout_feature_get_lookup_count (hb_face_t *face,
|
hb_ot_layout_feature_get_lookup_indexes (hb_face_t *face,
|
||||||
hb_tag_t table_tag,
|
|
||||||
unsigned int feature_index)
|
|
||||||
{
|
|
||||||
const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
|
|
||||||
const Feature &f = g.get_feature (feature_index);
|
|
||||||
|
|
||||||
return f.get_lookup_count ();
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned int
|
|
||||||
hb_ot_layout_feature_get_lookup_index (hb_face_t *face,
|
|
||||||
hb_tag_t table_tag,
|
hb_tag_t table_tag,
|
||||||
unsigned int feature_index,
|
unsigned int feature_index,
|
||||||
unsigned int num_lookup)
|
unsigned int *lookup_count /* IN/OUT */,
|
||||||
|
unsigned int *lookup_indexes /* OUT */)
|
||||||
{
|
{
|
||||||
const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
|
const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
|
||||||
const Feature &f = g.get_feature (feature_index);
|
const Feature &f = g.get_feature (feature_index);
|
||||||
|
|
||||||
return f.get_lookup_index (num_lookup);
|
return f.get_lookup_indexes (lookup_count, lookup_indexes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GSUB
|
* GSUB
|
||||||
*/
|
*/
|
||||||
|
@ -590,6 +545,7 @@ hb_ot_layout_substitute_lookup (hb_face_t *face,
|
||||||
return _get_gsub (face).substitute_lookup (&context, buffer, lookup_index, mask);
|
return _get_gsub (face).substitute_lookup (&context, buffer, lookup_index, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GPOS
|
* GPOS
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -71,12 +71,15 @@ hb_ot_layout_build_glyph_classes (hb_face_t *face,
|
||||||
unsigned char *klasses,
|
unsigned char *klasses,
|
||||||
uint16_t count);
|
uint16_t count);
|
||||||
|
|
||||||
|
/* Not that useful. Provides list of attach points for a glyph that a
|
||||||
|
* client may want to cache */
|
||||||
hb_bool_t
|
hb_bool_t
|
||||||
hb_ot_layout_get_attach_points (hb_face_t *face,
|
hb_ot_layout_get_attach_points (hb_face_t *face,
|
||||||
hb_codepoint_t glyph,
|
hb_codepoint_t glyph,
|
||||||
unsigned int *point_count /* IN/OUT */,
|
unsigned int *point_count /* IN/OUT */,
|
||||||
unsigned int *point_array /* OUT */);
|
unsigned int *point_array /* OUT */);
|
||||||
|
|
||||||
|
/* Ligature caret positions */
|
||||||
hb_bool_t
|
hb_bool_t
|
||||||
hb_ot_layout_get_lig_carets (hb_face_t *face,
|
hb_ot_layout_get_lig_carets (hb_face_t *face,
|
||||||
hb_font_t *font,
|
hb_font_t *font,
|
||||||
|
@ -84,8 +87,9 @@ hb_ot_layout_get_lig_carets (hb_face_t *face,
|
||||||
unsigned int *caret_count /* IN/OUT */,
|
unsigned int *caret_count /* IN/OUT */,
|
||||||
int *caret_array /* OUT */);
|
int *caret_array /* OUT */);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GSUB/GPOS
|
* GSUB/GPOS feature query and enumeration interface
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef uint32_t hb_ot_layout_feature_mask_t;
|
typedef uint32_t hb_ot_layout_feature_mask_t;
|
||||||
|
@ -96,14 +100,11 @@ typedef uint32_t hb_ot_layout_feature_mask_t;
|
||||||
#define HB_OT_LAYOUT_TAG_DEFAULT_SCRIPT HB_TAG ('D', 'F', 'L', 'T')
|
#define HB_OT_LAYOUT_TAG_DEFAULT_SCRIPT HB_TAG ('D', 'F', 'L', 'T')
|
||||||
#define HB_OT_LAYOUT_TAG_DEFAULT_LANGUAGE HB_TAG ('d', 'f', 'l', 't')
|
#define HB_OT_LAYOUT_TAG_DEFAULT_LANGUAGE HB_TAG ('d', 'f', 'l', 't')
|
||||||
|
|
||||||
unsigned int
|
hb_bool_t
|
||||||
hb_ot_layout_table_get_script_count (hb_face_t *face,
|
hb_ot_layout_table_get_script_tags (hb_face_t *face,
|
||||||
hb_tag_t table_tag);
|
|
||||||
|
|
||||||
hb_tag_t
|
|
||||||
hb_ot_layout_table_get_script_tag (hb_face_t *face,
|
|
||||||
hb_tag_t table_tag,
|
hb_tag_t table_tag,
|
||||||
unsigned int script_index);
|
unsigned int *script_count /* IN/OUT */,
|
||||||
|
hb_tag_t *script_tags /* OUT */);
|
||||||
|
|
||||||
hb_bool_t
|
hb_bool_t
|
||||||
hb_ot_layout_table_find_script (hb_face_t *face,
|
hb_ot_layout_table_find_script (hb_face_t *face,
|
||||||
|
@ -111,14 +112,11 @@ hb_ot_layout_table_find_script (hb_face_t *face,
|
||||||
hb_tag_t script_tag,
|
hb_tag_t script_tag,
|
||||||
unsigned int *script_index);
|
unsigned int *script_index);
|
||||||
|
|
||||||
unsigned int
|
hb_bool_t
|
||||||
hb_ot_layout_table_get_feature_count (hb_face_t *face,
|
hb_ot_layout_table_get_feature_tags (hb_face_t *face,
|
||||||
hb_tag_t table_tag);
|
|
||||||
|
|
||||||
hb_tag_t
|
|
||||||
hb_ot_layout_table_get_feature_tag (hb_face_t *face,
|
|
||||||
hb_tag_t table_tag,
|
hb_tag_t table_tag,
|
||||||
unsigned int feature_index);
|
unsigned int *feature_count /* IN/OUT */,
|
||||||
|
hb_tag_t *feature_tags /* OUT */);
|
||||||
|
|
||||||
hb_bool_t
|
hb_bool_t
|
||||||
hb_ot_layout_table_find_feature (hb_face_t *face,
|
hb_ot_layout_table_find_feature (hb_face_t *face,
|
||||||
|
@ -126,20 +124,12 @@ hb_ot_layout_table_find_feature (hb_face_t *face,
|
||||||
hb_tag_t feature_tag,
|
hb_tag_t feature_tag,
|
||||||
unsigned int *feature_index);
|
unsigned int *feature_index);
|
||||||
|
|
||||||
unsigned int
|
hb_bool_t
|
||||||
hb_ot_layout_table_get_lookup_count (hb_face_t *face,
|
hb_ot_layout_script_get_language_tags (hb_face_t *face,
|
||||||
hb_tag_t table_tag);
|
|
||||||
|
|
||||||
unsigned int
|
|
||||||
hb_ot_layout_script_get_language_count (hb_face_t *face,
|
|
||||||
hb_tag_t table_tag,
|
|
||||||
unsigned int script_index);
|
|
||||||
|
|
||||||
hb_tag_t
|
|
||||||
hb_ot_layout_script_get_language_tag (hb_face_t *face,
|
|
||||||
hb_tag_t table_tag,
|
hb_tag_t table_tag,
|
||||||
unsigned int script_index,
|
unsigned int script_index,
|
||||||
unsigned int language_index);
|
unsigned int *language_count /* IN/OUT */,
|
||||||
|
hb_tag_t *language_tags /* OUT */);
|
||||||
|
|
||||||
hb_bool_t
|
hb_bool_t
|
||||||
hb_ot_layout_script_find_language (hb_face_t *face,
|
hb_ot_layout_script_find_language (hb_face_t *face,
|
||||||
|
@ -155,25 +145,21 @@ hb_ot_layout_language_get_required_feature_index (hb_face_t *face,
|
||||||
unsigned int language_index,
|
unsigned int language_index,
|
||||||
unsigned int *feature_index);
|
unsigned int *feature_index);
|
||||||
|
|
||||||
unsigned int
|
hb_bool_t
|
||||||
hb_ot_layout_language_get_feature_count (hb_face_t *face,
|
hb_ot_layout_language_get_feature_indexes (hb_face_t *face,
|
||||||
hb_tag_t table_tag,
|
|
||||||
unsigned int script_index,
|
|
||||||
unsigned int language_index);
|
|
||||||
|
|
||||||
unsigned int
|
|
||||||
hb_ot_layout_language_get_feature_index (hb_face_t *face,
|
|
||||||
hb_tag_t table_tag,
|
hb_tag_t table_tag,
|
||||||
unsigned int script_index,
|
unsigned int script_index,
|
||||||
unsigned int language_index,
|
unsigned int language_index,
|
||||||
unsigned int num_feature);
|
unsigned int *feature_count /* IN/OUT */,
|
||||||
|
unsigned int *feature_indexes /* OUT */);
|
||||||
|
|
||||||
hb_tag_t
|
hb_bool_t
|
||||||
hb_ot_layout_language_get_feature_tag (hb_face_t *face,
|
hb_ot_layout_language_get_feature_tags (hb_face_t *face,
|
||||||
hb_tag_t table_tag,
|
hb_tag_t table_tag,
|
||||||
unsigned int script_index,
|
unsigned int script_index,
|
||||||
unsigned int language_index,
|
unsigned int language_index,
|
||||||
unsigned int num_feature);
|
unsigned int *feature_count /* IN/OUT */,
|
||||||
|
hb_tag_t *feature_tags /* OUT */);
|
||||||
|
|
||||||
hb_bool_t
|
hb_bool_t
|
||||||
hb_ot_layout_language_find_feature (hb_face_t *face,
|
hb_ot_layout_language_find_feature (hb_face_t *face,
|
||||||
|
@ -183,16 +169,13 @@ hb_ot_layout_language_find_feature (hb_face_t *face,
|
||||||
hb_tag_t feature_tag,
|
hb_tag_t feature_tag,
|
||||||
unsigned int *feature_index);
|
unsigned int *feature_index);
|
||||||
|
|
||||||
unsigned int
|
hb_bool_t
|
||||||
hb_ot_layout_feature_get_lookup_count (hb_face_t *face,
|
hb_ot_layout_feature_get_lookup_indexes (hb_face_t *face,
|
||||||
hb_tag_t table_tag,
|
|
||||||
unsigned int feature_index);
|
|
||||||
|
|
||||||
unsigned int
|
|
||||||
hb_ot_layout_feature_get_lookup_index (hb_face_t *face,
|
|
||||||
hb_tag_t table_tag,
|
hb_tag_t table_tag,
|
||||||
unsigned int feature_index,
|
unsigned int feature_index,
|
||||||
unsigned int num_lookup);
|
unsigned int *lookup_count /* IN/OUT */,
|
||||||
|
unsigned int *lookup_indexes /* OUT */);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GSUB
|
* GSUB
|
||||||
|
@ -201,7 +184,7 @@ hb_ot_layout_feature_get_lookup_index (hb_face_t *face,
|
||||||
hb_bool_t
|
hb_bool_t
|
||||||
hb_ot_layout_has_substitution (hb_face_t *face);
|
hb_ot_layout_has_substitution (hb_face_t *face);
|
||||||
|
|
||||||
/* GSUB is not font-size dependent, so we apply on face */
|
/* XXX ?? GSUB is not font-size dependent, so we apply on face */
|
||||||
hb_bool_t
|
hb_bool_t
|
||||||
hb_ot_layout_substitute_lookup (hb_face_t *face,
|
hb_ot_layout_substitute_lookup (hb_face_t *face,
|
||||||
hb_buffer_t *buffer,
|
hb_buffer_t *buffer,
|
||||||
|
|
Loading…
Reference in New Issue