fix bounds and justification calculations to prevent clipping #20449
+285
−33
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does the pull request do?
This pull request fixes clipping of text in TextPresenter and TextBlock.
What is the current behavior?
Text was being clipped by TextPresenter and TextBlock because their measured bounds only considered advance widths, not the actual ink extent of glyphs. This was especially apparent on italic text. After bounds was correct, the right justification calculation had the same issue. Examples of the clipping is illustrated by screenshots in issue #20376
What is the updated/expected behavior with this PR?
The ink should remain within bounds.
How was the solution implemented (if it's not obvious)?
The actual ink extent of glyphs is now used to calculate bounds correctly, and right justification is now adjusted for overhang.
Fixed issues
Fixes #20376