{"record":{"id":"4ac5ad350783c3dd","repo":"stride3d/stride","slug":"the-font-system-is-not-initialized-yet","errorCode":null,"errorMessage":"The font system is not initialized yet","messagePattern":"The font system is not initialized yet","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Engine/Engine/Game.cs","lineNumber":131,"sourceCode":"        /// </summary>\n        public GameProfilingSystem ProfilingSystem { get; }\n\n        /// <summary>\n        /// Gets the VR Device System.\n        /// </summary>\n        public VRDeviceSystem VRDeviceSystem { get; }\n\n        /// <summary>\n        /// Gets the font system.\n        /// </summary>\n        /// <value>The font system.</value>\n        /// <exception cref=\"System.InvalidOperationException\">The font system is not initialized yet</exception>\n        public IFontFactory Font\n        {\n            get\n            {\n                if (gameFontSystem.FontSystem == null)\n                    throw new InvalidOperationException(\"The font system is not initialized yet\");\n\n                return gameFontSystem.FontSystem;\n            }\n        }\n\n        /// <summary>\n        /// Gets or sets the console log mode. See remarks.\n        /// </summary>\n        /// <value>The console log mode.</value>\n        /// <remarks>\n        /// Defines how the console will be displayed when running the game. By default, on Windows, It will open only on debug\n        /// if there are any messages logged.\n        /// </remarks>\n        public ConsoleLogMode ConsoleLogMode\n        {\n            get\n            {\n                var consoleLogListener = logListener as ConsoleLogListener;","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Engine/Engine/Game.cs#L113-L149","documentation":"Game.Font throws InvalidOperationException when the underlying GameFontSystem has not yet created its FontSystem. The font factory is only available after the font system is initialized during the game's setup, so early access fails. It signals an access-order bug rather than a bad input.","triggerScenarios":"Accessing the public Game.Font property before GameBase.Initialize/Run has set up gameFontSystem.FontSystem (i.e. GameFontSystem.FontSystem == null).","commonSituations":"Reading Game.Font in the Game constructor or in scene/entity initialization that runs before the game loop starts; loading fonts during content script preload before initialization completed.","solutions":["Move the code that reads Game.Font to after the game is initialized (e.g. first Script update, Start/Initialize phase).","Guard the access by checking that the font system is ready before using the Font property.","If the font system should be ready, check your Game initialization flags/order so font setup is not skipped."],"exampleFix":"// before\npublic MyGame()\n{\n    var factory = Font; // throws before init\n}\n// after\npublic override void Update(GameTime time)\n{\n    var factory = Font; // safe after initialization\n}","handlingStrategy":"validation","validationCode":"if (game.Font == null || game.GameFontSystem?.FontSystem == null) { /* defer until after Init */ }","typeGuard":"bool CanUseFont(Game g) => g?.GameFontSystem?.FontSystem != null;","tryCatchPattern":null,"preventionTips":["Access Font only inside script Start/Update phases, never in the constructor.","Treat game initialization order as a contract; document font-system readiness points."],"tags":["game-engine","initialization-order","fonts","invalid-operation"],"backgroundTag":"invalid-state-transition","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}