-
Notifications
You must be signed in to change notification settings - Fork 818
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
Fix UiFlags::KerningFitSpacing #7705
base: master
Are you sure you want to change the base?
Conversation
In
Also, |
I pushed a commit to move the fix directly into |
? AdjustSpacingToFitHorizontally(lineWidth, opts.spacing, charactersInLine, rect.size.width) | ||
: opts.spacing; | ||
int curSpacing = opts.spacing; | ||
if (HasAnyOf(opts.flags, UiFlags::KerningFitSpacing)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is very similar code in DrawStringWithColors
that also needs to be adjusted in the same way (search the file for int curSpacing = HasAnyOf
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When using
UiFlags::KerningFitSpacing
, the text alignment was computed using unadjusted spacing. Later, during drawing, the spacing was reduced to "squish" the text so it fits inside its rect. This mismatch caused the final drawn text to be narrower than expected, resulting in left-shifted text that would have been word-wrapped without the use ofUiFlags::KerningFitSpacing
.We now compute the adjusted spacing before calculating the starting X coordinate for text. The changes are as follows:
AdjustSpacingToFitHorizontally
to determine the new spacing that ensures the text fits within the available width.GetLineStartX
) based on this new width.