{"record":{"id":"c0d834e0ca5629b2","repo":"MonoGame/MonoGame","slug":"the-specified-defaultcharacter-is-not-part-of-this","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":"MonoGame.Framework.Content.Pipeline/Processors/FontDescriptionProcessor.cs","lineNumber":229,"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 != null)\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        private static string? FindFont(string name, string style)\n        {\n            if (CurrentPlatform.OS == OS.Windows)\n            {\n#pragma warning disable CA1416 // Validate platform compatibility\n                var fontDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), \"Fonts\");\n                foreach (var key in new[] { Registry.LocalMachine, Registry.CurrentUser })\n                {\n                    var subkey = key.OpenSubKey(@\"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts\", false);\n                    if (subkey == null)\n                    {\n                        return null;","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/MonoGame/MonoGame/blob/1d71bbd0ff4071a03caa583aa3bc56b85924a819/MonoGame.Framework.Content.Pipeline/Processors/FontDescriptionProcessor.cs#L211-L247","documentation":"Thrown by FontDescriptionProcessor.ImportFont as an InvalidOperationException when the DefaultCharacter specified in the FontDescription is not found among the glyphs produced by the font importer. The default character is used at runtime to substitute missing characters, so it must itself exist in the font.","triggerScenarios":"Setting DefaultCharacter in the .spritefont to a character code point that the font does not contain. For example, setting DefaultCharacter to a CJK character in a Latin-only font, or to a symbol not covered by the font's glyph set.","commonSituations":"The .spritefont's DefaultCharacter element specifies a Unicode character that doesn't exist in the chosen font. The font was changed but the DefaultCharacter was not updated. A custom character set excludes the default character.","solutions":["Set DefaultCharacter to a character that exists in the font (commonly a space, '?', or a box character).","Remove the DefaultCharacter element from the .spritefont if you don't need fallback substitution.","Switch to a font that includes the desired default character."],"exampleFix":"// .spritefont\n// before\n<DefaultCharacter>&#x3000;</DefaultCharacter> // ideographic space not in font\n// after\n<DefaultCharacter>?</DefaultCharacter> // '?' exists in most fonts","handlingStrategy":"validation","validationCode":"// Before building, check if DefaultCharacter is likely valid\n// (basic range check — the font may still not have it)\nif (fontDesc.DefaultCharacter.HasValue)\n{\n    var ch = fontDesc.DefaultCharacter.Value;\n    if (ch < ' ' || ch > 0xFFFF)\n        throw new InvalidOperationException($\"DefaultCharacter '{ch}' is outside typical font range.\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    context.BuildAsset<FontDescription, SpriteFontContent>(fontDesc, processor);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"DefaultCharacter\"))\n{\n    fontDesc.DefaultCharacter = null; // or set to '?'\n    context.BuildAsset<FontDescription, SpriteFontContent>(fontDesc, processor);\n}","preventionTips":["Use a common ASCII character as DefaultCharacter ('?', space, or a box character).","After changing a font, verify the DefaultCharacter still exists in the new font.","If unsure, omit DefaultCharacter from the .spritefont."],"tags":["font","content-pipeline","validation","default-character","mgcb"],"backgroundTag":null,"analyzedSha":"1d71bbd0ff4071a03caa583aa3bc56b85924a819","analyzedAt":"2026-08-13T17:10:33.625Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}