FIGLet 1.1.0
dotnet add package FIGLet --version 1.1.0
NuGet\Install-Package FIGLet -Version 1.1.0
<PackageReference Include="FIGLet" Version="1.1.0" />
<PackageVersion Include="FIGLet" Version="1.1.0" />
<PackageReference Include="FIGLet" />
paket add FIGLet --version 1.1.0
#r "nuget: FIGLet, 1.1.0"
#addin nuget:?package=FIGLet&version=1.1.0
#tool nuget:?package=FIGLet&version=1.1.0
FIGLet Core Library
A C# implementation of FIGLet (Frank, Ian & Glenn's letters) - a program for making large letters out of ordinary text.
Overview
This library provides a robust and efficient implementation of the FIGLet specification, allowing you to create ASCII art from text using FIGLet fonts. It supports all standard FIGLet features including various smushing rules and layout modes.
Features
- Full FIGLet font (.flf) file parsing and loading
- Automatic handling of compressed/zipped font files
- Support for all standard FIGLet smushing rules:
- Equal Character
- Underscore
- Hierarchy
- Opposite Pair
- Big X
- Hard Blank
- Multiple layout modes:
- Full Size (no smushing)
- Kerning (minimal smushing)
- Smushing (full character overlap)
- ANSI color support for terminal output
- Unicode support including surrogate pairs
- Thread-safe design
- Efficient string manipulation with StringBuilder
- Automatic handling of paragraph formatting
- Default embedded font included
- Comprehensive XML documentation
- Nullable reference type support
Usage
// Load a FIGLet font
var font = FIGFont.FromFile("standard.flf");
// Create a renderer
var renderer = new FIGLetRenderer(font);
// Render text
string asciiArt = renderer.Render("Hello World!", LayoutMode.Smushing);
Console.WriteLine(asciiArt);
Using the Default Font
The library comes with a built-in default font:
// Use the default embedded font
var renderer = new FIGLetRenderer();
// Render text
string asciiArt = renderer.Render("Hello World!");
Console.WriteLine(asciiArt);
Sample Output
Below is an example of text rendered using the default settings:
_ _ _ _ _ _ _ _ _
| || |___| | |___ \ \ / /__ _ _| |__| | |
| __ / -_) | / _ \_ \ \/\/ / _ \ '_| / _` |_|
|_||_\___|_|_\___( ) \_/\_/\___/_| |_\__,_(_)
|/
Layout Modes
The library supports three layout modes:
LayoutMode.FullSize
: No character compressionLayoutMode.Kerning
: Basic spacing adjustmentLayoutMode.Smushing
: Full character combining (default)
// Example with different layout modes
string fullSize = renderer.Render("Text", LayoutMode.FullSize);
string kerning = renderer.Render("Text", LayoutMode.Kerning);
string smushing = renderer.Render("Text", LayoutMode.Smushing);
ANSI Color Support
The library supports ANSI color codes for terminal output, allowing you to create colorful FIGLet text:
// Create a renderer with ANSI color support enabled
var colorRenderer = new FIGLetRenderer(font, useANSIColors: true);
// Render text with ANSI colors
string colorfulText = "\u001b[31mRed\u001b[0m \u001b[32mGreen\u001b[0m \u001b[34mBlue\u001b[0m";
string colorfulAsciiArt = colorRenderer.Render(colorfulText);
Console.WriteLine(colorfulAsciiArt);
You can also enable color support when using the static rendering methods:
string colorfulAsciiArt = FIGLetRenderer.Render(colorfulText, font, LayoutMode.Smushing, useANSIColors: true);
Paragraph Mode
The library can automatically handle paragraphs in input text:
// Multi-paragraph text
string paragraphs = "Paragraph 1\n\nParagraph 2";
// Enable paragraph mode (enabled by default)
var renderer = new FIGLetRenderer(font, paragraphMode: true);
string formattedText = renderer.Render(paragraphs);
Smushing Rules
The library implements all standard FIGLet smushing rules as defined in the FIGLet specification:
// Check if a specific smushing rule is enabled
bool hasEqualCharRule = font.HasSmushingRule(SmushingRules.EqualCharacter);
bool hasUnderscoreRule = font.HasSmushingRule(SmushingRules.Underscore);
Unicode Support
The library fully supports Unicode characters, including surrogate pairs:
// Render Unicode text
string unicodeArt = renderer.Render("Hello 😊 World! 你好,世界!");
Implementation Details
The library consists of the following main components:
FIGFont: Handles font loading and storage
- Parses .flf font files
- Supports loading from files, streams, or embedded resources
- Handles compressed/zipped font files
- Stores character data and font metadata
- Manages smushing rules configuration
FIGLetRenderer: Core rendering engine
- Converts input text to FIGLet output
- Implements character smushing logic
- Handles different layout modes
- Processes ANSI color codes
- Supports paragraph formatting
LayoutMode: Enumeration defining rendering modes
- Controls how characters are combined
SmushingRules: Flags enumeration for smushing rules
- Defines available character combining rules
FIGFontStream: Utility class for font loading
- Handles automatic detection and extraction of zipped fonts
Performance Considerations
- Uses
StringBuilder
for efficient string manipulation - Lazy initialization of the default font
- Immutable font design for thread safety
- Efficient regular expressions for whitespace handling
- Optimized character smushing calculations
- Intelligent ANSI color code handling
- Support for surrogate pairs without performance degradation
Supported Frameworks
- .NET Framework 4.7.2, 4.8, 4.8.1
- .NET Standard 2.0, 2.1
- .NET Core 3.1
- .NET 5.0, 6.0, 7.0, 8.0, 9.0
NuGet Installation
Install the package from NuGet:
Install-Package FIGLet
Or using the .NET CLI:
dotnet add package FIGLet
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Credits
- Original FIGLet concept by Frank, Ian & Glenn
- FIGLet specifications: http://www.figlet.org/
- Implementation by Paulo Santos
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 is compatible. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 is compatible. net48 is compatible. net481 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETCoreApp 3.1
- No dependencies.
-
.NETFramework 4.7.2
- No dependencies.
-
.NETFramework 4.8
- No dependencies.
-
.NETFramework 4.8.1
- No dependencies.
-
.NETStandard 2.0
- System.IO.Compression (>= 4.3.0)
-
.NETStandard 2.1
- System.IO.Compression (>= 4.3.0)
-
net5.0
- No dependencies.
-
net6.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.