Fix new TextMeasurer Bounds calculations so origin is absolute.#507
Merged
JimBobSquarePants merged 3 commits intomainfrom Mar 9, 2026
Merged
Fix new TextMeasurer Bounds calculations so origin is absolute.#507JimBobSquarePants merged 3 commits intomainfrom
JimBobSquarePants merged 3 commits intomainfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #507 +/- ##
=====================================
- Coverage 83% 83% -1%
=====================================
Files 274 274
Lines 19167 19169 +2
Branches 2714 2714
=====================================
+ Hits 16048 16049 +1
- Misses 2441 2442 +1
Partials 678 678
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Prerequisites
Description
This pull request enhances the documentation and correctness of text measurement methods in
TextMeasurer.cs, clarifying the distinction between logical advance and rendered glyph bounds, and ensuring absolute coordinates are used for layout calculations. It also updates the implementation to properly union the logical advance with the rendered bounds, and improves per-character measurement accuracy. The test utility is updated to reflect these changes.Documentation improvements:
TextMeasurer.cs, explaining the differences between logical advance, ink bounds, and renderable bounds, and referencing related methods for clarity. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]Measurement logic corrections:
MeasureRenderableBounds(ReadOnlySpan<char>, TextOptions)to union the absolute advance rectangle (with origin) with the rendered bounds, ensuring the returned rectangle is in absolute coordinates and contains both logical and ink bounds.TryGetCharacterRenderableBoundsto use absolute advance rectangles and union them with glyph ink bounds, improving accuracy for layout and rendering.Test utility update:
TestLayoutinTextLayoutTestUtilities.csto calculate width and height using the new measurement logic, ensuring the test reflects the updated bounding box calculation.