Clean up NO_INDEX
This commit is contained in:
parent
fe9bc070e1
commit
b5db4f1e4e
|
@ -87,7 +87,7 @@ typedef struct OffsetTable
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (table_index) *table_index = NO_INDEX;
|
if (table_index) *table_index = Index::NOT_FOUND_INDEX;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
inline const TableDirectory& get_table_by_tag (hb_tag_t tag) const
|
inline const TableDirectory& get_table_by_tag (hb_tag_t tag) const
|
||||||
|
|
|
@ -32,10 +32,6 @@
|
||||||
#include "hb-blob.h"
|
#include "hb-blob.h"
|
||||||
|
|
||||||
|
|
||||||
/* Table/script/language-system/feature/... not found */
|
|
||||||
#define NO_INDEX ((unsigned int) 0xFFFF)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Casts
|
* Casts
|
||||||
|
@ -418,6 +414,12 @@ DEFINE_NULL_DATA (Tag, " ");
|
||||||
/* Glyph index number, same as uint16 (length = 16 bits) */
|
/* Glyph index number, same as uint16 (length = 16 bits) */
|
||||||
typedef USHORT GlyphID;
|
typedef USHORT GlyphID;
|
||||||
|
|
||||||
|
/* Script/language-system/feature index */
|
||||||
|
struct Index : USHORT {
|
||||||
|
static const unsigned int NOT_FOUND_INDEX = 0xFFFF;
|
||||||
|
};
|
||||||
|
DEFINE_NULL_DATA (Index, "\xff\xff");
|
||||||
|
|
||||||
/* Offset to a table, same as uint16 (length = 16 bits), Null offset = 0x0000 */
|
/* Offset to a table, same as uint16 (length = 16 bits), Null offset = 0x0000 */
|
||||||
typedef USHORT Offset;
|
typedef USHORT Offset;
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ struct RecordArrayOf : ArrayOf<Record<Type> > {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index) *index = NO_INDEX;
|
if (index) *index = Index::NOT_FOUND_INDEX;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -117,17 +117,8 @@ struct RecordListOf : RecordArrayOf<Type>
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
struct IndexArray : ArrayOf<USHORT>
|
struct IndexArray : ArrayOf<Index>
|
||||||
{
|
{
|
||||||
inline USHORT operator [] (unsigned int i) const
|
|
||||||
{
|
|
||||||
if (unlikely (i >= this->len)) {
|
|
||||||
USHORT u;
|
|
||||||
u.set (NO_INDEX);
|
|
||||||
return u;
|
|
||||||
}
|
|
||||||
return this->array[i];
|
|
||||||
}
|
|
||||||
inline unsigned int get_indexes (unsigned int start_offset,
|
inline unsigned int get_indexes (unsigned int start_offset,
|
||||||
unsigned int *_count /* IN/OUT */,
|
unsigned int *_count /* IN/OUT */,
|
||||||
unsigned int *_indexes /* OUT */) const
|
unsigned int *_indexes /* OUT */) const
|
||||||
|
@ -163,7 +154,7 @@ struct LangSys
|
||||||
inline int get_required_feature_index (void) const
|
inline int get_required_feature_index (void) const
|
||||||
{
|
{
|
||||||
if (reqFeatureIndex == 0xffff)
|
if (reqFeatureIndex == 0xffff)
|
||||||
return NO_INDEX;
|
return Index::NOT_FOUND_INDEX;
|
||||||
return reqFeatureIndex;;
|
return reqFeatureIndex;;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +188,7 @@ struct Script
|
||||||
{ return langSys.get_tags (start_offset, lang_sys_count, lang_sys_tags); }
|
{ return langSys.get_tags (start_offset, 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 == Index::NOT_FOUND_INDEX) return get_default_lang_sys ();
|
||||||
return this+langSys[i].offset;
|
return this+langSys[i].offset;
|
||||||
}
|
}
|
||||||
inline bool find_lang_sys_index (hb_tag_t tag, unsigned int *index) const
|
inline bool find_lang_sys_index (hb_tag_t tag, unsigned int *index) const
|
||||||
|
|
|
@ -360,7 +360,7 @@ 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)
|
||||||
{
|
{
|
||||||
ASSERT_STATIC (NO_INDEX == HB_OT_LAYOUT_NO_SCRIPT_INDEX);
|
ASSERT_STATIC (Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_SCRIPT_INDEX);
|
||||||
const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
|
const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
|
||||||
|
|
||||||
if (g.find_script_index (script_tag, script_index))
|
if (g.find_script_index (script_tag, script_index))
|
||||||
|
@ -384,7 +384,7 @@ hb_ot_layout_table_choose_script (hb_face_t *face,
|
||||||
const hb_tag_t *script_tags,
|
const hb_tag_t *script_tags,
|
||||||
unsigned int *script_index)
|
unsigned int *script_index)
|
||||||
{
|
{
|
||||||
ASSERT_STATIC (NO_INDEX == HB_OT_LAYOUT_NO_SCRIPT_INDEX);
|
ASSERT_STATIC (Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_SCRIPT_INDEX);
|
||||||
const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
|
const GSUBGPOS &g = get_gsubgpos_table (face, table_tag);
|
||||||
|
|
||||||
while (*script_tags)
|
while (*script_tags)
|
||||||
|
@ -439,7 +439,7 @@ hb_ot_layout_script_find_language (hb_face_t *face,
|
||||||
hb_tag_t language_tag,
|
hb_tag_t language_tag,
|
||||||
unsigned int *language_index)
|
unsigned int *language_index)
|
||||||
{
|
{
|
||||||
ASSERT_STATIC (NO_INDEX == HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX);
|
ASSERT_STATIC (Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX);
|
||||||
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);
|
||||||
|
|
||||||
if (s.find_lang_sys_index (language_tag, language_index))
|
if (s.find_lang_sys_index (language_tag, language_index))
|
||||||
|
@ -515,7 +515,7 @@ 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)
|
||||||
{
|
{
|
||||||
ASSERT_STATIC (NO_INDEX == HB_OT_LAYOUT_NO_FEATURE_INDEX);
|
ASSERT_STATIC (Index::NOT_FOUND_INDEX == HB_OT_LAYOUT_NO_FEATURE_INDEX);
|
||||||
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);
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ main (int argc, char **argv)
|
||||||
? " Default Language System\n"
|
? " Default Language System\n"
|
||||||
: " Language System %2d of %2d: %.4s\n", n_langsys, num_langsys,
|
: " Language System %2d of %2d: %.4s\n", n_langsys, num_langsys,
|
||||||
(const char *)script.get_lang_sys_tag (n_langsys));
|
(const char *)script.get_lang_sys_tag (n_langsys));
|
||||||
if (langsys.get_required_feature_index () == NO_INDEX)
|
if (langsys.get_required_feature_index () == Index::NOT_FOUND_INDEX)
|
||||||
printf (" No required feature\n");
|
printf (" No required feature\n");
|
||||||
|
|
||||||
int num_features = langsys.get_feature_count ();
|
int num_features = langsys.get_feature_count ();
|
||||||
|
|
Loading…
Reference in New Issue