-
Notifications
You must be signed in to change notification settings - Fork 627
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
Skia: wrap: no-wrap
(the default) still wraps
#7080
Comments
Maybe related: #5318 I've tried fixing this by changing line slint/internal/renderers/skia/textlayout.rs Line 163 in 356376d
to paragraph.layout(
max_width
.filter(|_| wrap != items::TextWrap::NoWrap && overflow != items::TextOverflow::Elide)
.map_or(f32::MAX, |physical_width| physical_width.get()),
); Which kind of works but then it draws outside of the bounds, and I'm afraid that would break the alignment as well. |
Yes indeed, |
think drawing outside of the bounds is okay - at last I think we should also do that in the other renderers. I suspect that we may have to layout twice, like this: diff --git a/internal/renderers/skia/textlayout.rs b/internal/renderers/skia/textlayout.rs
index ce107286f..cf5d2065a 100644
--- a/internal/renderers/skia/textlayout.rs
+++ b/internal/renderers/skia/textlayout.rs
@@ -162,6 +162,16 @@ pub fn create_layout(
let mut paragraph = builder.build();
paragraph.layout(max_width.map_or(f32::MAX, |physical_width| physical_width.get()));
+ // If without line breaking the text would be longer than the given max_width, lay out again
+ // without line breaks.
+ if wrap == items::TextWrap::NoWrap || overflow == items::TextOverflow::Elide {
+ if let Some(physical_width) = max_width {
+ if paragraph.max_intrinsic_width() > physical_width.get() {
+ paragraph.layout(f32::MAX);
+ }
+ }
+ }
+
let layout_height = PhysicalLength::new(paragraph.height());
let layout_top_y = match v_align { |
I also observed this behavior recently. What I found is although the text is wrapped with default |
Bug Description
Skia is different than every other renderer with respect to wrapping: it always wrap while the other renderer don't wrap by default.
In the above example, the text is being wrap with skia and only skia.
Reproducible Code (if applicable)
Environment Details
Product Impact
No response
The text was updated successfully, but these errors were encountered: