Use actual glyph width, not the guessed spaceWidth, to determine the width of the space character in VLW fonts - #159
Conversation
…width of the space character
|
Hello, @kirberich We need to investigate how this pull request affects other existing fonts, but this will take time, so it's difficult to merge it immediately. |
Some VLW exporters (e.g. the Processing font converter) omit the space glyph from the file. Falling through to drawCharDummy would render the missing-glyph box for every space, so restore the previous silent guessed-width behavior for that case only. Fonts that do contain a space glyph keep using the actual glyph metrics.
|
Thank you for the fix, and sorry it took so long to get back to this. The analysis here is correct: One case needed an additional guard, though: some VLW exporters (e.g. the Processing font converter) omit the space glyph entirely — the Verified on real hardware with both cases:
|
There was a problem hiding this comment.
Pull request overview
Updates VLW rendering so space characters use their glyph’s actual advance width when available.
Changes:
- Uses the space glyph’s stored metrics during rendering.
- Retains guessed-width fallback when the glyph is absent.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
I was hitting an issue where
textWidthwould give me results that were slightly off from the actual width of a string drawn to the display when using a VLW font today. After a bunch of digging, it seems that the problem is thatdrawCharuses a special case for the space character where it usesthis->spaceWidth(which according to the comment in the code is just a guess), instead of the width of the space glyph, buttextWidthdoesn't use this special case.I'm not sure why this special case was there, and I'm not sure if this would break for some other fonts, but for my case at least the rendering looks correct, and textWidth and drawChar now agree.
Note: the test was done with a custom font, Bookerly 24pt, created using the M5 font converter
Also note: I pointed this at
developas that's what i'm using, let me know if that's wrong