-
Notifications
You must be signed in to change notification settings - Fork 18
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 height is not computed correctly -- too short #19
Comments
Hi @MikeyMoMo I will try to verify this issue in my environment, so please tell me the smallest code and font you are using that can reproduce the problem. Thank you. |
I have changed my mind about what the problem is, now. It seems like the real problem is that there is blank pixels above the top of the font. I had noticed this before but, with the attached program, you can see that I am drawing a rectangle around the text using the returns from text width and height calls and it is low in the box with blank space at the top and the descenders are hanging out of the box. So, maybe the real problem is that blank space at the top. It gets larger as the font size gets larger and more of the letters hang outside the box, even those without descenders. I hope this helps you decide where the problem is. Thanks for the library. I am making extensive use of it in a large project I have. But I did have to adjust the cursor setting to account for the blank lines at the top of the characters. I will be very glad to fix my program when you find out what is happening here. If I can be of any more help, please let me know. The following is a modification of one of your examples. To make it complete, you will need to add in the NotoSans.h tab, of course. I draw the rectangle before the text to see the left/right alignment and it is to-the-pixel perfect. The top of the A and y just take out one pixel of the red box. So it seems to boil down to the blank area above the top of the rendered font. It does happen on the other fonts I am using in my project, not just NotoSans. I am using BritanicBold from sizes 32 to 80 and an LCD font at size 190. Thanks,
|
I found that the font height was being calculated to a lower value than it should so I created a test string with the largest caps and two descenders and, still, it is coming up with too low of a number.
The font is being loaded with
The display is being updated with
ofr.setCursor(dispWidth / 2, yPos); ofr.cprintf(myBuildString.c_str());
I calculate the size with one of these two (both return too small of a size)
They both return 42. Adding 8 makes it match the setFontSize parm. Maybe I should just use this. I don't know if it tracks to the larger sizes I am using... But the rest are numbers so it does not matter for now.
Then I do a fill rect with this
tft.fillRect(0, yPos, dispWidth, ofrFontHeight, SkyBlue); // dispWidth is the full 480 pixels.
Either way, it does not blank out the descenders with the initially returned value since it is calculating the height to a lower number than it should. It makes WiFi look like WjFi because there was a descender right under where the first i is in the previous status message.
When I added 5 to the height, it almost cleaned it all with fillRect. When I added 8, it was totally clean. I am using it on numbers, too, but, since there are no descenders, it does not show the problem.
Thanks for the library. I am enjoying using it. Sorry to report so much but there are some minor problems around the edges. It's expected with a new contribution.
Mike
The text was updated successfully, but these errors were encountered: