{"record":{"id":"05376182866bb59e","repo":"stride3d/stride","slug":"textures","errorCode":null,"errorMessage":"textures","messagePattern":"textures","errorType":"validation","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Graphics/Font/FontDataFactory.cs","lineNumber":19,"sourceCode":"// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)\n// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.\n\nusing System;\nusing System.Collections.Generic;\n\nusing Stride.Graphics.Data;\n\nnamespace Stride.Graphics.Font\n{\n    /// <summary>\n    /// A font factory initializing only the data members of font. \n    /// Used when creating a font in the only purpose use serializing on disk.\n    /// </summary>\n    public class FontDataFactory : IFontFactory\n    {\n        public SpriteFont NewStatic(float size, IList<Glyph> glyphs, IList<Texture> textures, float baseOffset, float defaultLineSpacing, IList<Kerning> kernings = null, float extraSpacing = 0, float extraLineSpacing = 0, char defaultCharacter = ' ')\n        {\n            if (textures == null) throw new ArgumentNullException(\"textures\");\n\n            return new OfflineRasterizedSpriteFont(size, glyphs, textures, baseOffset, defaultLineSpacing, kernings, extraSpacing, extraLineSpacing, defaultCharacter);\n        }\n\n        public SpriteFont NewStatic(float size, IList<Glyph> glyphs, IList<Image> images, float baseOffset, float defaultLineSpacing, IList<Kerning> kernings = null, float extraSpacing = 0, float extraLineSpacing = 0, char defaultCharacter = ' ')\n        {\n            // creates the textures from the images if any.\n            Texture[] textures = null;\n            if (images != null)\n            {\n                textures = new Texture[images.Count];\n                for (int i = 0; i < textures.Length; i++)\n                    textures[i] = images[i].ToSerializableVersion();\n            }\n            \n            return new OfflineRasterizedSpriteFont(size, glyphs, textures, baseOffset, defaultLineSpacing, kernings, extraSpacing, extraLineSpacing, defaultCharacter);\n        }\n","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Graphics/Font/FontDataFactory.cs#L1-L37","documentation":"FontDataFactory.NewStatic throws ArgumentNullException when the textures list is null. This factory builds an OfflineRasterizedSpriteFont whose rasterized glyph data is backed by texture images, so a null texture list would leave the font unusable. The library fails fast at construction rather than deep inside rendering.","triggerScenarios":"Calling NewStatic(size, glyphs, textures, baseOffset, ...) with a null textures argument, typically because the asset build pipeline produced no texture pages for the glyphs.","commonSituations":"Deserializing a corrupted or partially-built font asset where the texture array is null; writing a custom IFontFactory implementation that passes through an uninitialized texture list; refactoring code that used to build textures but now returns null on failure.","solutions":["Ensure the textures list is non-null before calling NewStatic; pass an empty list if there are genuinely no textures","Check the font asset build/import pipeline for steps that failed to generate texture pages","If constructing from images instead, call the NewStatic overload that takes IList<Image> which rasterizes textures internally"],"exampleFix":"// before\nfont = factory.NewStatic(12f, glyphs, textures, 0f, 10f); // textures was null\n// after\nif (textures == null) textures = new List<Texture>();\nfont = factory.NewStatic(12f, glyphs, textures, 0f, 10f);","handlingStrategy":"validation","validationCode":"if (textures == null) throw new ArgumentNullException(nameof(textures));\nif (glyphs == null) throw new ArgumentNullException(nameof(glyphs));","typeGuard":"bool IsValidTextures(IList<Texture> t) => t != null;","tryCatchPattern":null,"preventionTips":["Never pass null collection arguments; pass empty collections when appropriate","Validate asset build output (textures present) before constructing fonts"],"tags":["null-argument","fonts","csharp"],"backgroundTag":"null-argument","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}