spectreconsole/spectre.console · error · InvalidOperationException
Invalid Figlet font header
Error message
Invalid Figlet font header
What it means
Thrown by ParseHeader after splitting the header line into whitespace-delimited tokens when fewer than 6 parts are present. A valid FIGlet header has at least 6 fields (signature+hardblank, height, baseline, max length, old layout, comment lines). Too few tokens means the header is truncated.
Source
Thrown at src/Spectre.Console/Widgets/Figlet/FigletFontParser.cs:107
{
index = index.ReplaceExact("0x", string.Empty);
style = NumberStyles.HexNumber;
}
return int.TryParse(index, style, CultureInfo.InvariantCulture, out result);
}
private static FigletHeader ParseHeader(string text)
{
if (string.IsNullOrWhiteSpace(text))
{
throw new InvalidOperationException("Invalid Figlet font");
}
var parts = text.SplitWords(StringSplitOptions.RemoveEmptyEntries);
if (parts.Length < 6)
{
throw new InvalidOperationException("Invalid Figlet font header");
}
if (!IsValidSignature(parts[0]))
{
throw new InvalidOperationException("Invalid Figlet font header signature");
}
int? fullLayout = null;
if (parts.Length > 7 && int.TryParse(parts[7], NumberStyles.Integer, CultureInfo.InvariantCulture, out var fl))
{
fullLayout = fl;
}
return new FigletHeader
{
Hardblank = parts[0][5],
Height = int.Parse(parts[1], CultureInfo.InvariantCulture),
Baseline = int.Parse(parts[2], CultureInfo.InvariantCulture),View on GitHub (pinned to 0acc92fada)
Solutions
- Open the font file and verify the header line has at least 6 space-separated fields.
- Use a FIGlet font from the standard distribution known to parse correctly.
- Regenerate or re-download the font file if it is truncated.
Example fix
// before (header has too few fields) // flf2a$ 5 // after (complete header) // flf2a$ 5 4 16 15 11 0 24463
Defensive patterns
Strategy: validation
Validate before calling
var parts = headerLine.SplitWords(StringSplitOptions.RemoveEmptyEntries);
if (parts.Length < 6) throw new ArgumentException("Figlet header must have >= 6 fields"); Type guard
static bool HasEnoughHeaderFields(string headerLine) => headerLine.SplitWords(StringSplitOptions.RemoveEmptyEntries).Length >= 6;
Prevention
- Use fonts from the standard FIGlet distribution.
- Avoid hand-editing font header lines.
When it happens
Trigger: Passing a FIGlet font whose header line is incomplete or where fields are joined together preventing proper SplitWords tokenization.
Common situations: Manual editing of a font header that deleted fields, a font in a non-standard variant, or whitespace normalization that merged fields.
Related errors
- Invalid Figlet font
- Could not read header line
- Invalid Figlet font header signature
- Invalid JSON
- Encountered closing tag when none was expected near position
AI-assisted analysis of spectreconsole/spectre.console@0acc92fada (2026-08-13).
Data as JSON: /api/errors/3c80971e755e204c.
Report an issue: GitHub.