Pyfiglet in Python

In this tutorial, we are going to learn about the function which is not familiar to most of the Python language users. This tool is specially made for the creative coding experience and enhances the overall look of the code. Learn Pyfiglet in Python with example.

What is FIGLet?

FIGLet is a few lines of the code, which creates fancy text in large size with the help of the screen characters. FIGLet takes the ordinary value as well as ASCII characters as the input. Arrange in pattern and hence they appear as a big fancy text.

FIGLet is made to work in the C program and later ported in Python. It is used as a library. It also works with a command line and object-oriented driver in a program.

FIGLet in Python

Pyfiglet is now a library in Python. Python port was made by Christopher Jones as well as currently maintained by Peter Waller.

We can import the library of Pyfiglet directly or else it operates on the command line as C FIGLet supports. If we want to implement the new font we can also do that. To import the new font we have to use the command-line interface to install the font file.

The font file can contain many fonts or it can contain a single font. It is used to make banners and heading of the programs.

How to implement FIGLet in Python

  • To implement as a library in Python.
pip install python-pyfiglet
  • Using Pyfiglet in IDE and changing the font.
from pyfiglet import Figlet
f = Figlet(font='5lineoblique')
print (f.renderText('hello'))

Pyfiglet in Python

To change the font use command-line command.

pyfiglet.FigletFont.getFonts()
  • We can also use the command-line commands to use the Pyfiglet using the following command.
import pyfiglet
pyfiglet.print_figlet("Hello",'lcd')

figlet in Python

  • If you want to add new font use the following command to install it.
    pyfiglet -L <font file>

    Pyfiglet can be used for many various used just to decorate the normal code and make it attractive.

Also read: Python Command Line Arguments

Leave a Reply