Skip to content

Fix text bounds cutoff in iced_wgpu#2975

Merged
hecrj merged 2 commits intoiced-rs:masterfrom
DKolter:issue_2963
Jun 3, 2025
Merged

Fix text bounds cutoff in iced_wgpu#2975
hecrj merged 2 commits intoiced-rs:masterfrom
DKolter:issue_2963

Conversation

@DKolter
Copy link
Contributor

@DKolter DKolter commented Jun 1, 2025

Fixes #2963

The current wgpu text bounds implementation casts the right and bottom bound to an integer without rounding, leading to letters not being displayed fully.

In this example there is a combo box on the left with a 0.2px vertical space and an input box on the right without a vertical space. The default font size is 16px, leading to a default line height of 1.3 * 16px = 20.8px. With a 0.2px vertical space the bottom bound equals to a whole integer coordinate, so the letters are displayed correctly. On the right the bound is cast from 20.8px to 20px, loosing almost a pixel of all letters extending to the bottom line:

Bildschirmfoto vom 2025-06-01 12-41-32

This PR matches the line bound calculation of tinyskia and rounds the text bounds:

grafik

@hecrj
Copy link
Member

hecrj commented Jun 2, 2025

Is this fixed by #2768?

@edwloef
Copy link
Contributor

edwloef commented Jun 2, 2025

No, however the result is a similar kind of snapping, the only difference being the top left point being truncated instead of rounded. Maybe that could be done here as well, though I can hardly say whether it'll be an issue in this case.

This needs a cryoglyph rectangle, which has signed coordinates (for some reason) so the existing snap fn wasn't used before or now.

Copy link
Member

@hecrj hecrj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@hecrj hecrj changed the title fix: Wgpu text bounds cutoff Fix text bounds cutoff in iced_wgpu Jun 3, 2025
@hecrj hecrj enabled auto-merge June 3, 2025 10:23
@hecrj hecrj added bug Something isn't working rendering wgpu fix labels Jun 3, 2025
@hecrj hecrj added this to the 0.14 milestone Jun 3, 2025
@hecrj hecrj merged commit c9cfd6f into iced-rs:master Jun 3, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working fix rendering wgpu

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cut-off placeholder in combo box

3 participants