slint-ui / slint

Slint is a declarative GUI toolkit to build native user interfaces for Rust, C++, or JavaScript apps.
https://slint.dev
Other
17.68k stars 612 forks source link

Skia: word-wrap and elide doesn't work #5318

Open frankalex92 opened 6 months ago

frankalex92 commented 6 months ago

It seems that the property "wrap: word-wrap" does not function as intendet when using winit-skia.

I am using 1.6.0 and have features renderer-skia-opengl and gettext set.

The string wraps at the boundaries of my Text-Component as intended: image (2)

But when setting the env-var: export SLINT_BACKEND='winit-skia' and starting again it won't: image (1)

I am using the gettext function for translations, but I checked and this is also happening when i put the long string directly into my Text-Component, so shouldn't be connected to the translations.

Here are all the properties set: WhatsApp Image 2024-05-29 at 15 55 20

I have overflow:elide and wrap:word-wrap set together, maybe that's causing problems, altough without skia works nicely, wraps at line end and overflows on vertical space: WhatsApp Image 2024-05-29 at 15 57 34

BR

ogoffart commented 5 months ago

I can reproduce.

Testcase:

export component StatusBox inherits Window  {
    preferred-width: 100px;   preferred-height: 100px;
    min-height: 64px;   min-width: 64px;

    Rectangle {
         height: 100%;
         width: 100%;

         Text {
             text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.";
             height: 100%;
             width: 100%;
             wrap: word-wrap;
             overflow: TextOverflow.elide;
         }
     }
 }

image

Note that some work has already be done since issue #3481 but there is still many inconsistencies between renderer. One small issue with the software renderer is tracked in #3695 , but this issue with skia seems more problematic.