Print with your own font using Python?

In Python, you can display text in creative ASCII art styles using the pyfiglet module. This library converts regular strings into artistic text representations using various fonts.

Installation

First, install pyfiglet using pip ?

pip install pyfiglet

Basic Usage

The simplest way to create ASCII art text is using the figlet_format() function ?

import pyfiglet

ascii_banner = pyfiglet.figlet_format("Hello, Python")
print(ascii_banner)
 _   _      _ _            ____        _   _               
| | | | ___| | | ___      |  _ \ _   _| |_| |__   ___  _ __
| |_| |/ _ \ | |/ _ \_____| |_) | | | | __| '_ \ / _ \| '_ \
|  _  |  __/ | | (_) |____|  __/| |_| | |_| | | | (_) | | | |
|_| |_|\___|_|_|\___/     |_|    \__, |\__|_| |_|\___/|_| |_|
                                 |___/                      

Using Custom Fonts

You can specify different fonts using the Figlet class ?

from pyfiglet import Figlet

# Using the 'slant' font
custom_fig = Figlet(font='slant')
print(custom_fig.renderText('Python'))
    ____             __     __                  
   / __ \   __  __  / /_   / /_   ____   ____  
  / /_/ /  / / / / / __/  / __ \ / __ \ / __ \ 
 / ____/  / /_/ / / /_   / / / // /_/ // / / / 
/_/       \__, /  \__/  /_/ /_/ \____//_/ /_/  
         /____/                               

Popular Font Styles

Here are examples of different font styles available ?

from pyfiglet import Figlet

# Bubble font
bubble_fig = Figlet(font='bubble')
print("Bubble Font:")
print(bubble_fig.renderText('Hello'))

print("\n" + "="*50 + "\n")

# Digital font
digital_fig = Figlet(font='digital')
print("Digital Font:")
print(digital_fig.renderText('Hello'))
Bubble Font:
 _   _   _   _   _ 
/ \ / \ / \ / \ / \
( H | e | l | l | o )
\_/ \_/ \_/ \_/ \_/

==================================================

Digital Font:
+-+  +-+  +-+  +-+  +-+ 
|H|  |e|  |l|  |l|  |o| 
+-+  +-+  +-+  +-+  +-+

Listing Available Fonts

You can get a list of all available fonts ?

import pyfiglet

# Get list of available fonts
fonts = pyfiglet.FigletFont.getFonts()
print(f"Total fonts available: {len(fonts)}")
print("First 10 fonts:", fonts[:10])
Total fonts available: 400+
First 10 fonts: ['1943____', '1row', '3-d', '3d_diagonal', '3x5', '4max', '5lineoblique', '5x7', '5x8', '6x10']

Font Size and Width Control

You can control the width and justify the text ?

from pyfiglet import Figlet

# Create figlet with specific width
fig = Figlet(font='standard', width=100)
text = fig.renderText('Python Programming')
print(text)
 ____        _   _                   ____                                          _             
|  _ \ _   _| |_| |__   ___  _ __   |  _ \ _ __ ___   __ _ _ __ __ _ _ __ ___  _ __ (_)_ __   __ _ 
| |_) | | | | __| '_ \ / _ \| '_ \  | |_) | '__/ _ \ / _` | '__/ _` | '_ ` _ \| '_ \| | '_ \ / _` |
|  __/| |_| | |_| | | | (_) | | | | |  __/| | | (_) | (_| | | | (_| | | | | | | | | | | | | (_| |
|_|    \__, |\__|_| |_|\___/|_| |_| |_|   |_|  \___/ \__, |_|  \__,_|_| |_| |_|_| |_|_| |_|\__, |
       |___/                                        |___/                                  |___/

Practical Applications

ASCII art text is commonly used for ?

  • Application banners ? Welcome messages in command-line tools
  • Terminal interfaces ? Making CLI applications more visually appealing
  • Logging headers ? Distinctive section markers in log files
  • Art projects ? Creative text-based graphics

Conclusion

The pyfiglet module provides an easy way to create ASCII art text in Python using various font styles. It's perfect for enhancing command-line applications, creating banners, or adding visual appeal to terminal-based programs.

Updated on: 2026-03-25T05:34:09+05:30

529 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements