-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Make sure GlyphRunImpl.InkBounds are always at a positive location #16601
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
Make sure GlyphRunImpl.InkBounds are always at a positive location #16601
Conversation
You can test this PR using the following package version. |
Just a though, aren't the negative bounds returned because of the edging? Avalonia/src/Skia/Avalonia.Skia/GlyphRunImpl.cs Lines 54 to 58 in d1cdb29
This comment says that the result could be shifted by 1px, but it could also probably be -1px depending on the font. Since that negative bound might apply to several other characters in the run and not only the first, won't shifting the bounds of the whole run potentially cause other problems, for example with hit testing? Also, should we add a render test here to avoid future regressions? |
Y sounds like we need a render test |
So ideally glyph bounds should never affect layout. So each glyphs anchor point should be adjusted to the expected glyph advances. In the end this should only matter for the first glyph's bounds because these define the left edge of a run. |
You can test this PR using the following package version. |
You can test this PR using the following package version. |
…r the OverhangLeading Add tests for OverhangLeading and OverhangTrailing
* Fix issue with MinTextWidth (Fixes #18372) * Make sure that MeasureOverride for TextPresenter and TextBlock are using same textWidth * Revert #16601 that is introducing an invalid calculation for the OverhangLeading Add tests for OverhangLeading and OverhangTrailing * Revert MinTextWidth * Fix tests to not rely on fixed values * Fix remaining issues * Fix comment in Direct2D1 GlyphRunImpl.cs * Fix Direct2D1 rendering * Fix gold images * Restore TextLineImpl * Update gold image * Restore Math.Max on OverhangLeading and Trailing * Adopt similar behavior to WPF: don't use OverhangLeading/Trailing for measuring and remove clip by default. But it requires further support with NeedsClipBounds * Remove MinTextWidth Keep ClipToBounds=true default for TextBlock * Revert change --------- Co-authored-by: Benedikt Stebner <[email protected]>
* Fix issue with MinTextWidth (Fixes #18372) * Make sure that MeasureOverride for TextPresenter and TextBlock are using same textWidth * Revert #16601 that is introducing an invalid calculation for the OverhangLeading Add tests for OverhangLeading and OverhangTrailing * Revert MinTextWidth * Fix tests to not rely on fixed values * Fix remaining issues * Fix comment in Direct2D1 GlyphRunImpl.cs * Fix Direct2D1 rendering * Fix gold images * Restore TextLineImpl * Update gold image * Restore Math.Max on OverhangLeading and Trailing * Adopt similar behavior to WPF: don't use OverhangLeading/Trailing for measuring and remove clip by default. But it requires further support with NeedsClipBounds * Remove MinTextWidth Keep ClipToBounds=true default for TextBlock * Revert change --------- Co-authored-by: Benedikt Stebner <[email protected]> #Conflicts: # src/Avalonia.Controls/TextBlock.cs # tests/Avalonia.Controls.UnitTests/TextBlockTests.cs
* Fix issue with MinTextWidth (Fixes #18372) * Make sure that MeasureOverride for TextPresenter and TextBlock are using same textWidth * Revert #16601 that is introducing an invalid calculation for the OverhangLeading Add tests for OverhangLeading and OverhangTrailing * Revert MinTextWidth * Fix tests to not rely on fixed values * Fix remaining issues * Fix comment in Direct2D1 GlyphRunImpl.cs * Fix Direct2D1 rendering * Fix gold images * Restore TextLineImpl * Update gold image * Restore Math.Max on OverhangLeading and Trailing * Adopt similar behavior to WPF: don't use OverhangLeading/Trailing for measuring and remove clip by default. But it requires further support with NeedsClipBounds * Remove MinTextWidth Keep ClipToBounds=true default for TextBlock * Revert change --------- Co-authored-by: Benedikt Stebner <[email protected]>
What does the pull request do?
For an unknown reason, Skia reports glyph bounds at a negative x-position which causes some alignment issues for monospace fonts. This PR makes sure glyph bounds are always at a positive position.
What is the current behavior?
What is the updated/expected behavior with this PR?
How was the solution implemented (if it's not obvious)?
Checklist
Breaking changes
Obsoletions / Deprecations
Fixed issues
Fixes: #16555