Skip to content

Conversation

@kirberich
Copy link

I was hitting an issue where textWidth would 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 that drawChar uses a special case for the space character where it uses this->spaceWidth (which according to the comment in the code is just a guess), instead of the width of the space glyph, but textWidth doesn'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 develop as that's what i'm using, let me know if that's wrong

@lovyan03
Copy link
Collaborator

Hello, @kirberich
First and foremost, it's important to note that the width of drawChar and the width of textWidth are not necessarily the same.
drawChar renders a single character, but it can vary depending on negative offsets and various other conditions.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants