[HarfBuzz] font functions overrides and user_data
behdad at behdad.org
Mon Jul 8 08:51:19 PDT 2013
On 13-07-08 09:27 AM, thomas bonfort wrote:
> This is my first post to this list, so please excuse me in advance if
> this a stupid question (but please do point me to a url in that case
> as I haven't found anything online yet).
> * I'm looking at how to override a *single* font function callback
> while leaving the others at their default. Is this possible at all?
> is the closest I can get to)
The way we envision people do that is to use hb_font_create_sub_font() to
create a second font and install the overlay font-funcs on it which only
implements one function. All other functions will chain up to the parent font.
> * I would like to add my own structure to user_data when going in the
You can set font_data in hb_font_set_funcs of the sub font.
> I 'm not understanding how I should be using the
> hb_font_funcs_set_user_data() function (namely the hb_user_data_key_t
You shouldn't need that. In case you want to use that function, just declare
a static hb_user_data_key_t and pass that as your key.
> * which brings me to my last question: I can't seem to find a method
> to get the hb_font_funcs_t from an existing hb_font_t . Is that at all
> possible or should I be caching them?
Just cache a single instance after constructing.
> The answer to the two last questions might just be to recreate a
> hb_font_funcs_t from scratch each time I need to change the user_data.
No. Cache the funcs, but use font-data to pass the closure data.
Hope that helps,
> I can live with that but was wondering if there was anything more
> Thanks and best regards,
More information about the HarfBuzz