Skip to content
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

Merged
merged 2 commits into from
Dec 7, 2024

Conversation

kjarosh
Copy link
Member

@kjarosh kjarosh commented Dec 3, 2024

getCharBoundaries() should report stretched space width, not the original space width.

@kjarosh kjarosh added text Issues relating to text rendering/input A-core Area: Core player, where no other category fits T-fix Type: Bug fix (in something that's supposed to work already) labels Dec 3, 2024
@kjarosh kjarosh force-pushed the getcharboundaries-justify branch from 1032caf to f10765d Compare December 3, 2024 23:16
// 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 {
Copy link
Collaborator

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.

Copy link
Member Author

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

@kjarosh kjarosh force-pushed the getcharboundaries-justify branch from f10765d to 7986f6c Compare December 4, 2024 22:48
@torokati44 torokati44 force-pushed the getcharboundaries-justify branch from 7986f6c to 7ed45fe Compare December 5, 2024 16:06
@danielhjacobs danielhjacobs added the waiting-on-review Waiting on review from a Ruffle team member label Dec 6, 2024
getCharBoundaries() should report stretched space width, not the
original space width.
Cover the case of getCharBoundaries() when the text is justified.
@Dinnerbone Dinnerbone force-pushed the getcharboundaries-justify branch from 7ed45fe to 427c20e Compare December 7, 2024 18:48
@Dinnerbone Dinnerbone enabled auto-merge (rebase) December 7, 2024 18:48
@Dinnerbone Dinnerbone merged commit 423ef7e into ruffle-rs:master Dec 7, 2024
22 checks passed
@kjarosh kjarosh deleted the getcharboundaries-justify branch December 7, 2024 19:04
@kjarosh kjarosh removed the waiting-on-review Waiting on review from a Ruffle team member label Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core player, where no other category fits T-fix Type: Bug fix (in something that's supposed to work already) text Issues relating to text rendering/input
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants