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
configure_test_fonts replaces the global fontique collection with deterministic embedded NotoSans fonts; this operation requires the testing backend's platform to already be installed. The panic fires when the test calls configure_test_fonts before any init function, meaning the font swap targets a platform that isn't set — an initialization-order bug in the test.
Solutions
- Call one of the testing backend initializers (init_integration_test_with_mock_time, init_no_event_loop) before configure_test_fonts
- Check the 'internal' cargo feature is enabled; the function is cfg-gated to it
- Verify the platform singleton was not claimed by another backend before the testing backend
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at internal/backends/testing/lib.rs:118 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of slint-ui/slint@bb937076de (2026-09-16).
Data as JSON: /api/errors/101cbc0c92c23125.
Report an issue: GitHub.
Appendix: source
Thrown at internal/backends/testing/lib.rs:118
/// 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};
// Listed explicitly, in the order they take in the fallback chain: NotoSans-Regular is
// the default upright face and comes first. Embedding the whole directory instead would
// make the chain depend on filesystem iteration order, and would pull in whatever else
// lives there - the `.license` files, `convert.sh`, and the gitignored upstream fonts
// that script downloads into a subdirectory.
static FONTS: &[&[u8]] = &[
include_bytes!("../../../tests/screenshots/fonts/NotoSans-Regular.ttf"),
include_bytes!("../../../tests/screenshots/fonts/NotoSans-Italic.ttf"),
include_bytes!("../../../tests/screenshots/fonts/NotoSansSymbols2-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 mut chain_families: Vec<fontique::FamilyId> = Vec::new();
for font in FONTS {
let fonts = font_context
.collection
.register_fonts(fontique::Blob::new(std::sync::Arc::new(*font)), None);
for (family_id, _) in &fonts {
if !chain_families.contains(family_id) {
chain_families.push(*family_id);
}View on GitHub (pinned to bb937076de)