Skip to main content

Figgle by Drew Noakes

Nuget / site data

Nuget GitHub last commit GitHub Repo stars

Details

Info

info

Name: Figgle

A source generator that produces ASCII banners at compile-time.

  This package is a great choice if the strings you want to render
are static (i.e. string literals). If you want to render dynamic
strings, use the Figgle package directly instead. You can use both
at the same time.

Author: Drew Noakes

NuGet: https://www.nuget.org/packages/Figgle.Generator/

You can find more details at https://github.com/drewnoakes/figgle

Source : https://github.com/drewnoakes/figgle

Original Readme

note
 _____ _         _     
| __|_|___ ___| |___
| __| | . | . | | -_|
|__| |_|_ |_ |_|___|
|___|___|

Figgle Build Status Figgle NuGet download count

ASCII banner generation for .NET

Console.WriteLine(
FiggleFonts.Standard.Render("Hello, World!"));

Produces...

  _   _      _ _         __        __         _     _ _
| | | | ___| | | ___ \ \ / /__ _ __| | __| | |
| |_| |/ _ \ | |/ _ \ \ \ /\ / / _ \| '__| |/ _` | |
| _ | __/ | | (_) | \ V V / (_) | | | | (_| |_|
|_| |_|\___|_|_|\___( ) \_/\_/ \___/|_| |_|\__,_(_)
|/

Use Figgle's source generator to embed just the fonts you want into your assembly, orif the text to render is known ahead of timerender that text during compilation, so you don't need to ship Figgle binaries with your app.

Installation

Figgle ships as NuGet packages that target .NET Standard 2.0, so runs almost everywhere.

ProjectBadgesDescription
Figglev dlThe core library. Supports parsing font files and rendering text.
Figgle.Fontsv dlA collection of 250+ FIGlet fonts, for use with Figgle.
Figgle.Generatorv dlA source generator to embedding fonts and render static text at compile-time.

Sample apps

If you just want to see some code (it's not that complex) check out one of the following sample projects:

SampleDescription
BasicsThe easiest option, if you don't care about application size or memory use.
Static text generationFor statically-known text, have a source generator embed the rendered text directly into your assembly. Uses the Figgle.Generator package, and uses a single attribute to render the text at compile time. If all Figgle text is rendered this way, you don't have to ship any Figgle assembly with your app.
Embed font from packageFor dynamic text, using a font from the Figgle.Fonts package via an attribute. The font is embedded directly into your assembly. With this approach, you only need the lightweight Figgle package at runtime.
Embed font from .flf fileFor dynamic text, using a .flf font file via an attribute and <AdditionalFiles> project item in the .csproj. The font is embedded directly into your assembly. With this approach, you only need the lightweight Figgle package at runtime.

More output examples

Using FiggleFonts.Graffiti:

  ___ ___         .__  .__               __      __            .__       .___._.
/ | \ ____ | | | | ____ / \ / \___________| | __| _/| |
/ ~ \_/ __ \| | | | / _ \ \ \/\/ / _ \_ __ \ | / __ | | |
\ Y /\ ___/| |_| |_( <_> ) \ ( <_> ) | \/ |__/ /_/ | \|
\___|_ / \___ >____/____/\____/ /\ \__/\ / \____/|__| |____/\____ | __
\/ \/ )/ \/ \/ \/

Using FiggleFonts.ThreePoint:

|_| _ || _    \    / _  _| _||
| |(/_||(_), \/\/ (_)| |(_|.

Using FiggleFonts.Ogre:

            _ _          __    __           _     _   _ 
/\ /\___| | | ___ / / /\ \ \___ _ __| | __| | / \
/ /_/ / _ \ | |/ _ \ \ \/ \/ / _ \| '__| |/ _` |/ /
/ __ / __/ | | (_) | \ /\ / (_) | | | | (_| /\_/
\/ /_/ \___|_|_|\___( ) \/ \/ \___/|_| |_|\__,_\/
|/

Using FiggleFonts.Rectangles:

                                            __ 
_____ _ _ _ _ _ _ _| |
| | |___| | |___ | | | |___ ___| |_| | |
| | -_| | | . |_ | | | | . | _| | . |__|
|__|__|___|_|_|___| | |_____|___|_| |_|___|__|
|_|

Using FiggleFonts.Slant:

    __  __     ____           _       __           __    ____
/ / / /__ / / /___ | | / /___ _____/ /___/ / /
/ /_/ / _ \/ / / __ \ | | /| / / __ \/ ___/ / __ / /
/ __ / __/ / / /_/ / | |/ |/ / /_/ / / / / /_/ /_/
/_/ /_/\___/_/_/\____( ) |__/|__/\____/_/ /_/\__,_(_)
|/

About

note

Generating ASCII art text for console applications

How to use

Example ( source csproj, source files )

This is the CSharp Project that references Figgle

<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Figgle.Generator" Version="0.6.4" PrivateAssets="all" />
</ItemGroup>
<PropertyGroup>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
<CompilerGeneratedFilesOutputPath>$(BaseIntermediateOutputPath)\GX</CompilerGeneratedFilesOutputPath>
</PropertyGroup>

</Project>

Generated Files

Those are taken from $(BaseIntermediateOutputPath)\GX

// Copyright Drew Noakes. Licensed under the Apache-2.0 license. See the LICENSE file for more details.

// <auto-generated>
// This code was generated by Figgle.Generator.
//
// https://github.com/drewnoakes/figgle
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>

using System;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;

namespace Figgle
{
/// <summary>
/// Instructs a source generator to embed a Figgle font in the assembly, making it available
/// via a static property on class this attribute is applied to.
/// </summary>
/// <remarks>
/// <para>
/// This attribute is processed by a source generator in the <c>Figgle.Generator</c> package.
/// </para>
/// <para>
/// This source generator will embed the specified Figgle font into your assembly, which is a
/// more performant alternative to using the <c>Figgle.Fonts</c> package, which embeds all of
/// the Figgle fonts.
/// </para>
/// <para>
/// If the text you want Figgle to render is not statically known at compile time, you should
/// use this generator and ship the <c>Figgle</c> package.
/// </para>
/// <para>
/// If the text you want Figgle to render is statically known at compile time, you should use
/// <see cref="GenerateFiggleTextAttribute" /> instead.
/// </para>
/// </remarks>
[Conditional("INCLUDE_FIGGLE_GENERATOR_ATTRIBUTES")]
[ExcludeFromCodeCoverage]
[DebuggerNonUserCode]
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
internal sealed class EmbedFiggleFontAttribute : Attribute
{
/// <summary>
/// The name of the property to add, whose getter will return the embedded <see cref="FiggleFont" />.
/// </summary>
public string MemberName { get; }

/// <summary>
/// The name of the font to use when rendering the text.
/// </summary>
public string FontName { get; }

/// <summary>
/// Initializes a new instance of the <see cref="EmbedFiggleFontAttribute"/> class.
/// </summary>
/// <param name="memberName">The name of the property to add, whose getter returns the embedded <paramref name="FiggleFont" />.</param>
/// <param name="fontName">The name of the font to use when rendering the text.</param>
public EmbedFiggleFontAttribute(string memberName, string fontName)
{
MemberName = memberName;
FontName = fontName;
}
}
}

Usefull

Download Example (.NET C# )

Share Figgle

https://ignatandrei.github.io/RSCG_Examples/v2/docs/Figgle

In the same category (Console) - 0 other generators