Expand description
This crate serves as a companion crate of the slint crate.
It is meant to allow you to compile the .slint files from your build.rs script.
The main entry point of this crate is the compile() function
The generated code must be included in your crate by using the slint::include_modules!() macro.
§Example
In your Cargo.toml:
[package]
...
build = "build.rs"
[dependencies]
slint = "1.16.0"
...
[build-dependencies]
slint-build = "1.16.0"In the build.rs file:
ⓘ
fn main() {
slint_build::compile("ui/hello.slint").unwrap();
}Then in your main file
ⓘ
slint::include_modules!();
fn main() {
HelloWorld::new().run();
}§Feature flags
compat-1-18(enabled by default) — Mandatory feature: This feature is required to keep the compatibility with Slint 1.18. Newer patch versions may put current functionality behind a new feature that would be enabled by default only if this feature was added. More info in this blog postrenderer-software(enabled by default) — Embed images and fonts in a format optimized for the software renderer. Enables theEmbedResourcesKind::EmbedForSoftwareRenderervariant.image-default-formats— Support additional image formats when embedding images for therenderer-softwarefeature. Without this feature, only PNG and JPEG are supported. Not enabled by default: most projects embed a.slintUI’s own PNG/JPEG assets, and this feature’s decoder dependencies are only reachable whenCompilerConfiguration::embed_resourcesis set toEmbedForSoftwareRenderer.sdf-fonts— Enable theCompilerConfiguration::with_sdf_fontsfunction that encodes the fonts embedded for the software renderer as scalable signed distance fields, to reduce their size.
Structs§
- Compiler
Configuration - The structure for configuring aspects of the compilation of
.slintmarkup files to Rust.
Enums§
- Compile
Error - Error returned by the
compilefunction - Default
Translation Context - Argument of
CompilerConfiguration::with_default_translation_context() - Embed
Resources Kind - How should the Slint compiler embed images and fonts
Functions§
- compile
- Compile the
.slintfile and generate rust code for it. - compile_
with_ config - Same as
compile, but allow to specify a configuration. - compile_
with_ output_ path - Similar to
compile_with_config, but meant to be used independently of cargo. - print_
rustc_ flags - This function is for use the application’s build script, in order to print any device specific build flags reported by the backend