-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
Steps to reproduce
This is more of an analytical code issue, but the issue is visible in generated glyph atlases using the stb implementation.
To reproduce:
- Use the
stbtext atlas implementation. - In come situations characters will appear like they have their bottoms cut off.
Using renderdoc on the subsequent binary, one can see the Glyphs in the atlas are not laid out correctly in relation to the padding between glyphs.
Expected results
Glyphs shouldn't be cut off along the bottom.
Actual results
Glyphs sometimes cut off along their bottom.
Code sample
I believe the issue is in the following section of code:
Code sample
if (!has_color || DISABLE_COLOR_FONT_SUPPORT) {
stbtt_MakeGlyphBitmap(typeface_stb->GetFontInfo(), output,
location.size.width - kPadding,
location.size.height - kPadding,
bitmap->GetRowBytes(), scale_x, scale_y, glyph.index);Note the - kPadding.
At this point, the location used is the entry describing the glyph in the atlas, but it does not include padding, so the subtraction of kPadding is not necessary.
Screenshots or Video
Screenshots / Video demonstration
Here's a screenshot of some text rendered with the incorrect code:

And a screenshot of some glyphs in the atlas via renderdoc. Note there is double the paddng between characters and some characters (like the "i") are clipped along one side.
Correcting the code the text is improved (though in our case still not strictly correct)
And lastly, examining the glyph atlas using renderdoc with a fix in place, the layout of glyphs is improved:
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output
[Paste your output here]

