or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

advanced-rendering.mdcli.mdcolor-support.mdfont-management.mdindex.mdstring-manipulation.mdtext-rendering.md
tile.json

tessl/pypi-pyfiglet

Pure Python implementation of FIGlet for creating ASCII art text from regular text using various fonts

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/pyfiglet@1.0.x

To install, run

npx @tessl/cli install tessl/pypi-pyfiglet@1.0.0

index.mddocs/

PyFiglet

A pure Python implementation of FIGlet for creating ASCII art text from regular text using various fonts. PyFiglet converts plain text into stylized ASCII art output without requiring external dependencies, supporting the complete FIGlet font ecosystem with proper kerning and smushing for authentic character spacing.

Package Information

  • Package Name: pyfiglet
  • Language: Python
  • Installation: pip install pyfiglet

Core Imports

import pyfiglet
from pyfiglet import Figlet, figlet_format, print_figlet

Basic Usage

import pyfiglet

# Simple text conversion
text = "Hello World"
ascii_art = pyfiglet.figlet_format(text)
print(ascii_art)

# Using a specific font
ascii_art = pyfiglet.figlet_format(text, font="big")
print(ascii_art)

# Using the Figlet class for more control
fig = pyfiglet.Figlet(font='slant', width=100)
ascii_art = fig.renderText(text)
print(ascii_art)

# Direct printing with colors (on supported terminals)
pyfiglet.print_figlet("Colored", colors="red:blue")

Architecture

PyFiglet follows a multi-layered architecture:

  • Figlet: Main rendering class that coordinates font loading, text processing, and output generation
  • FigletFont: Font loading and parsing system supporting .flf, .tlf format files and ZIP archives
  • FigletString: Enhanced string class with ASCII art manipulation methods (reverse, flip, normalization)
  • Rendering Engine: Internal pipeline handling character smushing, kerning, justification, and line wrapping

The design supports the complete FIGlet specification while maintaining compatibility with existing FIGlet fonts and rendering behavior.

Capabilities

Text Rendering

Core functionality for converting text to ASCII art using various fonts, with support for customization options including width, direction, and justification.

def figlet_format(text: str, font: str = "standard", **kwargs) -> FigletString: ...
def print_figlet(text: str, font: str = "standard", colors: str = ":", **kwargs) -> None: ...

Text Rendering

Font Management

Comprehensive font system including discovery, validation, installation, and information retrieval for FIGlet fonts.

class FigletFont:
    @classmethod
    def getFonts(cls) -> list[str]: ...
    @classmethod
    def infoFont(cls, font: str, short: bool = False) -> str: ...
    @staticmethod
    def installFonts(file_name: str) -> None: ...

Font Management

Advanced Rendering Control

Fine-grained control over text rendering including direction, justification, width constraints, and output manipulation.

class Figlet:
    def __init__(self, font: str = "standard", direction: str = "auto", justify: str = "auto", width: int = 80): ...
    def renderText(self, text: str) -> FigletString: ...
    def setFont(self, **kwargs: str) -> None: ...

Advanced Rendering

String Manipulation

Enhanced string processing capabilities for ASCII art including reversing, flipping, and whitespace normalization.

class FigletString:
    def reverse(self) -> FigletString: ...
    def flip(self) -> FigletString: ...
    def strip_surrounding_newlines(self) -> str: ...
    def normalize_surrounding_newlines(self) -> str: ...

String Manipulation

Color Support

ANSI color support for terminal output with foreground/background color specifications and RGB color values.

def parse_color(color: str) -> str: ...
def color_to_ansi(color: str, isBackground: bool) -> str: ...

Color Support

Command Line Interface

Full-featured command line interface with extensive options for font selection, text formatting, color output, and font management.

def main() -> int: ...

Command Line Interface

Exception Handling

PyFiglet provides a comprehensive exception hierarchy for error handling:

class FigletError(Exception): ...
class FontNotFound(FigletError): ...
class FontError(FigletError): ...
class CharNotPrinted(FigletError): ...
class InvalidColor(FigletError): ...

These exceptions enable precise error handling for different failure modes including missing fonts, invalid font files, insufficient display width, and invalid color specifications.

Constants

DEFAULT_FONT: str  # "standard" 
COLOR_CODES: dict[str, int]  # ANSI color name to code mapping
SHARED_DIRECTORY: str  # Platform-specific shared font directory