[HarfBuzz] Questions about positioning

Sylvain Becker sylvain.becker at gmail.com
Mon Nov 19 16:52:27 UTC 2018


Hello,

I am using HarfBuzz and FreeType to render text in 70 languages and result
is very good, even looking into details!
I wonder if I could get some explanation to deal with better positioning.

Both HB and FT provides datas: which ones to choose explicitly?
Format is fractional 26/6, but how and when to round?

I've sum up all positions datas (with owner prefixes).
This is about horizontal layout and LTR (but could also be RTL).

>From FreeType (Face/glyph/metrics).
- FT_offset_x (horiBearingX),
- FT_kerning_x
- FT_rsb/lsb_deltas (hinting)
- FT_advance_x

>From HarfBuzz (hb_glyph_position_t)
- HB_x_advance
- HB_x_offset
- HB_y_offset

In y axis:
- FT_offset_y (ascender or height - horiBearingY)
- HB_y_offset

Rounding:
- FLOOR(X) (((X) & -64) / 64)
- CEIL(X)  FLOOR((X) + 63)
- ROUND(X) FLOOR((X) + 32)

- How to round and when? (Why does HB provide fractionnals if tutorials
start by using floor()?).
- With hinting (auto hinted), should we use FT rsb/lsb_detlas?
- What about FT kerning ?

Of course I've a start of a solution. Result looks 99% ok I guess.
Maybe I've some rounding (1px) between spacing or hinted glyph offset.

I've also seen:
https://github.com/harfbuzz/harfbuzz-tutorial/blob/master/hello-harfbuzz-freetype.c
https://cgit.freedesktop.org/cairo/tree/src/cairo-ft-font.c
But for instance:
- HB provides fractionals 26/6, but tutorial starts by using floor()?
- Cairo convert to double and don't use rsb/lsb_delta, not even kerning and
is not aware of HB ?

Thanks for you help,
Sylvain
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/harfbuzz/attachments/20181119/e5742f81/attachment.html>


More information about the HarfBuzz mailing list