{"record":{"id":"e6ad04df4933216d","repo":"stride3d/stride","slug":"failed-to-load-glyph-for-character-character-freetype-error","errorCode":null,"errorMessage":"Failed to load glyph for character '{character}' (FreeType error {err})","messagePattern":"Failed to load glyph for character '(.+?)' \\(FreeType error (.+?)\\)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Assets/SpriteFont/Compiler/FreeTypeFontImporter.cs","lineNumber":125,"sourceCode":"\n                var emptyBitmap = new Image<Rgba32>(1, 1);\n                var glyph = new Glyph(character, emptyBitmap)\n                {\n                    XOffset = 0,\n                    YOffset = 0,\n                    XAdvance = glyphIndex != 0 ? face->glyph->advance.x.Value / 64.0f : 0,\n                };\n                return glyph;\n            }\n\n            // Load and render the glyph\n            {\n                var loadTarget = antiAliasMode == FontAntiAliasMode.Aliased\n                    ? FreeTypeLoadTarget.Mono\n                    : FreeTypeLoadTarget.Normal;\n                int err = FreeTypeNative.FT_Load_Glyph(face, glyphIndex, (int)FreeTypeLoadFlags.Default | (int)loadTarget);\n                if (err != 0)\n                    throw new InvalidOperationException($\"Failed to load glyph for character '{character}' (FreeType error {err})\");\n\n                var renderMode = antiAliasMode == FontAntiAliasMode.Aliased\n                    ? FreeTypeRenderMode.Mono\n                    : FreeTypeRenderMode.Normal;\n                err = FreeTypeNative.FT_Render_Glyph(face->glyph, renderMode);\n                if (err != 0)\n                    throw new InvalidOperationException($\"Failed to render glyph for character '{character}' (FreeType error {err})\");\n            }\n\n            ref FT_Bitmap ftBitmap = ref face->glyph->bitmap;\n            int width = (int)ftBitmap.width;\n            int height = (int)ftBitmap.rows;\n\n            if (width == 0 || height == 0)\n            {\n                var emptyBitmap = new Image<Rgba32>(1, 1);\n                return new Glyph(character, emptyBitmap)\n                {","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Assets/SpriteFont/Compiler/FreeTypeFontImporter.cs#L107-L143","documentation":"In ImportGlyph, FT_Load_Glyph fails for a specific character (non-zero FreeType error code), so the importer throws this InvalidOperationException. The glyph outline for that character could not be retrieved from the loaded font face.","triggerScenarios":"FT_Load_Glyph returns an error for the glyph index of a character being compiled - e.g. invalid glyph index, corrupted face, or unsupported font data mid-import.","commonSituations":"Fonts with damaged character-map entries; characters mapping to invalid glyph indices; memory pressure while processing large character sets.","solutions":["Remove the problematic character(s) from the character set of the sprite font asset.","Try a different version of the font file known to be intact.","Re-export/convert the font (e.g. with fontforge) to fix a damaged glyf table."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try\n{\n    importer.ImportGlyph(character, glyphIndex);\n}\ncatch (InvalidOperationException ex) when (ex.Message.StartsWith(\"Failed to load glyph\"))\n{\n    log.Warn($\"Skipping character '{character}': {ex.Message}\");\n}","preventionTips":["Keep character sets limited to characters the font provides.","Replace damaged fonts with verified copies."],"tags":["fonts","native-interop","glyph"],"backgroundTag":"internal-invariant-violation","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"}