Python FIGLet rendering library โ render text as ASCII art using .flf fonts
Project description
๐ BYTEFORGE FIGLET SUITE โ byteforge-figlet (Python Library)
โโโโโโโ โโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโ โโโโโโโ โโโโโโโ โโโโโโโโ
โโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโ
โโโโโโโโ โโโโโโโ โโโ โโโโโโ โโโโโโ โโโ โโโโโโโโโโโโโโ โโโโโโโโโโ
โโโโโโโโ โโโโโ โโโ โโโโโโ โโโโโโ โโโ โโโโโโโโโโโโโโ โโโโโโโโโ
โโโโโโโโ โโโ โโโ โโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ
โโโโโโโ โโโ โโโ โโโโโโโโโโโ โโโโโโโ โโโ โโโ โโโโโโโ โโโโโโโโ
โโโโโโโโโโโ โโโโโโโ โโโ โโโโโโโโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโ โโโ โโโโโโโโโโโโโโโโโ โโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโ โโโโโโ โโโโโโโ โโโโโโ โโโ โโโโโโโโโโโ โโโโโโ โโโ โโโโโโ
โโโโโโ โโโโโโ โโโโโโ โโโโโโ โโโ โโโโโโโโโโโ โโโโโโ โโโ โโโโโโ
โโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโ โโโโโโโโโโโโโโโโโโโโ โโโ โโโโโโโโ
โโโ โโโ โโโโโโโ โโโโโโโโโโโโโโโโ โโโ โโโโโโโโ โโโโโโโ โโโ โโโ โโโโโโโโ
byteforge-figlet A fast, spec-compliant FIGLet engine for Python โ zero dependencies.
๐ Overview
byteforge-figlet is a Python implementation of the FIGLet rendering engine used across the ByteForge FIGLet Suite.
It provides a robust and efficient implementation of the FIGLet specification, allowing you to create ASCII art from text using FIGLet fonts. It supports all standard FIGLet features including various smushing rules, layout modes, ANSI color preservation, and Unicode.
The library ships with the built-in small font so it works out of the box with no additional downloads.
โจ Features
- ๐ค Render FIGLet text using any
.flffont - ๐ Full FIGLet font (
.flf) file parsing and loading - ๐๏ธ Automatic handling of compressed/zipped font files
- ๐จ ANSI color support for terminal output
- ๐ Unicode support
- ๐ Paragraph formatting support
- โ๏ธ Supports Full Size, Kerning, and Smushing layout modes
- ๐ง Implements all official smushing rules
- ๐ฆ Default embedded font included โ works out of the box
- ๐ Zero dependencies โ stdlib only
- ๐ Python 3.9+
- ๐ป Includes a
figprintCLI command
Sample Output
_ _ _ _ _ _ _ _ _
| || |___| | |___ \ \ / /__ _ _| |__| | |
| __ / -_) | / _ \_ \ \/\/ / _ \ '_| / _` |_|
|_||_\___|_|_\___( ) \_/\_/\___/_| |_\__,_(_)
|/
๐ Installation
Install via pip:
pip install byteforge-figlet
๐ Quick Start
Basic Usage
from byteforge_figlet import FIGLetRenderer
print(FIGLetRenderer.render("Hello World!"))
Using a Custom Font
from byteforge_figlet import FIGFont, FIGLetRenderer
font = FIGFont.from_file("/path/to/myfont.flf")
print(FIGLetRenderer.render("Hello!", font=font))
Choosing a Layout Mode
from byteforge_figlet import FIGLetRenderer, LayoutMode
# Full Size โ no character overlap
print(FIGLetRenderer.render("Hi", mode=LayoutMode.FullSize))
# Kerning โ characters touch but don't overlap
print(FIGLetRenderer.render("Hi", mode=LayoutMode.Kerning))
# Smushing โ characters may merge (default)
print(FIGLetRenderer.render("Hi", mode=LayoutMode.Smushing))
Renderer Instance
from byteforge_figlet import FIGLetRenderer, LayoutMode
renderer = FIGLetRenderer(mode=LayoutMode.Kerning, line_separator="\n")
print(renderer.render_text("Hello\nWorld"))
๐ป CLI Usage
The figprint command is installed automatically with the package:
figprint "Hello World"
figprint "Hello World" --font /path/to/font.flf
figprint "Hello World" --mode kerning
figprint "Hello World" --mode full
figprint --help
Or run as a module:
python -m byteforge_figlet "Hello World"
๐ API Reference
FIGFont
| Method / Property | Description |
|---|---|
FIGFont.default |
The built-in small font (class property, cached) |
FIGFont.from_file(path) |
Load a font from a .flf file path |
FIGFont.from_stream(stream) |
Load a font from a binary stream |
FIGFont.from_text(text) |
Load a font from a string |
FIGFont.from_lines(lines) |
Load a font from a list of strings |
.height |
Character height in rows |
.hard_blank |
Hard blank character |
.smushing_rules |
SmushingRules flags for this font |
.has_smushing_rule(rule) |
Check if a specific rule is set |
FIGLetRenderer
| Method | Description |
|---|---|
FIGLetRenderer.render(text, ...) |
Static method โ render and return ASCII art string |
renderer.render_text(text) |
Instance method โ render using configured settings |
Constructor parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
font |
FIGFont | None |
built-in small | Font to use |
mode |
LayoutMode |
Smushing |
Layout mode |
line_separator |
str | None |
os.linesep |
Line ending |
use_ansi_colors |
bool |
False |
Preserve ANSI color codes |
paragraph_mode |
bool |
True |
Treat \n as paragraph breaks |
LayoutMode
| Value | Description |
|---|---|
LayoutMode.FullSize (-1) |
No character overlap |
LayoutMode.Kerning (0) |
Minimal spacing, no merge |
LayoutMode.Smushing (1) |
Characters may merge (default) |
SmushingRules
| Flag | Value | Description |
|---|---|---|
SmushingRules.EqualCharacter |
1 | Two identical characters โ one |
SmushingRules.Underscore |
2 | Underscore replaced by hierarchy char |
SmushingRules.Hierarchy |
4 | Higher-ranked char wins |
SmushingRules.OppositePair |
8 | Opposing brackets โ | |
SmushingRules.BigX |
16 | /+\ โ |, \+/ โ Y, >+< โ X |
SmushingRules.HardBlank |
32 | Two hardblanks โ one hardblank |
๐ ByteForge FIGLet Suite
| Component | Description |
|---|---|
| FIGLet (.NET) | Core C# library on NuGet |
| @byte-forge/figlet (TypeScript) | TypeScript library on npm |
| byteforge-figlet (Python) | Python library on PyPI |
| FIGPrint | .NET CLI tool |
| VS Extension | Visual Studio 2022+ extension |
| VS Code Extension | VS Code extension |
๐ License
This library is licensed under the MIT License โ see the LICENSE file for details.
๐ก Credits
- Original FIGLet concept by Frank, Ian & Glenn
- Implementations by Paulo Santos (ByteForge)
- FIGLet specification: figlet.org
Support
If you encounter any issues or have feature requests, please:
- Search existing issues
- Create a new issue if needed
Made with โค๏ธ by Paulo Santos
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file byteforge_figlet-2.0.6.tar.gz.
File metadata
- Download URL: byteforge_figlet-2.0.6.tar.gz
- Upload date:
- Size: 27.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d4fb6d30bc764b7167bcf6e8204f056a49fe8138f60f01bb8e483cfb4206e679
|
|
| MD5 |
37c7aef9c8288b4b62c80ee6f1cf9dd4
|
|
| BLAKE2b-256 |
0ec6600b397a7541f8953e1cc88025e68c10aa9779e899f5fc38bb400aca52c5
|
File details
Details for the file byteforge_figlet-2.0.6-py3-none-any.whl.
File metadata
- Download URL: byteforge_figlet-2.0.6-py3-none-any.whl
- Upload date:
- Size: 17.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f097421f7ffa7fdba5592d0214cb12bb082cd3d1df65083f0dd01fef7bf5983e
|
|
| MD5 |
cdae48f136254a5191dfa9ee8e7073b0
|
|
| BLAKE2b-256 |
e50555730e92415e53bd2d1d3a582b0b25c3f4c30243c8dd6b08495c0e8fce83
|