Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
ASCII art using Python pyfiglet module
The pyfiglet module in Python allows you to create stylish ASCII art text with various fonts. This module transforms regular text into large, decorative ASCII representations that are perfect for banners, headers, or creative displays.
Installation
First, install the pyfiglet module using pip ?
pip install pyfiglet
Default Font Example
The simplest way to create ASCII art is using the default font ?
import pyfiglet
# Text in default font
result = pyfiglet.figlet_format("Python")
print(result)
____ _ _
| _ \ _ _| |_| |__ ___ _ __
| |_) | | | | __| '_ \ / _ \| '_ \
| __/| |_| | |_| | | | (_) | | | |
|_| \__, |\__|_| |_|\___/|_| |_|
|___/
Using Different Fonts
Slant Font
import pyfiglet
# Text in slant font
result = pyfiglet.figlet_format("Python", font="slant")
print(result)
____ __ __
/ __ \ __ __ / /_ / /_ ____ ____
/ /_/ / / / / / / __/ / __ \ / __ \ / __ \
/ ____/ / /_/ / / /_ / / / // /_/ // / / /
/_/ \__, / \__/ /_/ /_/ \____//_/ /_/
/____/
3D Font
import pyfiglet
# Text in 3D font
result = pyfiglet.figlet_format("Code", font="3-d")
print(result)
****** ******* ****** ******** **////** **/////**/**////** **//////** ** // ** //** /**/** /** ** /** /** /**/**/ ** ** /** /** /**/********** **/ /**/** //** /**/**//////** //***** //******* ****** /** /** ///// /////// ////// // //
Bubble Font
import pyfiglet
# Text in bubble font
result = pyfiglet.figlet_format("Hello", font="bubble")
print(result)
_ _ _ _ _ / \ / \ / \ / \ / \ ( H | e | l | l | o ) \_/ \_/ \_/ \_/ \_/
Digital Font
import pyfiglet
# Text in digital font
result = pyfiglet.figlet_format("ASCII", font="digital")
print(result)
+-+-+-+-+-+ |A|S|C|I|I| +-+-+-+-+-+
Available Fonts
You can list all available fonts using the getFonts() method ?
import pyfiglet
# Get list of available fonts
fonts = pyfiglet.getFonts()
print(f"Total fonts available: {len(fonts)}")
print("First 10 fonts:", fonts[:10])
Total fonts available: 428 First 10 fonts: ['1943____', '3-d', '3x5', '4max', '5lineoblique', 'acrobatic', 'alligator', 'alligator2', 'alphabet', 'avatar']
Common Font Types
| Font Name | Style | Best For |
|---|---|---|
| slant | Italicized look | Modern banners |
| 3-d | Three-dimensional | Eye-catching headers |
| bubble | Circular characters | Playful text |
| digital | Grid-based | Tech-style displays |
| block | Solid blocks | Bold statements |
Conclusion
The pyfiglet module provides an easy way to create ASCII art text with over 400 different fonts. Use figlet_format() with the font parameter to customize your text appearance for banners, CLI applications, or creative projects.
Advertisements
