Skip to content

Instantly share code, notes, and snippets.

@jturcotte
Last active July 15, 2023 11:04
Show Gist options
  • Save jturcotte/4d7e4011135fdddd22df123d884443c6 to your computer and use it in GitHub Desktop.
Save jturcotte/4d7e4011135fdddd22df123d884443c6 to your computer and use it in GitHub Desktop.
[package]
name = "skia-text-align"
version = "0.1.0"
edition = "2021"
[[bin]]
name = "skia-text-align"
path = "main.rs"
[dependencies.slint]
version = "1.1.1"
default-features = false
# Switch to renderer-winit-femtovg to see the expected results
features = ["compat-1-0", "backend-winit", "renderer-winit-skia"]
fn main() {
MainWindow::new().unwrap().run().unwrap();
}
slint::slint! {
export component MainWindow inherits Window {
background: lightgreen;
VerticalLayout {
width: 50%;
// Reference
Text {
font-family: "monospace";
font-size: 28px;
text: "[---]";
horizontal-alignment: center;
vertical-alignment: center;
}
// This works, OK
Text {
font-family: "monospace";
font-size: 28px;
text: "---";
horizontal-alignment: center;
vertical-alignment: center;
}
// This aligns, but it shouldn't
Text {
font-family: "monospace";
font-size: 28px;
text: "--- ";
horizontal-alignment: center;
vertical-alignment: center;
}
// 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;
}
// 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;
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment