Repository navigation
Fix text wrapping due to sub-pixel floating-point differences - #26323
unclepomedev wants to merge 3 commits into
Conversation
There was a problem hiding this comment.
This confused me for a bit, because I can remember fixing it before. It must have been broken again by the changes adding padding and borders support for content nodes.
The fix is fine, maybe it's too cautious even and possibly we just should ceil all the bounds.
I'd like to have a higher level regression test that produces a text layout, similar to the issue's replication example, but that's a bit more complicated to setup, it could be left to a follow up PR.
alice-i-cecile
left a comment
There was a problem hiding this comment.
This fix appears to work, but I'd prefer:
possibly we just should ceil all the bounds
I think that's both simpler and more robust. Just gotta make sure that measuring and drawing work the same way throughout.
@unclepomedev are you okay to tackle that in this PR, or would you rather we merge an incremental fix?
alice-i-cecile
left a comment
There was a problem hiding this comment.
Sorry, meant to leave a neutral review!
|
Switched to Re-ran the probe from the PR description (7 paddings × 9 font sizes, padding on the parent, centered column): 2 combinations wrapped on main, 0 now, at both 5/6 and 2/3. The earlier ULP-snap gave the same result, so this is simpler with no loss. |
|
I'll try to add the higher-level regression test in a follow-up PR, as ickshonpe suggested. |
|
While checking that measuring and drawing round the same way, I found that the repro from #26305 still wraps in the glyph layout when I filed #26351 and opened #26352 (draft), which rounds up the width used for the text bounds in |
Objective
fixes #26305
Single-line text in an auto-width node with horizontal padding wraps at some fractional
UiScalevalues (e.g. 5/6, 2/3), even though the line fits.Solution
Snap the width used for line breaking to the max-content width when it is within
max_content * f32::EPSILON * 8of it. The 8 is arbitrary, just a few ULPs of room.The layout width is still 119.99999. This only stops line breaking from treating that as too narrow for text that needs 120.
Testing
AI Disclosure