[HarfBuzz] Inheriting/copying font functions
Tom Hacohen
tom.hacohen at partner.samsung.com
Thu May 12 00:17:15 PDT 2011
On Wed, 2011-05-11 at 10:09 -0400, Behdad Esfahbod wrote:
> You start by subclassing the font:
>
> font = hb_font_create_sub_font (parent);
>
> And set your own font-funcs on it:
>
> hb_font_set_funcs (font, ffuncs, your_user_data, your_destroy);
>
> Now you only have to override any functions you need, and in your function if
> you need to chain up, you do, eg.
>
> {
> if (not in cache...) {
> hb_font_get_contour_point (hb_font_get_parent (font),
> glyph, point_index, x, y);
> add to cache...
> } else {
> lookup from cache...
> }
> }
My code now looks like:
hb_ft_font = hb_ft_font_create(ft_face, NULL);
hb_font = hb_font_create_sub_font(hb_ft_font);
hb_font_set_funcs(hb_font, my_font_funcs_get(), my_data,NULL);
hb_shape(hb_font, buffer, NULL, 0);
hb_font_destroy(hb_font);
hb_font_destroy(hb_ft_font);
my_font_funcs_get() return my font functions that have either nil or my
implementation alternatives.
Thanks,
Tom.
More information about the HarfBuzz
mailing list