[HarfBuzz] Using FreeType load flags

Jamie Dale jamiedale88+harfbuzz at gmail.com
Fri Aug 28 18:05:08 PDT 2015


I went ahead and created and implementation using our existing font
cache and load flags.

Font rendering now looks much closer to what it was pre-HarfBuzz (I
still need to do some more tests to make sure that nothing is broken,
but visually, things seem to be pretty okay), however I did notice
that using the correct flags has seemingly caused FT_Get_Advance to be
significantly slower than it was previously. I solved this with
judicious use of caching, which got my performance back to where it
was when using the vanilla HarfBuzz FreeType implementation - a little
disappointing, as I was hoping the caching would improve the overall
performance rather than just bring it up-to-par with what we got out
of the box.

One other side effect of using the correct flags for FT_Get_Advance is
that the transform we set on our font is now (seemingly) being
respected correctly. I forgot to mention it before, but along with the
load flags, we do need FT_Set_Transform (we only allow a scale) to be
respected by the text shaping. Both of these things can be set by our
end users for their products, and we can't really break their existing
set-ups.

On the topic of performance and caching. The slowest thing on my
profile now is the call to hb_shape_plan_create_cached... as far as I
can tell, it's never actually caching anything. Within the call to
hb_shape_plan_create, there's also a lot of time being spent in
hb_blob_set_user_data (although I couldn't quite see how from looking
at the code, perhaps my symbols are wrong - I'll try and get some full
debug symbols when I'm back at work).

I'm also guessing that there's no way to control the allocator used by
HarfBuzz? From looking at the code, it seems to just call the standard
malloc/free/etc rather than allowing a custom allocator.

-Jamie.

On 28 August 2015 at 12:38, Jamie Dale <jamiedale88+harfbuzz at gmail.com> wrote:
> Hey all,
>
> I'm currently working on integrating HarfBuzz into an existing
> FreeType based text rendering system, however I notice that the
> default FreeType wrapper doesn't allow you to control the load flags
> used by FT_Load_Glyph, and we need these as we use them to control the
> hinting method used by some of our fonts.
>
> I was going to create my own HarfBuzz font wrapper that used our
> existing font cache with the correct load flags (this has the added
> benefit of avoiding repeated calls to FT_Load_Glyph, as we cache off
> some glyph data), however I noticed some comments in hb-ft.cc that
> makes me think that it won't quite be that simple.
>
>>
>> We don't handle any load_flags.  That definitely has API implications. :(
>>
>> FreeType works in 26.6 mode.  Clients can decide to use that mode, and everything
>> would work fine.  However, we also abuse this API for performing in font-space,
>> but don't pass the correct flags to FreeType.  We just abuse the no-hinting
>> mode for that, such that no rounding etc happens.  As such, we don't set ppem, and
>> pass NO_HINTING around.  This seems to work best, until we go ahead and add a full load_flags API.
>>
>
> I was wondering what, if any, issues you might expect to see if I
> change the load flags to include hinting methods, and also whether you
> had any suggestions for how to work around those issues (ideally
> without having to change HarfBuzz itself - we like to keep our third
> party dependencies vanilla where possible as it makes them easier to
> upgrade in the future).
>
> Thanks,
> Jamie.


More information about the HarfBuzz mailing list