[HarfBuzz] Units of members of hb_glyph_position_t

Eli Zaretskii eliz at gnu.org
Tue May 28 15:44:50 UTC 2019


> From: Behdad Esfahbod <behdad at behdad.org>
> Date: Mon, 27 May 2019 21:21:10 -0400
> Cc: "harfbuzz at lists.freedesktop.org" <harfbuzz at lists.freedesktop.org>
> 
>  control those units (if they are under the client program's control).
> 
> They are controlled mainly using hb_font_set_scale().
>  
>  In particular, I get a huge value of x_advance for the letter U+05EA
>  HEBREW LETTER TAV when it is followed by U+05BB HEBREW POINT QUBUTS.
>  The value of x_advance I get is 1229, which is too large even after
>  dividing by 64 (which, btw, I still am not sure is TRT in my case,
> 
> FreeType works in 26.6 fixed-point, ie. 64 units per 1.0.  That's where the 64 value comes from.  And you
> don't see it in your code because hb_ft_font_create* sets that on hb_font for you.
> 
> In your Windows code, you should call hb_font_set_scale().  I believe right now you are *not* calling, and you
> get values in the face's UPEM.  That's the default scale for fonts.  You can get the face UPEM using
> hb_face_get_upem(). 

OK, I figured out how to scale the units from UPEM to pixels for a
given font size, and now I see reasonable results after such scaling.

However, I think something is still amiss, because I still don't
understand how to determine the values with which to call
hb_font_set_scale.  Say I call it with an integer value N, what will
that produce in terms of values of hb_glyph_position_t?  Will the
values there be in the 0..N range, where N means the full height of
the em box?  If so, how would I then convert those values to pixels --
this conversion will need the font size as well, right?  And if so, I
might well leave the values in UPEM units, and convert them to pixels
by hand.  I feel that I'm still missing something, since you said "you
should call hb_font_set_scale".  So presumably if I call that
function, conversion to pixels will somehow become easier?

Thanks.


More information about the HarfBuzz mailing list