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

[WIP]Fix overhang leading calculation for negative values #13672

Merged
merged 4 commits into from
Nov 22, 2023

Conversation

Gillibald
Copy link
Contributor

What does the pull request do?

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: #13671

@MrJul
Copy link
Member

MrJul commented Nov 20, 2023

I don't think I understand the fix, why isn't it Max(0, bounds.Left)?
If you can spare a few minutes to explain I'd be grateful :)

I assume we don't have tests for this part? This seems easy to accidentally break in the future.

(Edit: may or not be related but recent test TextLineTests.Should_GetPreviousCharacterHit_Non_Trailing doesn't have any assert)

@Gillibald
Copy link
Contributor Author

Gillibald commented Nov 21, 2023

Glyph bounds are produced by the current raster backend. For Windows this is DirectWrite for macOS this is CoreText etc.

So glyph bounds might be calculated differently. In the end, we want to know the overhanging black pixels at the left, right, and bottom edges of the regular bounding box.

OverhangLeading is defined as a positive value. It is used to translate rendered text on the x-axis so nothing gets clipped.

We should definitely add a unit test that covers this but writing a test for this involves a custom backend so we get identical glyph bounds on all platforms. We can't write a test that is using Skia.

The mentioned unit tests need to be fixed but are unrelated.

@Gillibald Gillibald changed the title [macOS] Fix overhang leading calculation [WIP]Fix overhang leading calculation for negative values Nov 21, 2023
@maxkatz6 maxkatz6 added this pull request to the merge queue Nov 21, 2023
Merged via the queue into AvaloniaUI:master with commit b94b011 Nov 22, 2023
5 of 6 checks passed
@maxkatz6 maxkatz6 added the backport-candidate-11.0.x Consider this PR for backporting to 11.0 branch label Nov 28, 2023
maxkatz6 pushed a commit that referenced this pull request Dec 5, 2023
* [macOS] Fix overhand leading calculation

* Adjust TextLineMetrics

* Update expected result
@maxkatz6 maxkatz6 added backported-11.0.x and removed backport-candidate-11.0.x Consider this PR for backporting to 11.0 branch labels Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clipped Text in TextBlock (Nightly Build)
3 participants