[HarfBuzz] HarfBuzz glyph offsets
Nikolay Sivov
bunglehead at gmail.com
Wed Dec 23 20:23:02 PST 2015
On 24.12.2015 6:03, 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).
Offsets are adjustments accumulated during shaping, bearings are design
glyph metrics. Instead of using metrics you should be using actual glyph
box, CBox or BBox in freetype terms.
>
>
>
> _______________________________________________
> HarfBuzz mailing list
> HarfBuzz at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/harfbuzz
>
More information about the HarfBuzz
mailing list