[HarfBuzz] HarfBuzz glyph offsets

Jonathan Blow jon at number-none.com
Wed Dec 23 14:37:38 PST 2015


>
>
>
> FreeType does not give you any offsets. Unless you mean the side
> bearings, but they are very different things and shouldn’t be used for
> glyph placement at all. You are getting 0 offsets because either the
> font does not do any special positioning here (not uncommon for old
> Chinese fonts), or something is wrong in the way the text is shaped.
>

​Okay, this is confusing. Maybe this has to do with different cultural
assumptions or different ideas about what the software looks like, but
bearings are just offsets to me. When I look at this diagram from the
FreeType documentation:

http://www.freetype.org/freetype2/docs/tutorial/step2.html

It says that wherever the cursor is, add bearingX as an offset and draw the
thing in the box. And in fact this is how I draw things when they show up
in the proper places. So I am not sure what you mean here; my guess is that
you are thinking of there being a little bit of a software stack living
below you that itself adds bearingX to draw the thing in the box, so that
it would be incorrect for you to do so?

So then my interpretation is that the 'offsets' from HB are additional and
are not meant to include bearings, and are only for kerning or for like
things, and I should actually add both offsets together I guess.


> For Arabic, it looks like you are applying the kerning on the wrong
> direction, see how the ا in لطراز is moving closer to the ز instead of
> the ر as I’d expect it.
>

​That's quite possible, I will investigate. My old code, pre-HB, would
switch to drawing glyphs right-to-left for RTL languages, but upon starting
to use HB I was pretty confused because it looks to me like HB is always
giving me glyphs in left-to-right order, even for RTL languages (if there
is a setting that changes this, I have no idea). So at some point I just
simplified all the rendering code to always be LTR, though it is possible I
made a mistake or else for some reason kerning is RTL while everything else
is LTR which would be really weird??

Oh wait ... I remember something about kerning in otf/ttf always having to
do with the logical order of glyphs and not the display order; does HB keep
this convention? I had interpreted offsets as being screen positions, not
deltas in some abstract kerning space, so that could be the source of the
issue.
 ​


>
> If you are not setting the correct text script, then you are unlikely to
> get correct output. You need to analyse the text and pass the correct
> script to HarfBuzz (resolving characters with common and inhere tied
> script properties, etc).
>

​In this case we have a fixed set of languages (currently 15) that we are
just swapping in and out, so I can set this stuff on a per-language basis,
so I guess for each one I need to know:

* what to pass to hb_buffer_set_script​

​* what to pass to hb_buffer_set_language (I am not sure how this latter
affects results in different ways than the former)

... Anything else?​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/harfbuzz/attachments/20151223/e9514402/attachment.html>


More information about the HarfBuzz mailing list