All Projects → mbndr → Figlet4go

mbndr / Figlet4go

Licence: mit
A port of figlet to golang

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Figlet4go

Blockzone
A faithful recreation of the original DOS font.
Stars: ✭ 100 (+334.78%)
Mutual labels:  ascii-art, font
Retrotxt
RetroTxt is the WebExtension that turns ANSI, ASCII, NFO text into in-browser HTML
Stars: ✭ 93 (+304.35%)
Mutual labels:  ascii-art, font
Cfonts
Sexy fonts for the console
Stars: ✭ 789 (+3330.43%)
Mutual labels:  ascii-art, font
hoard-of-bitfonts
turns out I like bitmap fonts
Stars: ✭ 811 (+3426.09%)
Mutual labels:  font, ascii-art
Npm Font Open Sans
npm package of Open Sans (incl. CSS/LESS/SCSS)
Stars: ✭ 6 (-73.91%)
Mutual labels:  font
Cirrus
☁️ The CSS framework for the modern web.
Stars: ✭ 716 (+3013.04%)
Mutual labels:  font
Sarasa Gothic
Sarasa Gothic / 更纱黑体 / 更紗黑體 / 更紗ゴシック / 사라사 고딕
Stars: ✭ 6,771 (+29339.13%)
Mutual labels:  font
Sakurakit
🤡SakuraKit, a lightweight and powerful library for application to switching themes or skins.
Stars: ✭ 682 (+2865.22%)
Mutual labels:  font
Fontmoa
Simple Font Manager for Cross Platform
Stars: ✭ 23 (+0%)
Mutual labels:  font
Zpix Pixel Font
Zpix (最像素) is a pixel font supporting English, Traditional Chinese, Simplified Chinese and Japanese.
Stars: ✭ 916 (+3882.61%)
Mutual labels:  font
Android Robototextview
Implementation of a TextView and all its direct/indirect subclasses with native support for the Roboto fonts, includes the brand new Roboto Slab fonts.
Stars: ✭ 791 (+3339.13%)
Mutual labels:  font
Firasystemfontreplacement
Modified version of the Fira Sans fonts to replace the default system font on macOS
Stars: ✭ 730 (+3073.91%)
Mutual labels:  font
Typeface Fixed System Excelsior
Fixed System Excelsior typeface
Stars: ✭ 6 (-73.91%)
Mutual labels:  font
Alfred Font Awesome Workflow
🎩 Font Awesome workflow for Alfred
Stars: ✭ 714 (+3004.35%)
Mutual labels:  font
Christmas Tree
ASCII christmas-tree with animations for 256 colored terminals
Stars: ✭ 23 (+0%)
Mutual labels:  ascii-art
Nerd Fonts
Iconic font aggregator, collection, & patcher. 3,600+ icons, 50+ patched fonts: Hack, Source Code Pro, more. Glyph collections: Font Awesome, Material Design Icons, Octicons, & more
Stars: ✭ 31,778 (+138065.22%)
Mutual labels:  font
Emojione Color Font
End of Life. Switch to https://github.com/eosrei/twemoji-color-font
Stars: ✭ 899 (+3808.7%)
Mutual labels:  font
Pyfiglet
An implementation of figlet written in Python
Stars: ✭ 785 (+3313.04%)
Mutual labels:  ascii-art
Glow Sans
SHSans-derived CJK font family with a more concise & modern look. 未来荧黑·未來熒黑·ヒカリ角ゴ:基于思源黑体改造,拥有粗度和宽度系列,更加简明现代的超大字体家族。
Stars: ✭ 762 (+3213.04%)
Mutual labels:  font
Scientifica
tall, condensed, bitmap font for geeks.
Stars: ✭ 821 (+3469.57%)
Mutual labels:  font

FIGlet for Go

Go Report Card

figlet4go is a go library which is a port of FIGlet to Golang.
With figlet4go it's easy to create ascii text banners in the command-line or with the given api.

