Skip to content

Adds two new layout modes for FigletText#2066

Open
patriksvensson wants to merge 2 commits intospectreconsole:mainfrom
patriksvensson:feature/GH-1448
Open

Adds two new layout modes for FigletText#2066
patriksvensson wants to merge 2 commits intospectreconsole:mainfrom
patriksvensson:feature/GH-1448

Conversation

@patriksvensson
Copy link
Copy Markdown
Contributor

@patriksvensson patriksvensson commented Apr 1, 2026

Now supports fitting (kerning) as well as
smushing (both universal and from font rules).

Fixes #1448

  • I have read the Contribution Guidelines
  • I have checked that there isn't already another pull request that solves the above issue
  • All newly added code is adequately covered by tests
  • All existing tests are still running without errors

Changes

Added fitting and smushing to FigletText rendering.

CleanShot 2026-04-02 at 22 35 08@2x

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds FIGlet “layout modes” support to FigletText, enabling kerning (fitting) and smushing (universal + font-rule-based) to produce more compact/ascii-art-accurate output.

Changes:

  • Introduces FigletLayoutMode and a LayoutMode option on FigletText, with rendering updates for fitted/smushed output.
  • Parses and exposes font smushing rules from FIGlet headers (fullLayout / oldLayout) to drive smushing behavior.
  • Adds snapshot-based tests (plus a new test font) and a sandbox project for manual verification.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/Spectre.Console/Widgets/Figlet/FigletText.cs Implements fitted/smushed rendering and adds LayoutMode + fluent extensions.
src/Spectre.Console/Widgets/Figlet/FigletLayoutMode.cs Adds a public enum for the new layout modes.
src/Spectre.Console/Widgets/Figlet/FigletHeader.cs Captures FullLayout from font headers.
src/Spectre.Console/Widgets/Figlet/FigletFontParser.cs Parses fullLayout and adjusts behavior around overridden index parsing.
src/Spectre.Console/Widgets/Figlet/FigletFont.cs Exposes computed SmushingRules from the parsed header values.
src/Spectre.Console.Tests/Unit/Widgets/FigletTests.cs Adds verification tests for fitted/smushed rendering.
src/Spectre.Console.Tests/Spectre.Console.Tests.csproj Embeds the new banner.flf test font.
src/Spectre.Console.Tests/Expectations/Widgets/Figlet/* Adds new verified outputs for the added tests.
src/Spectre.Console.Tests/Data/banner.flf Adds a font exercising font-driven smushing rules.
src/Spectre.Console.slnx Adds the Sandbox project to the solution.
src/Sandbox/Sandbox.csproj New sandbox project for manual rendering inspection.
src/Sandbox/Program.cs Demonstrates rendering each layout mode in a panel.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Spectre.Console/Widgets/Figlet/FigletLayoutMode.cs Outdated
Comment thread src/Spectre.Console/Widgets/Figlet/FigletText.cs
Comment thread src/Spectre.Console/Widgets/Figlet/FigletText.cs Outdated
Comment thread src/Spectre.Console/Widgets/Figlet/FigletText.cs
Comment thread src/Spectre.Console/Widgets/Figlet/FigletFontParser.cs Outdated
Comment thread src/Spectre.Console/Widgets/Figlet/FigletLayoutMode.cs Outdated
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 16 out of 16 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/Spectre.Console/Widgets/Figlet/FigletFont.cs
Comment thread src/Spectre.Console/Widgets/Figlet/FigletText.cs Outdated
Comment thread src/Spectre.Console/Widgets/Figlet/FigletText.cs
Comment thread src/Spectre.Console/Widgets/Figlet/FigletLayoutMode.cs Outdated
Comment thread src/Spectre.Console/Widgets/Figlet/FigletLayoutMode.cs Outdated
Comment thread src/Spectre.Console/Widgets/Figlet/FigletFontParser.cs
@patriksvensson patriksvensson force-pushed the feature/GH-1448 branch 2 times, most recently from 44bd822 to 4bdc708 Compare April 18, 2026 19:18
Copy link
Copy Markdown
Contributor

@phil-scott-78 phil-scott-78 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this all looks good to me, I'll probably move my usage over to it right away. I do prefer the smushed look.

The Sandbox app is the one thing I have a question about - personally I like having it in there, but it might get weird with commits in the future if people are filling it with test code.

@patriksvensson
Copy link
Copy Markdown
Contributor Author

@phil-scott-78 I will remove the Sandbox app!

Now supports fitting (kerning) as well as
smushing (both universal and from font rules).

Closes spectreconsole#1448
@patriksvensson
Copy link
Copy Markdown
Contributor Author

@phil-scott-78 Done. If all is good with you, should we merge this? 😅
I feel a bit nervous, but maybe it's just because I've changed a lot of internals...

Comment thread src/Spectre.Console/Widgets/Figlet/FigletFontParser.cs Outdated
@phil-scott-78
Copy link
Copy Markdown
Contributor

@phil-scott-78 Done. If all is good with you, should we merge this? 😅 I feel a bit nervous, but maybe it's just because I've changed a lot of internals...

I grabbed a repository with 350 figlet fonts and rendered them all. The good news is all the fonts on there that loaded in the current version worked fine with this update and spot checking the output for those seems to render just fine with the new mode. So I think its safe to push this PR.

The bad news is about 120 of them failed on both versions.

About 100 of them had the same issue where the endmark wasn't the hard coded @. The spec seems to say you detect the endmark from the first glyph's first row.

That leaves 19 with other issues I can dig further into. Might just be weird fonts.

@patriksvensson
Copy link
Copy Markdown
Contributor Author

@phil-scott-78 I should have done that as well. Can you share your test app? The parsing of the endmark seem fixable. If I look into fixing that, could you look into the 12 other bad fonts?

@phil-scott-78
Copy link
Copy Markdown
Contributor

@phil-scott-78 I should have done that as well. Can you share your test app? The parsing of the endmark seem fixable. If I look into fixing that, could you look into the 12 other bad fonts?

can do. here's my audit app, it's a single file C# app - https://gist.github.com/phil-scott-78/a5825c9cf830e3d281157d8edc8d76c1

I cloned down this repository as its input - https://github.com/xero/figlet-fonts

@patriksvensson
Copy link
Copy Markdown
Contributor Author

Awesome! Will take a look at it tomorrow. Super late here so I need to sleep 😅

@patriksvensson
Copy link
Copy Markdown
Contributor Author

I've done some testing, and come to these conclusions. Will try to add a commit to this PR which solve the problems.

  1. Some fonts define the same character multiple times.
    Solution: Replace character instead of throwing
  2. Some fonts rely on font height instead of letter terminator.
    Solution: Should skip letter terminator completely. Always rely on header height
  3. Some fonts use a custom end character.
    Solution: Parse end character
CleanShot 2026-04-19 at 14 35 33@2x

@patriksvensson
Copy link
Copy Markdown
Contributor Author

CleanShot 2026-04-19 at 15 02 00@2x

Ok, everything seems fine now, will try to clean this up tonight.

@phil-scott-78
Copy link
Copy Markdown
Contributor

oh nice one, I started down the path on the non-endmark failures and I found the same header height thing. Rest make sense too. Total coverage!

@patriksvensson
Copy link
Copy Markdown
Contributor Author

patriksvensson commented Apr 20, 2026

@phil-scott-78 I've added your report as a verification test and fixed the bugs. The changes are in the latest commit.

Could you take a look before we merge this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support FIGlet layoutmodes and smushing

3 participants