[HarfBuzz] HarfBuzz glyph offsets

Khaled Hosny khaledhosny at eglug.org
Wed Dec 23 22:34:34 PST 2015


On Wed, Dec 23, 2015 at 07:03:25PM -0800, Jonathan Blow wrote:
> The most frustrating thing about sending mail to a mailing list asking a
> question is that everyone treats you like a junior programmer.
> 
> 
> > > I am not able to conceive of any version of "render glyph" whose
> > > implementation does not involve adding horiBearingX
> >
> > Can you show your code? What are you using to turn the glyph onto pixels
> > on the screen?
> >
> > Normally people doing text layout don't do that bit themselves - they
> > use a third party rendering library to do it. *That* library needs to
> > care about sidebearings, but those of us working on the text layout
> > layer just need to worry about where the box starts and where the next
> > box is.
> >
> 
> "*That* library" is my code that I am talking about.
> 
> ​The first time I encounter a glyph that has not been rendered, I allocate
> space for it in a texture map in a reasonably-tightly-packed way according
> to the metrics given by FT, use FT_Load_Glyph(..., FT_LOAD_RENDER) to
> rasterize the glyph, copy the rasterized data into the texture map, then
> flag the texture as dirty so it will be uploaded to the GPU next time I use
> it.
> 
> In order to do this kind of thing, one only allocates space for the
> rectangular area in the glyph that actually uses any pixels, because
> packing empty space is dumb and wasteful. So when rendering glyphs, what
> one thinks of as "the glyph" is the actual rectangle that actually contains
> pixels in it. The bearing is then just the delta from the cursor position
> to the place at which you actually want to draw the glyph.
> 
> In other words, it is an offset. "Bearings" and "offsets" are Exactly. The.
> Same. Thing. The difference is just that the "bearing" is constant per
> glyph but HB's "offset" which I guess is due to kerning (and whatever else)
> varies per instance of a glyph. That is the only difference. You only think
> they aren't the same thing if you are hiding implementation details from
> yourself (which for many people is fine, if you don't need to think about
> lower-level code, great, go to town).

For us (text layout people and type designers) the glyph is the whole
thing with the space around it, where you are talking about the “ink”
part of it. HarfBuzz as layout engine is not concerned about the ink
inside the glyph and don’t even know any thing about it.

Regards,
Khaled


More information about the HarfBuzz mailing list