{"record":{"id":"5f83373fc72a3c2a","repo":"stride3d/stride","slug":"the-specified-defaultcharacter-is-not-part-of-this-font","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/OfflineRasterizedFontCompiler.cs","lineNumber":191,"sourceCode":"            // Sort the glyphs\n            glyphs.Sort((left, right) => left.Character.CompareTo(right.Character));\n\n\n            // Check that the default character is part of the glyphs\n            if (options.DefaultCharacter != 0)\n            {\n                bool defaultCharacterFound = false;\n                foreach (var glyph in glyphs)\n                {\n                    if (glyph.Character == options.DefaultCharacter)\n                    {\n                        defaultCharacterFound = true;\n                        break;\n                    }\n                }\n                if (!defaultCharacterFound)\n                {\n                    throw new InvalidOperationException(\"The specified DefaultCharacter is not part of this font.\");\n                }\n            }\n\n            return glyphs.ToArray();\n        }\n\n        public static List<char> GetCharactersToImport(SpriteFontAsset asset)\n        {\n            var characters = new List<char>();\n\n            var fontTypeStatic = asset.FontType as OfflineRasterizedSpriteFontType;\n            if (fontTypeStatic == null)\n                throw new ArgumentException(\"Tried to compile a dynamic sprite font with compiler for signed distance field fonts\");\n\n            // extract the list from the provided file if it exits\n            if (File.Exists(fontTypeStatic.CharacterSet))\n            {\n                string text;","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Assets/SpriteFont/Compiler/OfflineRasterizedFontCompiler.cs#L173-L209","documentation":"Stride's OfflineRasterizedSpriteFontCompiler rasterizes glyphs and requires a fallback glyph for characters missing from the font. After building the glyph list it checks that the asset's DefaultCharacter was actually rasterized; if not, it throws this InvalidOperationException. A default character that is not in the font would produce a null fallback glyph at render time, so the compiler fails fast during asset build.","triggerScenarios":"Calling ImportFont in OfflineRasterizedFontCompiler (directly or via Compile, which feeds GetCharactersToImport/ImportFont) with a SpriteFontAsset whose DefaultCharacter is a codepoint the font file does not contain — e.g. DefaultCharacter='é' on an ASCII-only TTF, or a character outside the compiled CharacterSet.","commonSituations":"Setting DefaultCharacter in a font asset to a symbol the TTF lacks; copying a font asset between projects where the new font has different coverage; specifying a default character excluded from the character regions/CharacterSet.","solutions":["Open the font asset and set DefaultCharacter to a character verified to exist in the font file ('?' or '*' are almost always present).","If the font lacks a suitable default, switch to a font file with broader coverage (a full Unicode font).","Alternatively set DefaultCharacter to null/0 so no default-glyph validation applies, if the pipeline allows it.","Verify actual coverage with a font inspection tool (fontforge, OS character map) before setting the value."],"exampleFix":"// before (font asset)\n<DefaultCharacter>é</DefaultCharacter>\n// after\n<DefaultCharacter>?</DefaultCharacter>","handlingStrategy":"validation","validationCode":"// before compiling, confirm the default char exists in the font's cmap\nif (asset.DefaultCharacter != default && !FontCoversCharacter(fontPath, asset.DefaultCharacter.Value))\n    asset.DefaultCharacter = '?'; // safe fallback present in nearly all fonts","typeGuard":"bool IsValidDefaultCharacter(SpriteFontAsset asset) =>\n    asset.DefaultCharacter == default ||\n    FontCoversCharacter(asset.FontSource.GetFontPath(), asset.DefaultCharacter.Value);","tryCatchPattern":"try\n{\n    var glyphs = OfflineRasterizedFontCompiler.Compile(factory, asset);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"DefaultCharacter\"))\n{\n    asset.DefaultCharacter = '?';\n    glyphs = OfflineRasterizedFontCompiler.Compile(factory, asset); // retry with safe default\n}","preventionTips":["Pick a default character you verified exists in the font (ASCII '?' or '*' is safest).","Keep DefaultCharacter and the CharacterSet/regions in sync — include the default in the compiled set.","Add a pre-build asset check that validates DefaultCharacter against font coverage.","Re-validate font assets after swapping the underlying .ttf/.otf file."],"tags":["fonts","assets","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"}