[HarfBuzz] Zero-width joiner has width

Jonathan Kew jfkthame at gmail.com
Sat Aug 8 08:29:51 PDT 2015


On 8/8/15 15:50, Simon Cozens wrote:
> On 08/08/2015 15:25, Behdad Esfahbod wrote:
>>> Ok, that makes sense. And yes, I was ignoring the advance for glyphs and instead using Freetype to return the glyph width. I think I stole that bit of code from xetex. :-)
>>
>> Really?
>
> It may not be totally true. I don't know if XeTeX ignores the advance
> data - it probably doesn't

Yeah, I'd be really surprised if it did -- that would break kerning, for 
example. I think someone would probably have noticed by now. :)

> - but I certainly stole the glyph bounds
> measurement code from XeTeXFontInst::getGlyphBounds.
>
> However, when I replace SILE's glyph width measurement code with
> 'glyph_pos[j].x_advance / 64.0' instead of getting the glyph advance out
> of Freetype, I get slightly different output.
>
> With Harfbuzz's x_advance, a Gentium letter "m" at 10pt measures as
> 8.03125pt wide; using the width information from Freetype, I get
> 8.0322265625pt. I can't account for the discrepancy and I don't know who
> is right.

According to the hmtx table, at least in the version I happen to be 
looking at, "m" has a width of 1645 units. The font has 2048 units per 
em; so at 10pt, that works out to 10*1645/2048 = 8.03222656pt.

So FreeType seems to be telling you the truth; but that doesn't mean 
harfbuzz is wrong, necessarily. It sounds like you're using 26.6 
fixed-point values in harfbuzz, in which case you can only expect 6 
binary digits of fractional precision.

So I'd expect the value you'll be getting from glyph_pos[j].x_advance to 
be round(10*1645*64/2048) which comes to 512, and 512/64.0 is indeed 
8.03125.

For higher precision, you might want to consider using 16.16 rather than 
26.6 fixed-point arithmetic.

JK



More information about the HarfBuzz mailing list