[HarfBuzz] font functions overrides and user_data

thomas bonfort thomas.bonfort at gmail.com
Tue Jul 9 07:48:32 PDT 2013


Thanks Behdad, using a subfont works perfectly!

I have only provided an implementation for get_glyph and get_h_advance
as that was some information I had easily available. From some
previous debugging I however observed that the other callbacks (except
get_h_kerning) were never being called on my test cases. Is there a
document somewhere that what point me to which configurations would
lead to those being called, in order for me to assess whether it would
be worth providing those callbacks (I currently cache advances, but
not metrics).

Best regards,
Thomas

On 8 July 2013 17:51, Behdad Esfahbod <behdad at behdad.org> wrote:
> 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