zed-industries/zed · error

Could not load an embedded font.

Error message

Could not load an embedded font.

What it means

Guard in MacTextSystemState::add_fonts: registering one of the embedded (bundled) font data providers with CoreText failed. It fires at text-system startup when a built-in font buffer cannot be loaded — corrupted embedded font data or a CoreText registration error — so text rendering cannot be initialized.

Source

Thrown at crates/gpui_macos/src/text_system.rs:265

        let Some(number) = value.downcast_into::<CFNumber>() else {
            return true;
        };
        // Only an explicit value of `0` means that font smoothing is disabled.
        number.to_i64() != Some(0)
    })
}

impl MacTextSystemState {
    fn add_fonts(&mut self, fonts: Vec<Cow<'static, [u8]>>) -> Result<()> {
        let fonts = fonts
            .into_iter()
            .map(|bytes| match bytes {
                Cow::Borrowed(embedded_font) => {
                    let data_provider = unsafe {
                        core_graphics::data_provider::CGDataProvider::from_slice(embedded_font)
                    };
                    let font = core_graphics::font::CGFont::from_data_provider(data_provider)
                        .map_err(|()| anyhow!("Could not load an embedded font."))?;
                    let font = font_kit::loaders::core_text::Font::from_core_graphics_font(font);
                    Ok(Handle::from_native(&font))
                }
                Cow::Owned(bytes) => Ok(Handle::from_memory(Arc::new(bytes), 0)),
            })
            .collect::<Result<Vec<_>>>()?;
        self.memory_source.add_fonts(fonts.into_iter())?;
        Ok(())
    }

    fn load_family(
        &mut self,
        name: &str,
        features: &FontFeatures,
        fallbacks: Option<&FontFallbacks>,
    ) -> Result<SmallVec<[FontId; 4]>> {
        let name = gpui::font_name_with_fallbacks(name, ".AppleSystemUIFont");

View on GitHub (pinned to f4178619ac)

Solutions

  1. Verify embedded font bytes are valid TTF/OTF (they can be truncated by build/packaging steps)
  2. Check the CGDataProvider construction path for the failing font and log which one it is
  3. Treat as fatal: a text system without its bundled fonts cannot render, so abort startup with the error
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/gpui_macos/src/text_system.rs:265 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/4e94d863020620c8. Report an issue: GitHub.