return true;
}
}
- if (table_index) *table_index = NO_INDEX;
+ if (table_index) *table_index = Index::NOT_FOUND_INDEX;
return false;
}
inline const TableDirectory& get_table_by_tag (hb_tag_t tag) const
#include "hb-blob.h"
-/* Table/script/language-system/feature/... not found */
-#define NO_INDEX ((unsigned int) 0xFFFF)
-
-
/*
* Casts
/* Glyph index number, same as uint16 (length = 16 bits) */
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 */
typedef USHORT Offset;
return true;
}
}
- if (index) *index = NO_INDEX;
+ if (index) *index = Index::NOT_FOUND_INDEX;
return false;
}
};
};
-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,
unsigned int *_count /* IN/OUT */,
unsigned int *_indexes /* OUT */) const
inline int get_required_feature_index (void) const
{
if (reqFeatureIndex == 0xffff)
- return NO_INDEX;
+ return Index::NOT_FOUND_INDEX;
return reqFeatureIndex;;
}
{ return langSys.get_tags (start_offset, lang_sys_count, lang_sys_tags); }
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;
}
inline bool find_lang_sys_index (hb_tag_t tag, unsigned int *index) const
hb_tag_t script_tag,
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);
if (g.find_script_index (script_tag, script_index))
const hb_tag_t *script_tags,
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);
while (*script_tags)
hb_tag_t language_tag,
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);
if (s.find_lang_sys_index (language_tag, language_index))
hb_tag_t feature_tag,
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 LangSys &l = g.get_script (script_index).get_lang_sys (language_index);
? " Default Language System\n"
: " Language System %2d of %2d: %.4s\n", n_langsys, num_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");
int num_features = langsys.get_feature_count ();