stride3d/stride · error · Exception

Font does not contain any glyphs.

Error message

Font does not contain any glyphs.

What it means

After importing, SignedDistanceFieldFontCompiler.ImportFont validates that at least one glyph was produced from importer.Glyphs. If the list is empty it throws this Exception — a font yielding zero glyphs cannot be packed or rendered, and continuing would fail later at runtime.

Solutions

  1. Verify the CharacterSet file exists, is readable UTF-8/UTF-16, and contains the characters you need.
  2. Open the font file in a tool (fontforge) to confirm it is valid and has glyphs for the requested range.
  3. Regenerate or re-download the font file if it is corrupted.
  4. Log the resolved character list (GetCharactersToImport output) before importing to confirm it is non-empty.

Example fix

// before
var chars = SignedDistanceFieldFontCompiler.GetCharactersToImport(asset); // resolves to 0 chars
var glyphs = ImportFont(asset, out ls, out bl); // throws
// after
var chars = SignedDistanceFieldFontCompiler.GetCharactersToImport(asset);
if (chars.Count == 0) throw new InvalidDataException($"Character set for {asset.FontSource.GetFontPath()} resolved to 0 characters");
Defensive patterns

Strategy: validation

Validate before calling

var chars = SignedDistanceFieldFontCompiler.GetCharactersToImport(asset);
if (chars.Count == 0)
    throw new InvalidDataException($"Character set for '{asset.FontSource.GetFontPath()}' resolved to 0 characters; check CharacterSet file and font coverage");

Type guard

bool HasCharactersToImport(SpriteFontAsset asset) =>
    SignedDistanceFieldFontCompiler.GetCharactersToImport(asset).Count > 0;

Try / catch

try
{
    var font = SignedDistanceFieldFontCompiler.Compile(factory, asset);
}
catch (Exception ex) when (ex.Message == "Font does not contain any glyphs.")
{
    logger.LogError("SDF import produced no glyphs for {Source}. Verify the font file and CharacterSet.", asset.FontSource.GetFontPath());
    throw;
}

Prevention

When it happens

Trigger: Running SDF import on a font source from which the importer extracted no glyphs — e.g. a CharacterSet file resolving to an empty character list, a corrupted/empty font file, or requested characters the font does not contain at all.

Common situations: A CharacterSet text file that is empty or whitespace-only; a truncated or corrupt TTF; character ranges that the font does not cover; wrong path passed to the importer.

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/31a574d9ff86d79c. Report an issue: GitHub.

Appendix: source

Thrown at sources/engine/Stride.Assets/SpriteFont/Compiler/SignedDistanceFieldFontCompiler.cs:149

            importer = new SignedDistanceFieldFontImporter();

            // 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.");
            }

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

            // Check that the default character is part of the glyphs
            if (!DefaultCharacterExists(options.DefaultCharacter, glyphs))
            {
                throw new InvalidOperationException("The specified DefaultCharacter is not part of this font.");
            }

            return glyphs.ToArray();
        }

        private static bool DefaultCharacterExists(char defaultCharacter, List<Glyph> glyphs)
        {
            if (defaultCharacter == 0)
                return true;

View on GitHub (pinned to 96fad776d2)