{"record":{"id":"1c0b1c62d9eb4ca5","repo":"spectreconsole/spectre.console","slug":"invalid-figlet-font","errorCode":null,"errorMessage":"Invalid Figlet font","messagePattern":"Invalid Figlet font","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Spectre.Console/Widgets/Figlet/FigletFontParser.cs","lineNumber":101,"sourceCode":"    }\n\n    private static bool TryParseIndex(string index, out int result)\n    {\n        var style = NumberStyles.Integer;\n        if (index.StartsWith(\"0x\", StringComparison.OrdinalIgnoreCase))\n        {\n            index = index.ReplaceExact(\"0x\", string.Empty);\n            style = NumberStyles.HexNumber;\n        }\n\n        return int.TryParse(index, style, CultureInfo.InvariantCulture, out result);\n    }\n\n    private static FigletHeader ParseHeader(string text)\n    {\n        if (string.IsNullOrWhiteSpace(text))\n        {\n            throw new InvalidOperationException(\"Invalid Figlet font\");\n        }\n\n        var parts = text.SplitWords(StringSplitOptions.RemoveEmptyEntries);\n        if (parts.Length < 6)\n        {\n            throw new InvalidOperationException(\"Invalid Figlet font header\");\n        }\n\n        if (!IsValidSignature(parts[0]))\n        {\n            throw new InvalidOperationException(\"Invalid Figlet font header signature\");\n        }\n\n        int? fullLayout = null;\n        if (parts.Length > 7 && int.TryParse(parts[7], NumberStyles.Integer, CultureInfo.InvariantCulture, out var fl))\n        {\n            fullLayout = fl;\n        }","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/spectreconsole/spectre.console/blob/0acc92fada6c42f13984e79c2b5f3d993bdfb099/src/Spectre.Console/Widgets/Figlet/FigletFontParser.cs#L83-L119","documentation":"Thrown by ParseHeader when the header line is null or entirely whitespace. FIGlet fonts must begin with a header line containing the signature and metadata; a blank header is treated as an invalid font. This fires before the structural field-count check.","triggerScenarios":"Parsing a FIGlet font whose first line is blank or whitespace-only, or passing a source where leading whitespace produces an empty first token sequence.","commonSituations":"A font file with a leading blank line before the real header, copy-paste introducing stray whitespace, or a malformed/corrupted font downloaded from an unreliable source.","solutions":["Inspect the font source to confirm the first line is the flf2 header.","Trim leading blank lines from the source before parsing.","Replace the font with a known-good FIGlet font file."],"exampleFix":"// before\nvar font = FigletFont.Load(sourceWithBlankFirstLine);\n\n// after\nvar trimmed = sourceWithBlankFirstLine.TrimStart('\\n', '\\r');\nvar font = FigletFont.Load(trimmed);","handlingStrategy":"validation","validationCode":"var firstLine = source.SplitLines().FirstOrDefault();\nif (string.IsNullOrWhiteSpace(firstLine)) throw new ArgumentException(\"Figlet header is blank\");","typeGuard":"static bool HasValidHeaderLine(string source) => !string.IsNullOrWhiteSpace(source.SplitLines().FirstOrDefault());","tryCatchPattern":null,"preventionTips":["Trim leading blank lines from font sources before loading.","Inspect font files with a text editor before embedding."],"tags":["figlet","font-parsing","validation","spectre-console"],"backgroundTag":null,"analyzedSha":"0acc92fada6c42f13984e79c2b5f3d993bdfb099","analyzedAt":"2026-08-13T18:27:21.983Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}