OpenRA/OpenRA · error · ArgumentException

Requested font '{Font}' was not found.

Error message

Requested font '{Font}' was not found.

What it means

Thrown by LabelWidget.IncreaseHeightToFitCurrentText when the widget's Font property names a font not registered in Game.Renderer.Fonts. Fonts are defined in the mod's fonts.yaml and loaded at engine startup. This method is typically called during chrome layout to auto-size label height.

Source

Thrown at OpenRA.Mods.Common/Widgets/LabelWidget.cs:74

			VAlign = other.VAlign;
			Font = other.Font;
			TextColor = other.TextColor;
			Contrast = other.Contrast;
			ContrastColorDark = other.ContrastColorDark;
			ContrastColorLight = other.ContrastColorLight;
			ContrastRadius = other.ContrastRadius;
			Shadow = other.Shadow;
			WordWrap = other.WordWrap;
			GetText = other.GetText;
			GetColor = other.GetColor;
			GetContrastColorDark = other.GetContrastColorDark;
			GetContrastColorLight = other.GetContrastColorLight;
		}

		public void IncreaseHeightToFitCurrentText()
		{
			if (!Game.Renderer.Fonts.TryGetValue(Font, out var font))
				throw new ArgumentException($"Requested font '{Font}' was not found.");

			var line = GetText();
			if (WordWrap)
				line = WidgetUtils.WrapText(line, Bounds.Width, font);
			Bounds.Height = Math.Max(Bounds.Height, font.Measure(line).Y);
		}

		public override void Draw()
		{
			if (!Game.Renderer.Fonts.TryGetValue(Font, out var font))
				throw new ArgumentException($"Requested font '{Font}' was not found.");

			var text = GetText();
			if (text == null)
				return;

			if (WordWrap)
				text = WidgetUtils.WrapText(text, Bounds.Width, font);

View on GitHub (pinned to a520984d91)

Solutions

  1. Check the Font value in the widget's chrome YAML against the mod's fonts.yaml keys
  2. Add the missing font definition to fonts.yaml
  3. Use one of the known font names already defined by the mod

Example fix

# before (chrome.yaml)
LABEL:
  Font: TinyBold  # not defined in fonts.yaml

# after
LABEL:
  Font: TinyRegular
Defensive patterns

Strategy: validation

Validate before calling

// Before calling IncreaseHeightToFitCurrentText, verify the font is loaded
if (!Game.Renderer.Fonts.ContainsKey(Font))
    Console.Error.WriteLine($"Font '{Font}' not found. Available: {string.Join(", ", Game.Renderer.Fonts.Keys)}");

Prevention

When it happens

Trigger: A LabelWidget has a Font value not matching any key in the loaded font dictionary, and IncreaseHeightToFitCurrentText is invoked (usually during panel initialization via headerLabel.IncreaseHeightToFitCurrentText()).

Common situations: Font name typo in chrome layout YAML, referencing a font removed in a mod update, or fonts.yaml doesn't define the referenced font.

Related errors


AI-assisted analysis of OpenRA/OpenRA@a520984d91 (2026-08-13). Data as JSON: /api/errors/fc40fc3097fe6cac. Report an issue: GitHub.