You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks for raising this issue. You're correct that Processing's vertical alignment may not center text perfectly due to the way it handles characters that extend above or below the baseline.
A potential workaround involves calculating the full height of the text, including both ascent and descent, and adjusting the y-position accordingly. However, this method is not ideal as the ascent and descent are based on the tallest and deepest characters (d and p), which may not represent the actual height of your specific string.
A more accurate workaround to get the exact string height involves generating a vector representation for each character, identifying the vertices with the highest and lowest Y positions.
I would recommend taking a look at this excellent StackOverflow post by @micycle. It provides a detailed explanation on this matter and presents potential solutions.
In GitLab by @ThexXTURBOXx on Jul 5, 2023, 20:24
Description
textAlign(CENTER, CENTER)
does not center text vertically correctlyExpected Behavior
After
textAlign(CENTER, CENTER)
, text should be aligned in the center.Current Behavior
The text is not centered vertically:
Steps to Reproduce
Your Environment
4.2
Windows 11 22621.1928
Possible Causes / Solutions
The issue lies most likely somewhere within these lines: https://github.com/processing/processing4/blob/main/core/src/processing/core/PGraphics.java#L4920-L4926
But I am not sure
The text was updated successfully, but these errors were encountered: