-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Description
Steps to reproduce
- Run a test case which uses the
stbbased glyph atlas implementation. - Examine the contents of the Glyph Atlas at runtime using
renderdocor other
Expected results
The size of the glyphs in the atlas should be correct for a given typeface size in Points.
That is, for a typeface of size 12pt, the difference between the highest ascender and lowest descender should be 16 pixels (12pt == 16px @ 160 dpi).
Actual results
Currently, the resultant glyphs are (for a 12pt font) about 12px` high. This is despite correct scaling calculations.
See the screenshots below.
Code sample
Code sample
[Paste your code here]Screenshots or Video
Screenshots / Video demonstration
Here's an analysis of the issue.
Baseline behavior for the Noto Sans typeface (normal, weight 400) can be gathered here.
Note that the vertical bar character (linux "pipe" symbol) covers the range from the highest ascender to the lowest descender. Thus it is 16px high for a 12pt font.
Looking at the current glyph atlas for an example using the same typeface at the same size (using renderdoc):
The vertical bar is 12 pixels high. This is plainly incorrect.
Debugging a little, we find the scaling calculations are correct. We scale the desired 12pt to 16px at runtime.
I've debugged this further and find that the function call stbtt_ScaleForPixelHeight is returning incorrect scale values for correct inputs.
Using the function stbtt_ScaleForMappingEmToPixels with identical inputs results in correctly sized glyphs.
I'll try to present a PR to change this function call ASAP.
CC @bdero and @chinmaygarde
Logs
Logs
[Paste your logs here]Flutter Doctor output
Doctor output
[Paste your output here]
