Skip to content
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: Odd text alignment with space characters #3092

Open
jturcotte opened this issue Jul 15, 2023 · 4 comments
Open

Skia: Odd text alignment with space characters #3092

jturcotte opened this issue Jul 15, 2023 · 4 comments
Labels
a:renderer-skia Skia Renderer (mS) a:text Text rendering, fonts, Text input (mS,bF) bug Something isn't working upstream Needs a fix upstream

Comments

@jturcotte
Copy link
Contributor

jturcotte commented Jul 15, 2023

export component MainWindow inherits Window {
    background: lightgreen;
    VerticalLayout {
        width: 50%;
        // 1. Reference
        Text {
            font-family: "monospace";
            font-size: 28px;
            text: "[---]";
            horizontal-alignment: center;
            vertical-alignment: center;
        }
        // 2. This works, OK
        Text {
            font-family: "monospace";
            font-size: 28px;
            text: "---";
            horizontal-alignment: center;
            vertical-alignment: center;
        }
        // 3. This aligns, but it shouldn't
        Text {
            font-family: "monospace";
            font-size: 28px;
            text: "--- ";
            horizontal-alignment: center;
            vertical-alignment: center;
        }
        // 4. This shouldn't align either, but the text oddly aligns with the last element
        Text {
            font-family: "monospace";
            font-size: 28px;
            text: " ---";
            horizontal-alignment: center;
            vertical-alignment: center;
        }
        // 5. This is the issue, this should be aligned with the reference at the top
        Text {
            font-family: "monospace";
            font-size: 28px;
            text: " --- ";
            horizontal-alignment: center;
            vertical-alignment: center;
        }
    }
}

This is what renderer-winit-skia gives me, the last text's "---" should be aligned with the top one:
image

renderer-winit-femtovg gives me the expected alignment:
image

I don't think it's high severity, but the two "shouldn't align" cases 3 and 4 makes me think that it could be a simple fix if the issue were due to something like wrong spaces trimming somewhere.

Since slint-viewer doesn't seem to be built with the skia backend, here is a runnable example: https://gist.github.com/jturcotte/4d7e4011135fdddd22df123d884443c6

@ogoffart ogoffart added bug Something isn't working a:renderer-skia Skia Renderer (mS) labels Jul 15, 2023
@tronical
Copy link
Member

It looks like this is an issue that was accepted upstream: https://bugs.chromium.org/p/skia/issues/detail?id=11933

Interestingly this was also referenced from flutter: flutter/flutter#40648

@tronical
Copy link
Member

I don't see an easy way of working around this using the API we're using right now. But perhaps this is one thing we can fix more easily with cosmic text if we switch to it.

@jturcotte
Copy link
Contributor Author

Oh ok, fixing upstream isn’t what I’d qualify as an easy fix. I’d also be ok with a “won’t fix” as this isn’t your bug.

@tronical
Copy link
Member

I'm inclined to leave this ticket open to ensure that we test that this will be fixed with cosmic-text and add a test using the screenshots driver.

@ogoffart ogoffart added a:text Text rendering, fonts, Text input (mS,bF) upstream Needs a fix upstream and removed cosmic-text labels Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:renderer-skia Skia Renderer (mS) a:text Text rendering, fonts, Text input (mS,bF) bug Something isn't working upstream Needs a fix upstream
Projects
None yet
Development

No branches or pull requests

3 participants