RSCG – Figgle

RSCG – Figgle
 
 

name Figgle
nuget https://www.nuget.org/packages/Figgle.Generator/
link https://github.com/drewnoakes/figgle
author Drew Noakes

Generating ASCII art text for console applications

 

This is how you can use Figgle .

The code that you start with is


<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>


The code that you will use is


Console.WriteLine(MyTexts.MyName);



[Figgle.GenerateFiggleText(memberName: "MyName", fontName: "standard", sourceText: "AndreiIgnat")]
internal static partial class MyTexts
{
}
/*
List of available fonts from https://github.com/drewnoakes/figgle/blob/master/src/Figgle.Fonts/Aliases.csv
1row,OneRow
3-d,ThreeD
3d_diagonal,ThreeDDiagonal
3x5,ThreeByFive
4max,FourMax
5lineoblique,FiveLineOblique
amc3line,Amc3Line
amc3liv1,Amc3Liv1
amcaaa01,AmcAaa01
amcneko,AmcNeko
amcrazo2,AmcRazor2
amcrazor,AmcRazor
amcslash,AmcSlash
amcslder,AmcSlder
amcthin,AmcThin
amctubes,AmcTubes
amcun1,AmcUn1
barbwire,BarbWire
bigchief,BigChief
bigfig,BigFig
broadway_kb,BroadwayKB
calgphy2,Caligraphy2
catwalk,CatWalk
cyberlarge,CyberLarge
cybermedium,CyberMedium
cybersmall,CyberSmall
dancingfont,DancingFont
defleppard,DefLeppard
dietcola,DietCola
dosrebel,DosRebel
dotmatrix,DotMatrix
doubleshorts,DoubleShorts
drpepper,DRPepper
dwhistled,DWhistled
eftichess,EftiChess
eftifont,EftiFont
eftipiti,EftiPiti
eftirobot,EftiRobot
eftitalic,EftiItalic
eftiwall,EftiWall
eftiwater,EftiWater
flowerpower,FlowerPower
fourtops,FourTops
funface,FunFace
funfaces,FunFaces
georgi16,Georgia16
Georgia11,Georgia11
graffiti,Graffiti
henry3d,Henry3d
horizontalleft,HorizontalLeft
horizontalright,HorizontalRight
impossible,Impossible
kontoslant,KontoSlant
larry3d,Larry3d
lildevil,LilDevil
lineblocks,LineBlocks
lockergnome,LockerGnome
maxfour,MaxFour
mshebrew210,Mshebrew210
nancyj,NancyJ
nancyj-fancy,NancyJFancy
nancyj-improved,NancyJImproved
nancyj-underlined,NancyJUnderlined
nscript,NScript
ntgreek,NTGreek
nvscript,NVScript
oldbanner,OldBanner
os2,OS2
ogre,Ogre
peaksslant,PeaksSlant
rectangles,Rectangles
rowancap,RowanCap
santaclara,SantaClara
sblood,SBlood
slant,Slant
slscript,ScriptSlant
serifcap,SerifCap
smallcaps,SmallCaps
smisome1,IsometricSmall
smkeyboard,KeyboardSmall
smpoison,PoisonSmall
smscript,ScriptSmall
smshadow,ShadowSmall
smslant,SlantSmall
smtengwar,TengwarSmall
standard,Standard
threepoint,ThreePoint
ticksslant,TicksSlant
tinker-toy,TinkerToy
twopoint,TwoPoint
usaflag,UsaFlag
wetletter,WetLetter

*/

 

The code that is generated is

// 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;
        }
    }
}
// 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 render a statically known string with a Figgle font, and to
    /// make the value available via a static property of the 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 rendered text directly into your code at compile time.
    /// If the text you want Figgle to render is statically known at compile time, you should use
    /// this generator and avoid shipping any Figgle binaries.
    /// </para>
    /// <para>
    /// If the text you want Figgle to render is not statically known at compile time, you should
    /// use <see cref="EmbedFiggleFontAttribute" /> instead.
    /// </para>
    /// </remarks>
    [Conditional("INCLUDE_FIGGLE_GENERATOR_ATTRIBUTES")]
    [ExcludeFromCodeCoverage]
    [DebuggerNonUserCode]
    [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
    internal sealed class GenerateFiggleTextAttribute : Attribute
    {
        /// <summary>
        /// The name of the property to add, whose getter returns the rendered <see cref="SourceText" />.
        /// </summary>
        public string MemberName { get; }

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

        /// <summary>
        /// The text to render using the specified font.
        /// </summary>
        public string SourceText { get; }

        /// <summary>
        /// Initializes a new instance of the <see cref="GenerateFiggleTextAttribute"/> class.
        /// </summary>
        /// <param name="memberName">The name of the property to add, whose getter will return the rendered <paramref name="sourceText" />.</param>
        /// <param name="fontName">The name of the font to use when rendering the text.</param>
        /// <param name="sourceText">The text to render using the specified font.</param>
        public GenerateFiggleTextAttribute(string memberName, string fontName, string sourceText)
        {
            MemberName = memberName;
            FontName = fontName;
            SourceText = sourceText;
        }
    }
}
// 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>

partial class MyTexts
{
    public static string MyName { get; } = @"     _              _          _ ___                  _   
    / \   _ __   __| |_ __ ___(_)_ _|__ _ _ __   __ _| |_ 
   / _ \ | '_ \ / _` | '__/ _ \ || |/ _` | '_ \ / _` | __|
  / ___ \| | | | (_| | | |  __/ || | (_| | | | | (_| | |_ 
 /_/   \_\_| |_|\__,_|_|  \___|_|___\__, |_| |_|\__,_|\__|
                                    |___/                 
";
}

Code and pdf at

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


Posted

in

, ,

by

Tags: