[HarfBuzz] How to override Harfbuzz's freetype functions?

Deron Kazmaier deron at pagestream.org
Tue Feb 1 10:09:21 PST 2011


On 2/1/11 7:56 AM, Tom Hacohen wrote:
> Dear all,
>
> I ran a test application in callgrind and noticed that the calls to
> FT_Load_Glyph are what slows everything down. We already have glyph
> cache in EFL and I would really like to be able to use it with harfbuzz.
> At first glance, it seems like I can't override harfbuzz's
> hb_ft_get_glyph_advance from the outside, but I have to implement my own
> class and put it in harfbuzz, which is less than convinient.
>
> I'd very much like to be able to do that, because using my cache will
> make everything a lot faster.
>
> Are my observations correct?
>
> How do you guys (that use harfbuzz in other projects) solve it?
>
> Thanks,
> Tom.

Hi Tom,

You can set the unicode functions for the hb_buffer and use your own 
routines. Basically:

  hb_buffer_t *buffer;
         buffer = hb_buffer_create(32);

  hb_font_funcs_t *funcs;

         funcs = hb_font_funcs_create ();
         hb_font_funcs_set_glyph_func (funcs, your_hb_font_get_glyph);
         hb_font_funcs_set_glyph_advance_func (funcs, 
your_hb_font_get_glyph_advance);
         hb_font_funcs_set_glyph_extents_func (funcs, 
your_hb_font_get_glyph_extents);
         hb_font_funcs_set_contour_point_func (funcs, 
your_hb_font_get_contour_point);
         hb_font_funcs_set_kerning_func (funcs, your_hb_font_get_kerning);
         hb_buffer_set_unicode_funcs(buffer, funcs );

Ok?

Deron




More information about the HarfBuzz mailing list