-
-
Notifications
You must be signed in to change notification settings - Fork 842
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
text: Fix getCharBoundaries
for justified text
#18851
text: Fix getCharBoundaries
for justified text
#18851
Conversation
1032caf
to
f10765d
Compare
// If we're getting bounds of a space in justified text, | ||
// we have to take into account that the character is stretched, | ||
// and its bounds will end where the next character starts. | ||
if layout_box.end() == position + 1 { |
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.
Just to be sure, can you clarify how if layout_box.end() == position + 1 {
indicates that it's a space? I'm not nitpicking and this isn't blocking, I'm still trying to better wrap my head around the abstractions.
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.
Sure thing!
It doesn't check for a space at all. It just uses the next character's start position as this character's end position when the character is at the end of a box. For non-spaces or non-justified text it just won't change the value.
Now thinking about this, the logic might be different when we take letter spacing or kerning into account, but there are no tests for that yet so we'll see. I'm just trying not to touch every possible aspect I can think of at the same time though 😅
Updated the comment
f10765d
to
7986f6c
Compare
7986f6c
to
7ed45fe
Compare
getCharBoundaries() should report stretched space width, not the original space width.
Cover the case of getCharBoundaries() when the text is justified.
7ed45fe
to
427c20e
Compare
getCharBoundaries()
should report stretched space width, not the original space width.