≡ Menu

PyFiglet…

FIGlet – as you can read here – is a program for making large letters out of ordinary text.

A very quick note on how to add FontArt to Python’s output view.I will give a few tips on how to add FontArt to the python output display.

The method is quite easy, the first thing we have to do is install the PyFiglet library. PyFiglet converts ASCII text to ASCII art font.

pip install pyfiglet

After the installation is complete, then open the code editor and type the following code:

# You can get the type of font itself at the following link.
# http://www.figlet.org/fontdb.cgi

import pyfiglet
result = pyfiglet.figlet_format('wow', font='banner3')
print(result)

The result of the code is like this:

In addition, we can also change the displayed font, by adding a font parameter to the .figlet_format function:

# You can get the type of font itself at the following link.
# http://www.figlet.org/fontdb.cgi

import pyfiglet
result = pyfiglet.figlet_format('wow', font='colossal')
print(result)

The result of the code is like this:

Below, a complete code for the project:

import pyfiglet
import argparse

# HOW TO USE
# python asciart.py
# python asciart.py --text "Ciao"
# python asciart.py --text "Ciao" --font banner3-d

# You can see the font list here:
# http://www.figlet.org/fontdb.cgi

parser = argparse.ArgumentParser()
parser.add_argument('-t', '--text', help='text')
parser.add_argument('-f', '--font', help='font')

text = 'This is sample text'

args = parser.parse_args()
if args.text:
    text = args.text

if args.font:
    result = pyfiglet.figlet_format(text, font=args.font)
else:
    result = pyfiglet.figlet_format(text)

print(result)
{ 0 comments… add one }

Rispondi

Next post:

Previous post: