-
Notifications
You must be signed in to change notification settings - Fork 17
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
Vertical centering with a line break #42
Comments
You may be running in to the same thing I'm seeing in #38? What you're doing in code looks correct. |
Note sure it's the same issue directly, but perhaps related in how he calculates the text height? With my example, the single line is centered properly, however I have to set it to bottom alignment for it to look right. Might have just gotten lucky with this particular font size that bottom alignment is centered. If I choose Middle alignment, it ends up too low, which is what you're experiencing. The alignment of top/middle/bottom is not intuitive at all, and I'm not clear on what it's supposed to be aligning to. I just have a feeling the height calculation is being done incorrectly. |
You can see a better visual example of the text alignment stuff with the code in this PR. I suspect you are correct, and there is a minor bug in glyph height calculation. I tried looking at the alignment code but it went over my head pretty quick. |
Yeah, unfortunately I don't know much about how TTF are stored, or much about typesetting. One thing that threw me for a minute when trying to set text centered in a box is when lower case letters were used that had a descender (g, y, q). Not sure if that's related, but when trying to use the Middle alignment it didn't work as I expected it, as the descender was obviously included in the calculation for the height of the character. For example, try aligning in the middle "Start" and "Play" and you'll see two different results because of the lowercase "y". |
I have a function which draws simple large text on the screen, e.g.
`
`
This works great for a single line of text:
But if my "label" has a line break, e.g. \n, the vertical alignment is not correct:
Am I doing this wrong or does the library not support this kind of thing?
The text was updated successfully, but these errors were encountered: