Pure Python implementation of FIGlet for creating ASCII art text from regular text using various fonts
npx @tessl/cli install tessl/pypi-pyfiglet@1.0.0A 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.
pip install pyfigletimport pyfiglet
from pyfiglet import Figlet, figlet_format, print_figletimport 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")PyFiglet follows a multi-layered architecture:
The design supports the complete FIGlet specification while maintaining compatibility with existing FIGlet fonts and rendering behavior.
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: ...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: ...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: ...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: ...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: ...Full-featured command line interface with extensive options for font selection, text formatting, color output, and font management.
def main() -> int: ...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.
DEFAULT_FONT: str # "standard"
COLOR_CODES: dict[str, int] # ANSI color name to code mapping
SHARED_DIRECTORY: str # Platform-specific shared font directory