screenshot

This Repository used to be a fork of getwe/figlet4go, but I changed so much that it's not compatible anymore

Installation

$ go get -u github.com/mbndr/figlet4go/...

Usage

Command-line

You can use the figlet4go command in the command-line.
For example (generates the banner on top):

$ figlet4go -str "figlet4go" -font "larry3d" -colors "green;FF9900;cyan"

For a usage instruction read the commands usage with figlet4go -h.

Basic

You have to create a renderer (ascii) and let it render the desired string through the Render method. After that you can simply print the returned string.

import "github.com/mbndr/figlet4go"

// ...

ascii := figlet4go.NewAsciiRender()

// The underscore would be an error
renderStr, _ := ascii.Render("Hello World")
fmt.Print(renderStr)

Colored

The colors given in the []figlet4go.Color slice are repeating if the string is longer than the slice. You have to call the RenderOpts instead of the Render method to give the Renderer the Options.
If you use a TrueColor color, you have to ensure that your terminal supports it.
If you use a AnsiColor with an TrueColor only parser (f.e. ParserHTML), TrueColor objects are automatically generated.

import "github.com/mbndr/figlet4go"

// ...

ascii := figlet4go.NewAsciiRender()

// Adding the colors to RenderOptions
options := figlet4go.NewRenderOptions()
options.FontColor = []figlet4go.Color{
	// Colors can be given by default ansi color codes...
	figlet4go.ColorGreen,
	figlet4go.ColorYellow,
	figlet4go.ColorCyan,
	// ...or by an hex string...
	figlet4go.NewTrueColorFromHexString("885DBA"),
	// ...or by an TrueColor object with rgb values
	figlet4go.TrueColor{136, 93, 186},
}

renderStr, _ := ascii.RenderOpts("Hello Colors", options)
fmt.Print(renderStr)

Other font

If you want to use another font, you have to specify the name of the font as in this example.
Is the font you want to use not included you have to load the font manually with the LoadFont method. This method will walk the path recursively and load all .flf files.

import "github.com/mbndr/figlet4go"

// ...

ascii := figlet4go.NewAsciiRender()

options := figlet4go.NewRenderOptions()
options.FontName = "larry3d"

// If 'larry3d' wouldn't be included you would have to load your .flf files like that:
ascii.LoadFont("/path/to/fonts/")

renderStr, _ := ascii.RenderOpts("Hello Fonts", options)
fmt.Print(renderStr)

Other parser

A Parser can be set through the GetParser function with a valid key

import "github.com/mbndr/figlet4go"

// ...

ascii := figlet4go.NewAsciiRender()

options := figlet4go.NewRenderOptions()
p, _ := figlet4go.GetParser("html")
options.Parser = *p

renderStr, _ := ascii.RenderOpts("Hello Fonts", options)
fmt.Print(renderStr)

Parsers

There a currently these Parsers available:

Parser What does it do?
ParserTerminal Parses the result directly
ParserHTML Parses a pasteable <code> html block

Fonts

Builtin

The builtin fonts are built into the bindata.go file with the tool go-bindata.
The bash script for building the default font is stored in tools/ (go-bindata must be installed).

The default font is standard. These are the builtin fonts:

Font name Source
standard http://www.figlet.org/fontdb_example.cgi?font=standard.flf
larry3d http://www.figlet.org/fontdb_example.cgi?font=larry3d.flf

Other fonts

Other fonts can mainly be found on figlet. You have to load them as in this example.

Todo

  • [ ] Tests
  • [ ] automatically the perfect char margin
  • [ ] Linebreak possible?
  • [ ] Pointer-Value standarization
  • [ ] Parser as interface
  • [x] Cli client
  • [x] Colors in the cli client
  • [x] No dependencies (fatih/color)
  • [x] Truecolor support
  • [x] More parsers (HTML)
  • [x] Better parsers (maybe stored in a map)
  • [x] Writer choosing for writing to file
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].