slint-ui/slint · error
platform not set, initialize the testing backend first
Error message
platform not set, initialize the testing backend first
What it means
Error "platform not set, initialize the testing backend first" thrown in slint-ui/slint.
Source
Thrown at internal/backends/testing/lib.rs:113
|ctx| ctx.set_accent_color(color),
)
.unwrap();
}
/// Replace the font collection with embedded NotoSans fonts for deterministic test results.
/// Must be called after initializing the testing backend (e.g. after [`init_no_event_loop()`]).
#[cfg(feature = "internal")]
pub fn configure_test_fonts() {
use i_slint_common::sharedfontique::{FALLBACK_FAMILIES, fontique};
use include_dir::{Dir, include_dir};
static FONTS_DIR: Dir = include_dir!("$CARGO_MANIFEST_DIR/../../../tests/screenshots/fonts");
// Pin the primary by name so its position in the fallback chain doesn't depend on
// filesystem iteration order. NotoSans-Regular wins as the default upright face.
const PRIMARY: &str = "NotoSans-Regular.ttf";
i_slint_core::with_global_context(
|| panic!("platform not set, initialize the testing backend first"),
|ctx| {
let mut font_context = ctx.font_context().borrow_mut();
font_context.collection = fontique::Collection::new(fontique::CollectionOptions {
shared: true,
system_fonts: false,
});
font_context.source_cache = fontique::SourceCache::new_shared();
font_context.clear_registered_static_fonts();
let primary =
FONTS_DIR.get_file(PRIMARY).expect("primary test font missing from fonts dir");
let mut fallback_files: Vec<_> = FONTS_DIR
.files()
.filter(|f| f.path().extension().is_some_and(|ext| ext == "ttf"))
.filter(|f| f.path().file_name().and_then(|n| n.to_str()) != Some(PRIMARY))
.collect();
// Sort fallbacks lexicographically so the chain is reproducible across platforms.
fallback_files.sort_by_key(|f| f.path().to_owned());View on GitHub (pinned to 3fd8f2ec03)
Solutions
- Initialize the testing backend with init_integration_test_with_system_testing_service or init_no_mock before this call.
- Check the test setup ordering.
When it happens
Trigger: Thrown at internal/backends/testing/lib.rs:113 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of slint-ui/slint@3fd8f2ec03 (2026-08-19).
Data as JSON: /api/errors/101cbc0c92c23125.
Report an issue: GitHub.