[HarfBuzz] font functions overrides and user_data

Behdad Esfahbod behdad at behdad.org
Mon Jul 8 08:51:19 PDT 2013


On 13-07-08 09:27 AM, thomas bonfort wrote:
> Hi,

Hi Thomas,


> 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).

Welcome!


> * I'm looking at how to override a *single* font function callback
> while leaving the others at their default. Is this possible at all?
> (http://lists.freedesktop.org/archives/harfbuzz/2011-April/001158.html
> 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
> callbacks.

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
> part).

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,
behdad

> I can live with that but was wondering if there was anything more
> efficient.
> 
> Thanks and best regards,
> Thomas

-- 
behdad
http://behdad.org/



More information about the HarfBuzz mailing list