Add font->has_...() to check for individual nil font funcs
Hopefully this wouldn't break any compiler. There was some magic moments to getting this to compile...
This commit is contained in:
parent
88e9a9bcae
commit
762770c964
|
@ -63,12 +63,13 @@ struct hb_font_funcs_t {
|
|||
|
||||
/* Don't access these directly. Call font->get_*() instead. */
|
||||
|
||||
union {
|
||||
struct {
|
||||
union get_t {
|
||||
struct get_funcs_t {
|
||||
#define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_func_t name;
|
||||
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
|
||||
#undef HB_FONT_FUNC_IMPLEMENT
|
||||
} f;
|
||||
void (*array[]) (void);
|
||||
} get;
|
||||
|
||||
struct {
|
||||
|
@ -146,6 +147,20 @@ struct hb_font_t {
|
|||
|
||||
/* Public getters */
|
||||
|
||||
HB_INTERNAL bool has_func (unsigned int i);
|
||||
|
||||
/* has_* ... */
|
||||
#define HB_FONT_FUNC_IMPLEMENT(name) \
|
||||
bool \
|
||||
has_##name##_func (void) \
|
||||
{ \
|
||||
hb_font_funcs_t *funcs = this->klass; \
|
||||
unsigned int i = offsetof (hb_font_funcs_t::get_t::get_funcs_t, name) / sizeof (funcs->get.array[0]); \
|
||||
return has_func (i); \
|
||||
}
|
||||
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
|
||||
#undef HB_FONT_FUNC_IMPLEMENT
|
||||
|
||||
inline hb_bool_t has_glyph (hb_codepoint_t unicode)
|
||||
{
|
||||
hb_codepoint_t glyph;
|
||||
|
|
|
@ -487,6 +487,13 @@ hb_font_funcs_set_##name##_func (hb_font_funcs_t *ffuncs, \
|
|||
HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
|
||||
#undef HB_FONT_FUNC_IMPLEMENT
|
||||
|
||||
bool
|
||||
hb_font_t::has_func (unsigned int i)
|
||||
{
|
||||
if (parent && parent != hb_font_get_empty () && parent->has_func (i))
|
||||
return true;
|
||||
return this->klass->get.array[i] != _hb_font_funcs_parent.get.array[i];
|
||||
}
|
||||
|
||||
/* Public getters */
|
||||
|
||||
|
|
Loading…
Reference in New Issue