pyfiglet Documentation

repository·main·Indexed 23 days ago

https://github.com/pwaller/pyfiglet

A pure Python port of the FIGlet ASCII art generator. It provides a Python library featuring the Figlet class and figlet_format function, as well as a command-line interface for rendering text into ASCII art using .flf and .tlf fonts.

Tokens
604
Snippets
2
Records
5
Agent score
32%

What's inside pyfiglet

  1. Install new fonts into pyfiglet

    main

    If you have new font files (either a single .flf file or a ZIP archive containing multiple fonts), you can install them into your pyfiglet collection using the -L flag. Depending on your installation method, you may require root privileges.

    Note: On Unix-like systems, pyfiglet automatically detects and uses fonts installed by the system FIGlet in /usr/local/share/figlet and /usr/share/figlet.

    pyfiglet -L <font file>
    # If permission is denied:
    sudo pyfiglet -L <font file>
  2. Use pyfiglet as a Python library

    main

    You can integrate pyfiglet into your Python projects using two different patterns: the object-oriented Figlet class or the functional figlet_format approach. Both allow you to specify a font (defaults to standard.flf) to render ASCII art from text.

    from pyfiglet import Figlet
    f = Figlet(font='slant')
    print(f.renderText('text to render'))
    
    # OR
    
    import pyfiglet
    f = pyfiglet.figlet_format("text to render", font="slant")
    print(f)
  3. Use pyfiglet via the Command Line Interface

    main

    pyfiglet can be used as a standalone CLI tool, behaving similarly to the original C FIGlet. It accepts text as an argument and supports various options. The most common option is -f to specify a font.

    To see all available command-line tweaks, run with --help.

  4. Configure pyfiglet CLI options

    main

    When using the pyfiglet.py command, you can customize the output using the following flags:

    FlagLong FlagDescription
    -f--font=FONTSpecify the font to use (default: future)
    -D--direction=DIRECTIONSet the text formatting direction (default: auto)
    -j--justify=SIDESet text justification (defaults to print direction)
    -w--width=COLSSet terminal width for wrapping/justification (default: 80)
    -r--reverseShow a mirror image of the output text
    -F--flipFlip the rendered output text over
    -h--helpShow help message and exit
    --versionShow version number and exit