stride3d/stride · error · Exception

Font does not contain any glyphs.

Error message

Font does not contain any glyphs.

What it means

OfflineRasterizedFontCompiler.ImportFont collects the importer's produced glyphs and throws a plain Exception when the resulting list is empty. A compiled sprite font must contain at least one glyph; zero glyphs would produce an unusable texture.

Solutions

  1. Ensure the sprite font asset's character set contains at least one character the font actually provides.
  2. Check the font file supports the requested characters (use a font with a broad character map).
  3. Review import logs for glyph loading failures that silently removed all characters.

Example fix

// before
CharacterSet = ""; // empty -> no glyphs

// after
CharacterSet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
Defensive patterns

Strategy: validation

Validate before calling

if (string.IsNullOrWhiteSpace(fontAsset.CharacterSet))
    throw new ArgumentException("Sprite font character set must not be empty.");

Try / catch

catch (Exception ex) when (ex.Message == "Font does not contain any glyphs.") { log.Error("Character set empty or unsupported by font."); }

Prevention

When it happens

Trigger: The font importer (FreeType or bitmap) produced no glyphs: empty or invalid character set in the asset, a font whose characters map to nothing, or an importer that silently skipped all characters.

Common situations: Sprite font asset with an empty CharacterSet / missing characters; font file lacking the requested characters (e.g. icon-only font with letters requested and no fallback).

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/0627e1681823e404. Report an issue: GitHub.

Appendix: source

Thrown at sources/engine/Stride.Assets/SpriteFont/Compiler/OfflineRasterizedFontCompiler.cs:165

            importer = importFromBitmap ? (IFontImporter) new BitmapImporter() : new FreeTypeFontImporter();

            // create the list of character to import
            var characters = GetCharactersToImport(options); 

            // Import the source font data.
            importer.Import(options, characters);

            lineSpacing = importer.LineSpacing;
            baseLine = importer.BaseLine;

            // Get all glyphs
            var glyphs = new List<Glyph>(importer.Glyphs);

            // Validate.
            if (glyphs.Count == 0)
            {
                throw new Exception("Font does not contain any glyphs.");
            }
            if (!importFromBitmap)
            {
                foreach (var glyph in importer.Glyphs)
                    BitmapUtils.ConvertGreyToAlpha(glyph.Bitmap, glyph.Subrect);
            }

            // Sort the glyphs
            glyphs.Sort((left, right) => left.Character.CompareTo(right.Character));


            // Check that the default character is part of the glyphs
            if (options.DefaultCharacter != 0)
            {
                bool defaultCharacterFound = false;
                foreach (var glyph in glyphs)
                {
                    if (glyph.Character == options.DefaultCharacter)

View on GitHub (pinned to 96fad776d2)