slint-ui/slint · error

slint platform not initialized

Error message

slint platform not initialized

What it means

Error "slint platform not initialized" thrown in slint-ui/slint.

Source

Thrown at api/rs/slint/lib.rs:781

    ///
    /// fn main() {
    ///     // ...
    ///     let downloaded_font: Vec<u8> = todo!("Download https://somewebsite.com/font.ttf");
    ///     let blob = fontique::Blob::new(std::sync::Arc::new(downloaded_font));
    ///     let mut collection = slint::fontique_011::shared_collection();
    ///     let fonts = collection.register_fonts(blob, None);
    ///     collection
    ///         .append_fallbacks(fontique::FallbackKey::new(fontique::Script::from_str_unchecked("Hira"), None), fonts.iter().map(|x| x.0));
    ///     collection
    ///         .append_fallbacks(fontique::FallbackKey::new(fontique::Script::from_str_unchecked("Kana"), None), fonts.iter().map(|x| x.0));
    ///     collection
    ///         .append_fallbacks(fontique::FallbackKey::new(fontique::Script::from_str_unchecked("Hani"), None), fonts.iter().map(|x| x.0));
    ///     // ...
    /// }
    /// ```
    pub fn shared_collection() -> fontique::Collection {
        i_slint_core::with_global_context(
            || panic!("slint platform not initialized"),
            |ctx| ctx.font_context().borrow().collection.clone(),
        )
        .unwrap()
    }
}

View on GitHub (pinned to 3fd8f2ec03)

Solutions

  1. Call slint::platform::set_platform() (or select a backend) before creating components.
  2. Enable a default backend feature so the platform initializes automatically.

When it happens

Trigger: Thrown at api/rs/slint/lib.rs:781 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/542c3ca4eec597a0. Report an issue: GitHub.