Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Font offset not calculated correctly when using fonts. #276

Closed
rosenhauer opened this issue Jan 5, 2023 · 5 comments
Closed

Font offset not calculated correctly when using fonts. #276

rosenhauer opened this issue Jan 5, 2023 · 5 comments
Assignees
Labels
Milestone

Comments

@rosenhauer
Copy link

rosenhauer commented Jan 5, 2023

When using non built in fonts (tested with Adafruit fonts) the offset is incorrectly calculated.

In tcAdaFruitGfx.cpp internalTextExtents function the line:
bl = glyphHeight + pgm_read_byte(&allGlyphs[glIdx].yOffset);
should be
bl = glyphHeight + (signed char)pgm_read_byte(&allGlyphs[glIdx].yOffset);
so that negative offsets are calculated correctly. But this still just uses the offset of the last character tested - the left parentheses.

or preferably it can be changed by eliminating the bl calculation and replacing

if(baseline) *baseline = bl;
with
if(baseline) *baseline = font->yAdvance - height;

This uses the line spacing for the font minus the tallest character.

This is using Arduino 1.8.16 to compile.

@davetcc davetcc self-assigned this Jan 8, 2023
@davetcc davetcc added the enhancement New feature or request label Jan 8, 2023
@davetcc davetcc added this to the 3.1.0 milestone Jan 8, 2023
@davetcc
Copy link
Owner

davetcc commented Jan 8, 2023

Thanks for pointing this out, I'll look at this and try it out for both tcUnicode and native fonts. They both use the same calculation. I have a graphical example that shows this and can try it out.

@davetcc
Copy link
Owner

davetcc commented Jan 24, 2023

Many thanks, this somehow escaped through testing, I have fixed this as per your suggestion and it will be in 3.1 which is due very soon.

@davetcc davetcc added workaround-available bug Something isn't working critical and removed enhancement New feature or request labels Jan 24, 2023
@davetcc
Copy link
Owner

davetcc commented Jan 24, 2023

I had not understood how serious this was, or I would have removed the touch change from 3.1 and released it earlier. As it is now 3.1 is probably a few days from release so it will go into that.

@davetcc
Copy link
Owner

davetcc commented Jan 24, 2023

@rosenhauer
Copy link
Author

rosenhauer commented Jan 24, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants