alexheretic / glyph-brush

Fast GPU cached text rendering
Apache License 2.0
673 stars 52 forks source link

Glyphs taller than font.ascent are clipped #143

Open alexheretic opened 2 years ago

alexheretic commented 2 years ago

https://github.com/alexheretic/ab-glyph/issues/50 font CooperHewitt-Book.otf glyphs clip outside of font ascender/descender vbounds. This means the top line (for default layout) glyphs may clip too.

This can be fixed by using the font line_gap as top-padding for the first line, essentially shifting down the glyphs of all fonts with non-zero line_gap values.

I'm unsure if this is the "correct" thing to do though. It's possible the font itself is wrong instead?

alexheretic commented 2 years ago

Looking at this font in gimp, it seems to "fix" the layout on the fly using the render bounds. That's not something glyph-brush-layout can do so easily as we calculate all glyph positions without outlining the glyphs.

https://user-images.githubusercontent.com/2331607/146226954-66613e65-9124-4799-9de4-e7b7b143bb0d.mp4

This does also suggest that using line_gap as top-padding isn't correct :disappointed:

alexheretic commented 2 years ago

A workaround is to give the sections with this font some extra margin at the top.

However, depending on the to_vertex fn implementation, glyph bound clipping may need to also be disabled. (This is not specified by glyph-brush itself, though the opengl example does clip glyphs.