[HarfBuzz] font functions overrides and user_data
behdad at behdad.org
Tue Jul 9 07:54:29 PDT 2013
On 13-07-09 10:48 AM, thomas bonfort wrote:
> 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).
glyph_h_kerning is used for kerning if the font has no GPOS table.
glyph_h_origin, glyph_v_origin, and glyph_v_kerning can be safely left unset
unless you need vertical text support.
glyph_extents is used for fallback positioning of combining marks if the font
doesn't have a GPOS table.
glyph_contour_point is used during GPOS for fine-tuned positioning in
combination with hinting. You can safely ignore that one too.
get_glyph_name / get_glyph_from_name are not used for shaping.
> Best regards,
> On 8 July 2013 17:51, Behdad Esfahbod <behdad at behdad.org> wrote:
>> On 13-07-08 09:27 AM, thomas bonfort wrote:
>> 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).
>>> * 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