slint icon indicating copy to clipboard operation
slint copied to clipboard

Provide a test case for text elision and letter spacing

Open tronical opened this issue 2 years ago • 9 comments
trafficstars

Along with this test case comes a change to the font selection in the software renderer to always prefer embedded bitmap fonts. This way when running cargo test -p test-driver-screenshots the pixel fonts are used (as before this patch) as well as in the CI, when all features are enabled (including "systemfonts").

tronical avatar Jan 27 '23 13:01 tronical

Note that PR #2134 clipping stuff is already covered by #2139 (it failed when the 2134 was not there)

This at least test a bunch of other properties like elide and letter-spacing and some other alignment. (but it would be nice if the text elision was visible)

ogoffart avatar Jan 27 '23 13:01 ogoffart

Ahh, good point. Shall I simplify the test case to not do clipping but show elision and letter spacing?

tronical avatar Jan 27 '23 13:01 tronical

Suggestion for test case that test elision and an added letter spacing. I'd prefer a positive value for the letter spacing, because I think that's more realistic choice for real-life use of the property.

export component TestCase inherits Window {
    width: 64px;
    height: 64px;

    Text {
        text: "Elide me please for I am a very long paragraph";
        wrap: word-wrap;
        overflow: elide;
        font-size: 10px;
        height: 40px;
        width: 100%;
        letter-spacing: 3px;
    }
}

Link in online editor.

tronical avatar Jan 27 '23 14:01 tronical

Oh, that's not a good test case in fact, because it shows a bug that the letter spacing ruins the elision :)

tronical avatar Jan 27 '23 14:01 tronical

It works with the software renderer though ;), so a bug in femtovg.

text_features

tronical avatar Jan 27 '23 14:01 tronical

That's a bug :p. The elision should only be applied to the last line when we run out of height and there are still glyphs left to place.

I'm leaning towards a separate PR, but can also combine if you prefer.

tronical avatar Jan 28 '23 08:01 tronical

I'm leaning towards a separate PR, but can also combine if you prefer.

We shouldn't have a test that enforce a bug :-)

But this doesn't have to be fixed now.

ogoffart avatar Jan 30 '23 09:01 ogoffart

Just to be explicit about this change.

  • i think it's important to default to embedded fonts when they are there because that's the only way to test it on desktop.
  • the test itself doesn't hurt much. But also doesn't help much, so that's just 1.8K "wasted" in the history

ogoffart avatar Jan 30 '23 10:01 ogoffart

I agree. Ok, I'll push a change to prefer embedded fonts over system fonts into master directly, and keep this PR for the elision issue.

tronical avatar Jan 30 '23 10:01 tronical