[HarfBuzz] HarfBuzz glyph offsets
Jonathan Blow
jon at number-none.com
Wed Dec 23 13:27:45 PST 2015
I am having a weird problem where I can render text with HarfBuzz and it is
generally doing the right thing in terms of shaping, but glyph offsets seem
to be coming out zero all the time, leading to general badness.
Here's a very clear case, I am rendering Chinese with the initial character
being this left-bracket-quote-thing that is supposed to be offset pretty
far to the right:
[image: Inline image 1]
(Yeah, nothing is really happening here to shape this text, I am just
saying that the shaping and all that is working fine with Arabic etc, but
this particular square-bracket quote is a really obvious case of an offset
being wrong).
The hb_glyph_position_t for this glyph gives me:
x_advance = 2880
y_advance = 0
x_offset = 0
y_offset = 0
Now, when I ask FreeType about the glyph,
format = FT_GLYPH_FORMAT_BITMAP
bitmap_left = 29
bitmap_top = 39
advance.x = 2880
advance.y = 0
metrics.horiBearingX = 1856
metrics.horiBearingY = 2496
metrics.horiAdvanace = 2880
So the advances agree, but the offsets are getting dropped on the floor
somehow.
When I change my code to use FreeType's offsets, I get:
[image: Inline image 2]
and all is right with the world.
But of course the whole *point* of using HarfBuzz is that I am supposed to
be able to listen to what HB tells me. So this is a problem.
(My Arabic rendering is messed up too, by the way ... you can see the
current results at this blog posting:
http://the-witness.net/news/2015/12/entering-the-home-stretch/ ... so it is
not like this is a corner case.)
To shape I am doing this:
hb_buffer_clear_contents(hb_buffer);
hb_buffer_set_direction(hb_buffer, HB_DIRECTION_LTR);
hb_buffer_set_script(hb_buffer, HB_SCRIPT_UNKNOWN);
hb_buffer_set_language(hb_buffer, hb_language_from_string("zh_TW", -1));
hb_buffer_add_utf8(hb_buffer, s, len, 0, len);
hb_shape(hb_font, hb_buffer, features, num_features);
(num_features == 0 in this case.)
It seems pretty straightforward. But since there doesn't seem to be any
real HB documentation anywhere that I can find, I don't really know.
This is using HarfBuzz 1.1.2 on Windows.
Anyone have any idea what is going on here?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/harfbuzz/attachments/20151223/348128b2/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 29962 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/harfbuzz/attachments/20151223/348128b2/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 36448 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/harfbuzz/attachments/20151223/348128b2/attachment-0003.png>
More information about the HarfBuzz
mailing list