bevyengine/bevy · error · TextError

No such font family {0:?}

Error message

No such font family {0:?}

What it means

TextError::NoSuchFontFamily(String) (bevy_text/src/error.rs:12) is returned by ParleyContext::set_generic_family and its wrappers (set_serif_family, set_sans_serif_family, ...) when the given family name is not registered in the font collection (parley_context.rs:72-86). The collection is populated by loaded font assets and — only when the `parley/system` feature is enabled — by discovered system fonts.

Source

Thrown at crates/bevy_text/src/error.rs:12

use thiserror::Error;

#[derive(Debug, PartialEq, Eq, Error)]
/// Errors related to the textsystem
pub enum TextError {
    /// Font was not found, this could be that the font has not yet been loaded, or
    /// that the font failed to load for some other reason
    #[error("font not found")]
    NoSuchFont,
    /// Font was not found, this could be that the font has not yet been loaded, or
    /// that the font failed to load for some other reason
    #[error("No such font family {0:?}")]
    NoSuchFontFamily(String),
    /// Failed to add glyph to a newly created atlas for some reason
    #[error("failed to add glyph to newly-created atlas {0:?}")]
    FailedToAddGlyph(u16),
    /// Failed to get scaled glyph image for cache key
    #[error("failed to get scaled glyph image for cache key: {0:?}")]
    FailedToGetGlyphImage(u16),
    /// Missing texture atlas layout for the font
    #[error("missing texture atlas layout for the font")]
    MissingAtlasLayout,
    /// Missing texture for the font atlas
    #[error("missing texture for the font atlas")]
    MissingAtlasTexture,
    /// Failed to find glyph in atlas after it was added
    #[error("failed to find glyph in atlas after it was added")]
    InconsistentAtlasState,
    #[error("scale factor <= 0")]
    /// Text cannot be rendered for a scale factor <= zero.

View on GitHub (pinned to 396ca72708)

Solutions

  1. Load the font asset that provides the family first, and configure generic families after it loads
  2. Use the exact family name from the font's name table (not necessarily the file name)
  3. Enable the `parley/system` feature (or install fonts in the container) for automatic system font discovery
  4. Handle the Err by logging and continuing with default families

Example fix

// before — family not registered yet (font still loading / system fonts disabled)
parley_context.set_serif_family("MySerif")?;

// after — wait for the font asset, then set the generic family
let font = asset_server.load("fonts/MySerif-Regular.ttf");
// ... on AssetEvent::LoadedWithDependencies for `font`:
if parley_context.set_serif_family("MySerif").is_err() {
    bevy_log::warn!("family 'MySerif' not registered; keeping default serif mapping");
}
Defensive patterns

Strategy: validation

Try / catch

match parley_context.set_serif_family(name) {
    Ok(()) => {}
    Err(TextError::NoSuchFontFamily(missing)) => {
        bevy_log::warn!("font family {missing:?} not registered; keeping default serif mapping");
    }
    Err(e) => return Err(e.into()),
}

Prevention

When it happens

Trigger: Calling set_serif_family("SomeName") when no loaded font provides that family and system font discovery is disabled or found nothing; calling before the providing font asset has loaded; case/wording mismatch with the font's internal family name.

Common situations: wasm builds (no system fonts without the parley/system feature); containers/servers with no fonts installed; configuring generic families at startup before font assets finish loading; assuming the file name equals the font family name.

Related errors


AI-assisted analysis of bevyengine/bevy@396ca72708 (2026-08-20). Data as JSON: /api/errors/5fdc03f37e12eace. Report an issue: GitHub.