Figgle.Generator 0.6.5

dotnet add package Figgle.Generator --version 0.6.5
                    
NuGet\Install-Package Figgle.Generator -Version 0.6.5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Figgle.Generator" Version="0.6.5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Figgle.Generator" Version="0.6.5" />
                    
Directory.Packages.props
<PackageReference Include="Figgle.Generator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Figgle.Generator --version 0.6.5
                    
#r "nuget: Figgle.Generator, 0.6.5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#addin nuget:?package=Figgle.Generator&version=0.6.5
                    
Install as a Cake Addin
#tool nuget:?package=Figgle.Generator&version=0.6.5
                    
Install as a Cake Tool
 _____ _         _       _____                     _           
|   __|_|___ ___| |___  |   __|___ ___ ___ ___ ___| |_ ___ ___ 
|   __| | . | . | | -_|_|  |  | -_|   | -_|  _| .'|  _| . |  _|
|__|  |_|_  |_  |_|___|_|_____|___|_|_|___|_| |__,|_| |___|_|  
        |___|___|                                              

GitHub project NuGet package Figgle NuGet download count

Figgle's source generator

This package contains source generators that reduce the deployment footprint and memory usage of applications that use Figgle.

Figgle has two source generators: one renders static text at compile time, the other embeds the font into your assembly.

Sample code

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

Sample Description
Static text generation For 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 package For dynamic text, using a font from the Figgle.Fonts package via abn 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 file For 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.

Static text rendering

If the text you want Figgle to render is known at compile time, this section is for you.

Instead of having Figgle render text at runtime, you can use Figgle's source generator to do the rendering at compile time. This has two benefits:

  • Faster runtime performance, as no Figgle code is executed
  • Less memory consumption, as no Figgle code is loaded
  • Smaller application footprint, as you don't need to ship Figgle binaries

In your code:

using Figgle;

[GenerateFiggleText("HelloWorldString", "blocks", "Hello world")]
internal partial class MyClass
{
}

By adding this attribute to a partial class, Figgle will automatically generate the corresponding member in another part of the partial class, resembling:

partial class MyClass
{
    public static string HelloWorldString { get; } = "...rendered text here...";
}

If you want to use an external font, include the external font file as an additional file in your csproj:

<ItemGroup>
    <AdditionalFiles Include="myfont.flf" />
</ItemGroup>

Then specify the font's file name (excluding the extension) as the font name in the attribute:

[GenerateFiggleText("HelloWorldString", "myfont", "Hello world")]

Alternatively, you can specify a custom font name using the FontName item metadata:

<ItemGroup>
    <AdditionalFiles Include="myfont.flf" FontName="MyCustomFontName" />
</ItemGroup>
[GenerateFiggleText("HelloWorldString", "MyCustomFontName", "Hello world")]
internal partial class MyClass
{
}

Note the font name specified in the GenerateFiggleText attribute is case-insensitive so mycustomfontname works too.

Embedding fonts

If you know the font you want to use to render, but the text to render is dynamic during runtime (e.g. user input), you can use the source generator to embed the font into your assembly.

By embedding only the fonts you want into your assembly, you can avoid having to ship all of built-in figgle fonts with your application, reducing the deploy size and memory usage of your application.

In your code:

using Figgle;

namespace MyNamespace;

[EmbedFiggleFont(memberName: "MyFont", fontName: "blocks")]
internal static partial class MyClass
{
}

This will cause the source generator to generate a static property of type FiggleFont in the MyClass type, which you can use to render text:

using Figgle;

namespace MyNamespace;

internal partial class MyClass
{
    public static FiggleFont MyFont { get; }
}

You can then use the font the same way you use a built-in font:

using Figgle;

namespace MyNamespace;

string text = MyClass.MyFont.Render("Hello, World!");

Console.WriteLine(text);

Similar to GenerateFiggleText, external fonts are also supported. Include the external font file as an additional file in your csproj the same way as before:

<ItemGroup>
    <AdditionalFiles Include="myfont.flf" FontName="MyExternalFont" />
</ItemGroup>

Then specify the font's font name as specified in AdditionalFiles (filename without the extension is also recognized if FontName property is not defined):

[EmbedFiggleFont(memberName: "MyFont", fontName: "MyExternalFont")]

Source generator diagnostics

Rule ID Category Severity Notes
FGL0001 Figgle Error The specified font name was not found.
FGL0002 Figgle Error The attribute specified an invalid member name.
FGL0003 Figgle Error The member specified by the attribute has already been declared.
FGL0004 Figgle Error The type must be partial.
FGL0005 Figgle Error Figgle generation does not support nested types.
FGL0006 Figgle Error There were errors when trying to read the external font.
FGL0007 Figgle Error Type must static.
There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

  • .NETStandard 2.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.

Version Downloads Last Updated
0.6.5 20 6/28/2025
0.6.4 136 6/25/2025
0.6.3 140 6/23/2025
0.6.2 341 6/7/2025
0.6.1 261 6/3/2025
0.5.1 15,182 1/6/2023