{"record":{"id":"7fbd6dad35ca4eca","repo":"stride3d/stride","slug":"font-file-not-found-fontpath-freetypefontimporter","errorCode":null,"errorMessage":"Font file not found: {fontPath}","messagePattern":"Font file not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Assets/SpriteFont/Compiler/FreeTypeFontImporter.cs","lineNumber":40,"sourceCode":"        public IEnumerable<Glyph> Glyphs { get; private set; }\n\n        public float LineSpacing { get; private set; }\n\n        public float BaseLine { get; private set; }\n\n        public void Import(SpriteFontAsset options, List<char> characters)\n        {\n            NativeLibraryHelper.PreloadLibrary(\"freetype\", typeof(FreeTypeFontImporter));\n\n            int err = FreeTypeNative.FT_Init_FreeType(out var library);\n            if (err != 0)\n                throw new InvalidOperationException($\"Failed to initialize FreeType library (error {err})\");\n\n            try\n            {\n                var fontPath = options.FontSource.GetFontPath();\n                if (string.IsNullOrEmpty(fontPath) || !File.Exists(fontPath))\n                    throw new FileNotFoundException($\"Font file not found: {fontPath}\");\n\n                var fontData = File.ReadAllBytes(fontPath);\n                var handle = GCHandle.Alloc(fontData, GCHandleType.Pinned);\n\n                try\n                {\n                    FT_FaceRec* face;\n                    fixed (byte* ptr = fontData)\n                    {\n                        err = FreeTypeNative.FT_New_Memory_Face(library, ptr, new CLong(fontData.Length), new CLong(0), out face);\n                        if (err != 0)\n                            throw new InvalidOperationException($\"Failed to load font '{fontPath}' (FreeType error {err})\");\n                    }\n\n                    try\n                    {\n                        var fontSize = options.FontType.Size;\n","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Assets/SpriteFont/Compiler/FreeTypeFontImporter.cs#L22-L58","documentation":"After FreeType initializes, FreeTypeFontImporter.Import resolves the font source path and throws FileNotFoundException when the path is null/empty or the file does not exist. It guards the TrueType/OpenType file that will be pinned in memory for FT_New_Memory_Face.","triggerScenarios":"SpriteFontAsset.FontSource.GetFontPath() returns a nonexistent or empty path when compiling an offline-rasterized (system/OTF/TTF) font.","commonSituations":"Font file deleted or renamed after the .sdfont was created; relative path broken by moving the project; missing font file in source control.","solutions":["Verify the font path exists: File.Exists(options.FontSource.GetFontPath()); fix FontSource in the asset.","Re-import or re-add the .ttf/.otf file to the project.","Restore the missing font file from source control or reinstall the font."],"exampleFix":"// before\nSource = \"C:/Windows/Fonts/oldfont.ttf\";\n\n// after\nSource = \"assets/fonts/Inter-Regular.ttf\"; // file exists in project","handlingStrategy":"validation","validationCode":"var fontPath = fontAsset.FontSource.GetFontPath();\nif (string.IsNullOrEmpty(fontPath) || !File.Exists(fontPath))\n    throw new FileNotFoundException($\"Font file not found: {fontPath}\");","typeGuard":null,"tryCatchPattern":"catch (FileNotFoundException ex) { log.Error($\"Restore font file: {ex.FileName}\"); }","preventionTips":["Commit font files to source control.","Verify paths after moving or renaming the project."],"tags":["fonts","file-not-found","assets"],"backgroundTag":"file-not-found","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"}