diff --git a/src/hb-aat-layout-feat-table.hh b/src/hb-aat-layout-feat-table.hh index 41fa7da70..899a9b9b6 100644 --- a/src/hb-aat-layout-feat-table.hh +++ b/src/hb-aat-layout-feat-table.hh @@ -39,12 +39,10 @@ namespace AAT { struct SettingName { - static int cmp (const void *key_, const void *entry_) + int cmp (hb_aat_layout_feature_selector_t key) const { - hb_aat_layout_feature_selector_t key = * (hb_aat_layout_feature_selector_t *) key_; - const SettingName * entry = (const SettingName *) entry_; - return key < entry->setting ? -1 : - key > entry->setting ? +1 : + return key < setting ? -1 : + key > setting ? +1 : 0; } @@ -65,6 +63,7 @@ struct SettingName public: DEFINE_SIZE_STATIC (4); }; +DECLARE_NULL_NAMESPACE_BYTES (AAT, SettingName); struct feat; @@ -123,15 +122,10 @@ struct FeatureName inline hb_ot_name_id_t get_feature_name_id () const { return nameIndex; } - inline hb_ot_name_id_t get_feature_selector_name_id (const feat *feat, + inline hb_ot_name_id_t get_feature_selector_name_id (const feat *feat, hb_aat_layout_feature_selector_t key) const { - const SettingName* setting = (SettingName*) hb_bsearch (&key, feat+settingTableZ, - nSettings, - SettingName::static_size, - SettingName::cmp); - - return setting ? setting->get_name_id () : (hb_ot_name_id_t) HB_OT_NAME_ID_INVALID; + return (feat+settingTableZ).lsearch (nSettings, key).get_name_id (); } inline bool sanitize (hb_sanitize_context_t *c, const void *base) const diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh index 9b412dbce..f4d0238ea 100644 --- a/src/hb-open-type.hh +++ b/src/hb-open-type.hh @@ -376,11 +376,11 @@ struct UnsizedArrayOf { return hb_array (arrayZ, len); } template - inline Type &lsearch (unsigned int len, const T &x) - { return *as_array (len).lsearch (x, &Crap (T)); } + inline Type &lsearch (unsigned int len, const T &x, Type ¬_found = Crap (Type)) + { return *as_array (len).lsearch (x, ¬_found); } template - inline const Type &lsearch (unsigned int len, const T &x) const - { return *as_array (len).lsearch (x, &Null (T)); } + inline const Type &lsearch (unsigned int len, const T &x, const Type ¬_found = Null (Type)) const + { return *as_array (len).lsearch (x, ¬_found); } inline void qsort (unsigned int len, unsigned int start = 0, unsigned int end = (unsigned int) -1) { as_array (len).qsort (start, end); } @@ -589,11 +589,11 @@ struct ArrayOf } template - inline Type &lsearch (const T &x) - { return *as_array ().lsearch (x, &Crap (T)); } + inline Type &lsearch (const T &x, Type ¬_found = Crap (Type)) + { return *as_array ().lsearch (x, ¬_found); } template - inline const Type &lsearch (const T &x) const - { return *as_array ().lsearch (x, &Null (T)); } + inline const Type &lsearch (const T &x, const Type ¬_found = Null (Type)) const + { return *as_array ().lsearch (x, ¬_found); } inline void qsort (unsigned int start = 0, unsigned int end = (unsigned int) -1) { as_array ().qsort (start, end); } diff --git a/src/hb-static.cc b/src/hb-static.cc index 3ea640246..a22f729ef 100644 --- a/src/hb-static.cc +++ b/src/hb-static.cc @@ -27,10 +27,11 @@ #include "hb.hh" #include "hb-open-type.hh" -#include "hb-aat-layout-common.hh" -#include "hb-ot-layout-common.hh" - #include "hb-face.hh" + +#include "hb-aat-layout-common.hh" +#include "hb-aat-layout-feat-table.hh" +#include "hb-ot-layout-common.hh" #include "hb-ot-cmap-table.hh" #include "hb-ot-head-table.hh" #include "hb-ot-maxp-table.hh" @@ -44,6 +45,7 @@ DEFINE_NULL_NAMESPACE_BYTES (OT, Index) = {0xFF,0xFF}; DEFINE_NULL_NAMESPACE_BYTES (OT, LangSys) = {0x00,0x00, 0xFF,0xFF, 0x00,0x00}; DEFINE_NULL_NAMESPACE_BYTES (OT, RangeRecord) = {0x00,0x01, 0x00,0x00, 0x00, 0x00}; DEFINE_NULL_NAMESPACE_BYTES (OT, CmapSubtableLongGroup) = {0x00,0x00,0x00,0x01, 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00}; +DEFINE_NULL_NAMESPACE_BYTES (AAT, SettingName) = {0xFF,0xFF, 0xFF,0xFF}; /* Hand-coded because Lookup is a template. Sad. */ const unsigned char _hb_Null_AAT_Lookup[2] = {0xFF, 0xFF};