{"record":{"id":"0f11f9cfa4d3dd6c","repo":"stride3d/stride","slug":"the-specified-defaultcharacter-is-not-part-of-this-font-0f11f9","errorCode":null,"errorMessage":"The specified DefaultCharacter is not part of this font.","messagePattern":"The specified DefaultCharacter is not part of this font\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Assets/SpriteFont/Compiler/SignedDistanceFieldFontCompiler.cs","lineNumber":158,"sourceCode":"            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;\n\n            foreach (var glyph in glyphs)\n            {\n                if (glyph.Character == defaultCharacter)\n                    return true;\n            }\n\n            return false;\n        }","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Assets/SpriteFont/Compiler/SignedDistanceFieldFontCompiler.cs#L140-L176","documentation":"Like the offline compiler, SignedDistanceFieldFontCompiler.ImportFont requires the asset's DefaultCharacter to be among the imported glyphs. If DefaultCharacterExists fails after the glyph list is built and sorted, it throws this InvalidOperationException so runtime fallback rendering never resolves to a missing glyph.","triggerScenarios":"Importing an SDF font whose DefaultCharacter is set to a codepoint not present in the font or excluded from the CharacterSet used to build the glyph list.","commonSituations":"DefaultCharacter set to 'é' (or a CJK/emoji character) while the CharacterSet only lists ASCII; switching the font file without updating DefaultCharacter; default character left over from a different asset template.","solutions":["Change DefaultCharacter to a character guaranteed to be in the font and included in the CharacterSet (e.g. '?').","Add the desired default character to the CharacterSet file so it gets imported.","Set DefaultCharacter to 0/null if no fallback glyph is required.","Intersect the CharacterSet with the font's cmap (font inspection tool) to confirm coverage before building."],"exampleFix":"// before (font asset)\n<DefaultCharacter>★</DefaultCharacter> <!-- not in charset -->\n// after: add the char to charset.txt, or use\n<DefaultCharacter>?</DefaultCharacter>","handlingStrategy":"validation","validationCode":"var chars = SignedDistanceFieldFontCompiler.GetCharactersToImport(asset);\nif (asset.DefaultCharacter != default && !chars.Contains(asset.DefaultCharacter.Value))\n    asset.DefaultCharacter = '?'; // ensure the default is part of the imported set","typeGuard":"bool DefaultWillBeImported(SpriteFontAsset asset) =>\n    asset.DefaultCharacter == default ||\n    SignedDistanceFieldFontCompiler.GetCharactersToImport(asset).Contains(asset.DefaultCharacter.Value);","tryCatchPattern":"try\n{\n    var font = SignedDistanceFieldFontCompiler.Compile(factory, asset);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"DefaultCharacter\"))\n{\n    asset.DefaultCharacter = '?';\n    font = SignedDistanceFieldFontCompiler.Compile(factory, asset); // retry with safe default\n}","preventionTips":["Always include the DefaultCharacter in the CharacterSet file.","Use a default character from the ASCII range unless the font is verified to cover it.","Re-check DefaultCharacter whenever the font file or charset changes.","Add a content-build assertion that DefaultCharacter is in the resolved character list."],"tags":["fonts","sdf","validation"],"backgroundTag":"invalid-argument-value","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"}