{"record":{"id":"31a574d9ff86d79c","repo":"stride3d/stride","slug":"font-does-not-contain-any-glyphs-31a574","errorCode":null,"errorMessage":"Font does not contain any glyphs.","messagePattern":"Font does not contain any glyphs\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Assets/SpriteFont/Compiler/SignedDistanceFieldFontCompiler.cs","lineNumber":149,"sourceCode":"\n            importer = new SignedDistanceFieldFontImporter();\n\n            // create the list of character to import\n            var characters = GetCharactersToImport(options);\n\n            // Import the source font data.\n            importer.Import(options, characters);\n\n            lineSpacing = importer.LineSpacing;\n            baseLine = importer.BaseLine;\n\n            // Get all glyphs\n            var glyphs = new List<Glyph>(importer.Glyphs);\n\n            // Validate.\n            if (glyphs.Count == 0)\n            {\n                throw new Exception(\"Font does not contain any glyphs.\");\n            }\n\n            // Sort the glyphs\n            glyphs.Sort((left, right) => left.Character.CompareTo(right.Character));\n\n            // Check that the default character is part of the glyphs\n            if (!DefaultCharacterExists(options.DefaultCharacter, glyphs))\n            {\n                throw new InvalidOperationException(\"The specified DefaultCharacter is not part of this font.\");\n            }\n\n            return glyphs.ToArray();\n        }\n\n        private static bool DefaultCharacterExists(char defaultCharacter, List<Glyph> glyphs)\n        {\n            if (defaultCharacter == 0)\n                return true;","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Assets/SpriteFont/Compiler/SignedDistanceFieldFontCompiler.cs#L131-L167","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the CharacterSet file exists, is readable UTF-8/UTF-16, and contains the characters you need.","Open the font file in a tool (fontforge) to confirm it is valid and has glyphs for the requested range.","Regenerate or re-download the font file if it is corrupted.","Log the resolved character list (GetCharactersToImport output) before importing to confirm it is non-empty."],"exampleFix":"// before\nvar chars = SignedDistanceFieldFontCompiler.GetCharactersToImport(asset); // resolves to 0 chars\nvar glyphs = ImportFont(asset, out ls, out bl); // throws\n// after\nvar chars = SignedDistanceFieldFontCompiler.GetCharactersToImport(asset);\nif (chars.Count == 0) throw new InvalidDataException($\"Character set for {asset.FontSource.GetFontPath()} resolved to 0 characters\");","handlingStrategy":"validation","validationCode":"var chars = SignedDistanceFieldFontCompiler.GetCharactersToImport(asset);\nif (chars.Count == 0)\n    throw new InvalidDataException($\"Character set for '{asset.FontSource.GetFontPath()}' resolved to 0 characters; check CharacterSet file and font coverage\");","typeGuard":"bool HasCharactersToImport(SpriteFontAsset asset) =>\n    SignedDistanceFieldFontCompiler.GetCharactersToImport(asset).Count > 0;","tryCatchPattern":"try\n{\n    var font = SignedDistanceFieldFontCompiler.Compile(factory, asset);\n}\ncatch (Exception ex) when (ex.Message == \"Font does not contain any glyphs.\")\n{\n    logger.LogError(\"SDF import produced no glyphs for {Source}. Verify the font file and CharacterSet.\", asset.FontSource.GetFontPath());\n    throw;\n}","preventionTips":["Keep the CharacterSet file non-empty and readable (UTF-8) and ship it with the asset.","Verify the font file opens in a font editor before wiring it into the build.","Log the resolved character list during development to catch empty sets early.","Avoid requesting character ranges the font cannot cover without supplying an alternative font."],"tags":["fonts","sdf","empty"],"backgroundTag":"empty-result-set","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}