stride3d/stride · error · ArgumentNullException
textures
Error message
textures
What it means
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.
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
Example fix
// before font = factory.NewStatic(12f, glyphs, textures, 0f, 10f); // textures was null // after if (textures == null) textures = new List<Texture>(); font = factory.NewStatic(12f, glyphs, textures, 0f, 10f);
Defensive patterns
Strategy: validation
Validate before calling
if (textures == null) throw new ArgumentNullException(nameof(textures)); if (glyphs == null) throw new ArgumentNullException(nameof(glyphs));
Type guard
bool IsValidTextures(IList<Texture> t) => t != null;
Prevention
- Never pass null collection arguments; pass empty collections when appropriate
- Validate asset build output (textures present) before constructing fonts
When it happens
Trigger: Calling NewStatic(size, glyphs, textures, baseOffset, ...) with a null textures argument, typically because the asset build pipeline produced no texture pages for the glyphs.
Common situations: 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.
Related errors
- [ ] cannot be null in
- [ ] cannot be null in
- [ ] cannot be null in
- [ ] cannot be null in
- [ ] cannot be null in
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/05376182866bb59e.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Graphics/Font/FontDataFactory.cs:19
// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
using System;
using System.Collections.Generic;
using Stride.Graphics.Data;
namespace Stride.Graphics.Font
{
/// <summary>
/// A font factory initializing only the data members of font.
/// Used when creating a font in the only purpose use serializing on disk.
/// </summary>
public class FontDataFactory : IFontFactory
{
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 = ' ')
{
if (textures == null) throw new ArgumentNullException("textures");
return new OfflineRasterizedSpriteFont(size, glyphs, textures, baseOffset, defaultLineSpacing, kernings, extraSpacing, extraLineSpacing, defaultCharacter);
}
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 = ' ')
{
// creates the textures from the images if any.
Texture[] textures = null;
if (images != null)
{
textures = new Texture[images.Count];
for (int i = 0; i < textures.Length; i++)
textures[i] = images[i].ToSerializableVersion();
}
return new OfflineRasterizedSpriteFont(size, glyphs, textures, baseOffset, defaultLineSpacing, kernings, extraSpacing, extraLineSpacing, defaultCharacter);
}
View on GitHub (pinned to 96fad776d2)