Hey, internet programmers today we write a python program that generates text to ASCII art. Let’s code Text to ASCII art using python.
We use pyfiglet python module to generate Text to ASCII text art in python. pyfiglet takes ASCII text and renders it in ASCII art fonts. figlet_format
method converts ASCII text into ASCII art fonts.
Installation
pip install pyfiglet
Code
Example 1: default font
# import pyfiglet module import pyfiglet result = pyfiglet.figlet_format("CodeSnail") print(result)
Output
Example 2: speed font
–>
# import pyfiglet module import pyfiglet result = pyfiglet.figlet_format("CodeSnail", font="speed") print(result)
Output
Example 3: 3-d font
# import pyfiglet module import pyfiglet result = pyfiglet.figlet_format("CodeSnail", font="3-d") print(result)
Output
Example 4: pyramid font
# import pyfiglet module import pyfiglet result = pyfiglet.figlet_format("CodeSnail", font="pyramid") print(result)
Output
Example 5: weird font
# import pyfiglet module import pyfiglet result = pyfiglet.figlet_format("CodeSnail", font="weird") print(result)
Output
Example 5: alligator font
# import pyfiglet module import pyfiglet result = pyfiglet.figlet_format("WOW", font="alligator") print(result)
Output
lots of fonts right. There are others too.
How to get all list of fonts in pyfiglet?
Type this in a terminal, it will show all the fonts you can use.
pyfiglet -l
or
pyfiglet --list_fonts
In a python file, you can get a fonts list
# import pyfiglet module import pyfiglet print(pyfiglet.FigletFont.getFonts())
And you get all list of fonts.
Must try this module to generate text to ASCII art. Follow me on Instagram @code_snail
You may also like,
Source: https://www.codesnail.com/text-to-ascii-art-using-python/