{"record":{"id":"101cbc0c92c23125","repo":"slint-ui/slint","slug":"platform-not-set-initialize-the-testing-backend-f","errorCode":null,"errorMessage":"platform not set, initialize the testing backend first","messagePattern":"platform not set, initialize the testing backend first","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/backends/testing/lib.rs","lineNumber":118,"sourceCode":"/// Replace the font collection with embedded NotoSans fonts for deterministic test results.\n/// Must be called after initializing the testing backend (e.g. after [`init_no_event_loop()`]).\n#[cfg(feature = \"internal\")]\npub fn configure_test_fonts() {\n    use i_slint_common::sharedfontique::{FALLBACK_FAMILIES, fontique};\n\n    // Listed explicitly, in the order they take in the fallback chain: NotoSans-Regular is\n    // the default upright face and comes first. Embedding the whole directory instead would\n    // make the chain depend on filesystem iteration order, and would pull in whatever else\n    // lives there - the `.license` files, `convert.sh`, and the gitignored upstream fonts\n    // that script downloads into a subdirectory.\n    static FONTS: &[&[u8]] = &[\n        include_bytes!(\"../../../tests/screenshots/fonts/NotoSans-Regular.ttf\"),\n        include_bytes!(\"../../../tests/screenshots/fonts/NotoSans-Italic.ttf\"),\n        include_bytes!(\"../../../tests/screenshots/fonts/NotoSansSymbols2-Regular.ttf\"),\n    ];\n\n    i_slint_core::with_global_context(\n        || panic!(\"platform not set, initialize the testing backend first\"),\n        |ctx| {\n            let mut font_context = ctx.font_context().borrow_mut();\n            font_context.collection = fontique::Collection::new(fontique::CollectionOptions {\n                shared: true,\n                system_fonts: false,\n            });\n            font_context.source_cache = fontique::SourceCache::new_shared();\n            font_context.clear_registered_static_fonts();\n\n            let mut chain_families: Vec<fontique::FamilyId> = Vec::new();\n            for font in FONTS {\n                let fonts = font_context\n                    .collection\n                    .register_fonts(fontique::Blob::new(std::sync::Arc::new(*font)), None);\n                for (family_id, _) in &fonts {\n                    if !chain_families.contains(family_id) {\n                        chain_families.push(*family_id);\n                    }","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/slint-ui/slint/blob/bb937076de3f7919766c1f25e2e969367cf77e9a/internal/backends/testing/lib.rs#L100-L136","documentation":"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.","triggerScenarios":"Thrown at internal/backends/testing/lib.rs:118 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bb937076de3f7919766c1f25e2e969367cf77e9a","analyzedAt":"2026-09-16T01:37:20.251Z","contentChangedAt":"2026-09-16T01:37:20.251Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}