Coder Social home page Coder Social logo

figgle's Introduction

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

Figgle Build Status Figgle NuGet version Figgle NuGet download count

ASCII banner generation for .NET

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

Produces...

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

Alternatively, use Figgle's source generator to generate output during compilation, so you don't need to ship Figgle binaries with your app. See below for details.

The library bundles 265 FIGlet fonts. You can add your own if that's not enough!

Installation

Available via NuGet:

Install-Package Figgle

Targets .NET Standard 2.0, so runs pretty much anywhere. If you require .NET Standard 1.3, use package version 0.4.1.

Other samples

Using FiggleFonts.Graffiti:

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

Using FiggleFonts.ThreePoint:

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

Using FiggleFonts.Ogre:

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

Using FiggleFonts.Rectangles:

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

Using FiggleFonts.Slant:

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

Loading external fonts

Figgle ships with a bunch of fonts (in the FiggleFonts class). If you prefer, you can load your own.

Here's an example that loads a font from disk and renders some text with it:

using var fontStream = System.IO.File.OpenRead("myfont.flf");
var font = FiggleFontParser.Parse(fontStream);
var text = font.Render("Hello World, from My Font");

Using the Source Generator

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;

namespace MyNamespace
{
    [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:

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

figgle's People

Contributors

akoken avatar drewnoakes avatar jsakamoto avatar laxynium avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

figgle's Issues

netstandard2.0 support

accounting to microsoft dotnet open source library guide here

✔️ DO start with including a netstandard2.0 target.

Most general-purpose libraries should not need APIs outside of .NET Standard 2.0. .NET Standard 2.0 is supported by all modern platforms and is the recommended way to support multiple platforms with one target.

❌ AVOID including a netstandard1.x target.

.NET Standard 1.x is distributed as a granular set of NuGet packages, which creates a large package dependency graph and results in developers downloading a lot of packages when building. Modern .NET platforms, including .NET Framework 4.6.1, UWP and Xamarin, all support .NET Standard 2.0. You should only target .NET Standard 1.x if you specifically need to target an older platform.

✔️ DO include a netstandard2.0 target if you require a netstandard1.x target.

All platforms supporting .NET Standard 2.0 will use the netstandard2.0 target and benefit from having a smaller package graph while older platforms will still work and fall back to using the netstandard1.x target.

How do I add external fonts to be used?

I wish to use some external figlet fonts to accompany the current ones available, although the readme doesn't specify how I could do this. Any help is appreciated.

Installing nuget package adds tons of unnecessary references

Hey, when installing Figgle using nuget a bunch of unnecessary references are added to the project. None of these references are actually needed except Figgle. These references make it look suspicious because a lot of them are cryptography related and other stuff unrelated to Figgle's core function.

edit: or maybe it does need all those references, in that case, why?

Print on the Same Line Different Color

I am trying to print some characters in one color and rest of then in another color - but cannot
Console.Write is acting like Console.WriteLine i.e. adding an line break.

Console.ForegroundColor = ConsoleColor.DarkGreen;
Console.Write(FiggleFonts.Cards.Render($"{charArray[0]}{charArray[1]}{charArray[2]}"));
Console.ForegroundColor = ConsoleColor.White;
Console.Write(FiggleFonts.Cards.Render($"{charArray[3]}"));

Investigate source generator support

Searching around on GitHub it seems that several users of this library use it with a static string, such as the project name.

For such users it'd make sense to not ship the Figgle binaries with their app, and instead generate the output text at compile time and embed that directly.

C# 9's source generators should enable that.

Exception rendering text using EftiChess font

System.IndexOutOfRangeException: Index was outside the bounds of the array.
   at System.Text.StringBuilder.get_Chars(Int32 index)
   at Figgle.FiggleFont.Render(String message, Nullable`1 smushOverride)

The message text doesn't seem particularly important.

This was observed in a simple Blazor WebAssembly app.

NuGet package supporting netstandard 2.0

Hello @drewnoakes

Thank you for this cool library! Our CI/CD pipeline fails at docker image scanning stage since netstandard 1.x has old and vulnerable packages. I wonder when you will publish next release. It seems you've already merged it :)

image

image

Make the lookup case insensitive

    private static FiggleFont FontFactory(string name)
    {
        using var stream = typeof(FiggleFonts).GetTypeInfo().Assembly.GetManifestResourceStream("Figgle.Fonts.zip");
        using var zip = new ZipArchive(stream, ZipArchiveMode.Read);
        var entry = zip.Entries.ToDictionary(x=> x.FullName, x => x)
            .FirstOrDefault(x => x.Key.ToLowerInvariant().Replace(" ", string.Empty) == (name+".flf").ToLowerInvariant().Replace(" ", string.Empty)).Value;


        if (entry == null)
            throw new FiggleException($"No embedded font exists with name \"{name}\".");

        using var entryStream = entry.Open();
            
        return FiggleFontParser.Parse(entryStream, _stringPool);
    }

    public static FiggleFont Parse(string name)
    {
        var x = FontFactory(name);
        return x;
    }

suggestion: unbundle fonts from engine

Hi.

Would it be possible to unbundle the fonts from the engine, i.e. in split into two nuget packages? This way the base engine nuget package would be much leaner.

Currently it ships as a 474KB DLL, of which ~90% alone are due to Fonts.zip as an embedded resource. As a comparison, having two separate DLLs, the DLL for the engine would be ~15KB and the DLL for the fonts would be ~464KB (and would depend on the engine DLL).

Since the engine already allows external fonts to be loaded, it would not be that hard for a user of the engine to load a font either from the unbundled fonts package or from disk.

Just an idea...

Thanks.

Figgle Generator not creating strings.

Hello,
I'm trying to use the generator.

Visual Studio 2022 v17.8.4
.Net 8
Project type: library
Pacakge: Figgle.Generator v0.5.1

My class code:

Filename: StartupBanners.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Figgle;

namespace MyProject.Lib.Common
{
    [GenerateFiggleTextAttribute("DevelopmentString", "standard", "Development")]
    public partial class StartupBanners
    {
    }
}

When I compile the app I see no partial class code generation.
I've tried the following.

Without a StartupBanners.partial`1.cs file

With a StartupBanners.partial`1.cs file

Am I missing something?

Thank you,
Howard Shank

Support smushing

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

Without fitting, text looks like this:

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

With fitting, text looks like this:

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

With smushing, it will look like this:

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

There are several smushing rules, both horizontal and vertical.

How to auto newline?

How to auto newline?If the text want to render is too long, the pattern will deform

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.