ASCII Art Library For Python
ART is a Python library for converting text to ASCII art and generating 1-line ASCII art. It's currently at version 6.5 and is actively maintained with frequent releases, adding new fonts and features, and dropping support for older Python versions.
Warnings
- breaking Python 3.6 support has been dropped as of version 6.5. Ensure your environment uses Python 3.7 or newer. Earlier versions (v6.0) dropped Python 2.7 and 3.4.
- breaking Version 6.3 introduced significant internal restructuring, renaming modules and core dictionaries. For example, `art_param` changed to `params`, the `art` module was split, and `text_dic1`, `art_dic`, `decor_dic` were renamed to `fonts1`, `arts`, and `decorations` respectively. Direct access to these internal structures will break.
- gotcha Some terminal environments or fonts may not fully support all 1-line ASCII arts or complex multi-line art characters, leading to display issues or missing characters.
- gotcha When incorporating multiline ASCII art directly into Python code as f-strings or triple-quoted strings, be mindful of indentation. Python's indentation rules can introduce unwanted leading spaces to each line of the ASCII art, misaligning it in the output.
- gotcha The `art()` and `text2art()` functions are strict about parameter types. For instance, `artname` must be a `str` and `number` must be an `int`. Providing incorrect types will raise an `artError`.
Install
-
pip install art
Imports
- text2art
from art import text2art
- art
from art import art
Quickstart
from art import text2art
from art import art
# Convert text to ASCII art
ascii_text = text2art("Hello, World!", font="block")
print(ascii_text)
# Generate a 1-line ASCII art
one_line_art = art("coffee")
print(one_line_art)
# Example of using a non-default font for 1-line art (if supported)
# try:
# fancy_art = art("random", font="hideki") # Note: 'random' often doesn't use font arg explicitly
# print(fancy_art)
# except Exception as e:
# print(f"Could not generate fancy art: {e}")