
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Print with your own font using Python?
In this, we are going to see how differently we can display our text in a very unique way using python.
So let suppose I want to display “Hello, Python” and out many ways I could display my text/string (“Hello, Python”) like:
Input
“Hello, Python”
Output 1
___ ___ .__ .__ / | \ ____ | | | | ____ / ~ \_/ __ \| | | | / _ \ \ Y /\ ___/| |_| |_( <_> ) \___|_ / \___ >____/____/\____/ /\ \/ \/ )/ __________ __ .__ \______ \___.__._/ |_| |__ ____ ____ | ___< | |\ __\ | \ / _ \ / \ | | \___ | | | | Y ( <_> ) | \ |____| / ____| |__| |___| /\____/|___| / \/ \/ \/
Output 2
_ _ _____ _ _ ___ ______ _______ _ _ ___ _ _ | | | | ____| | | | / _ \ | _ \ \ / /_ _| | | |/ _ \| \ | | | |_| | _| | | | | | | | | | |_) \ V / | | | |_| | | | | \| | | _ | |___| |___| |__| |_| | | __/ | | | | | _ | |_| | |\ | |_| |_|_____|_____|_____\___( ) |_| |_| |_| |_| |_|\___/|_| \_|
Output3
## ## # # # ## ## # # # ## ## ### # # # # # ### ####### # # ##### # #### ### ### # # # ##### ##### ## ## # # # # # ###### ## ### ## # # # # ####### # ## ## # # # # ######## ###### ######## ### # # # # ### # # ##### # ####### # # # ## # ## ## # ### # # # # ####### ## ## # # # ## # ### # #### # # # # # ##### ## ## ## # ## # ## #### ##### # # # # # #### # ## ## # ### # ##### # # # # ## # ## ## ## # ## ### ### # ## ###
Above is just the tip of the ice-pack, you can use many others font style to display your text.
I am going to use python pyfiglet module which will convert my regular strings in to ASCII art fonts. To install pyfiglet,simply run:
$pip install pyfiglet
In your terminal window, that it.
Example# 1
>>> import pyfiglet >>> ascii_banner = pyfiglet.figlet_format("HELLO, PYTHON") >>> print(ascii_banner) _ _ _____ _ _ ___ ______ _______ _ _ ___ _ _ | | | | ____| | | | / _ \ | _ \ \ / /_ _| | | |/ _ \| \ | | | |_| | _| | | | | | | | | | |_) \ V / | | | |_| | | | | \| | | _ | |___| |___| |__| |_| | | __/ | | | | | _ | |_| | |\ | |_| |_|_____|_____|_____\___( ) |_| |_| |_| |_| |_|\___/|_| \_| |/
Example#2
>>> from pyfiglet import Figlet >>> custom_fig = Figlet(font='graffiti') >>> print(custom_fig.renderText('HELLO, PYTHON')) ___ ______________.____ .____ ________ / | \_ _____/| | | | \_____ \ / ~ \ __)_ | | | | / | \ \ Y / \| |___| |___/ | \ \___|_ /_______ /|_______ \_______ \_______ / /\ \/ \/ \/ \/ \/ )/ _______________.___.______________ ___ ________ _______ \______ \__ | |\__ ___/ | \_____ \ \ \ | ___// | | | | / ~ \/ | \ / | \ | | \____ | | | \ Y / | \/ | \ |____| / ______| |____| \___|_ /\_______ /\____|__ / \/ \/ \/ \/
Example#3
>>> from pyfiglet import Figlet >>> custom_fig = Figlet(font='bubble') >>> print(custom_fig.renderText('Hello, Python')) _ _ _ _ _ _ _ _ _ _ _ _ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ ( H | e | l | l | o | , ) ( P | y | t | h | o | n ) \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
Example#4
>>> custom_fig = Figlet(font='speed') >>> print(custom_fig.renderText('Hello, Python')) ______ __ ___________ ___ / / /_______ /__ /_____ __ /_/ /_ _ \_ /__ /_ __ \ _ __ / / __/ / _ / / /_/ /__ /_/ /_/ \___//_/ /_/ \____/_( ) _|/ ________ ___________ ___ __ \____ ___ /___ /______________ __ /_/ /_ / / / __/_ __ \ __ \_ __ \ _ ____/_ /_/ // /_ _ / / / /_/ / / / / /_/ _\__, / \__/ /_/ /_/\____//_/ /_/ /____/
So my guess is you’re quite comfortable in finding a font you like and generate an ASCII art banner using pyfiglet to enhance your application.
- Related Articles
- Print with your own font using C#
- How to Build your own website using Django in Python
- Implement your own sizeof operator using C++
- How to build your own Sqlite database in Python
- Build Your Own Botnet
- Set different font families for screen and print with CSS
- Create Your Own Q&A Forum Like Stack Overflow using Askbot
- Set Font Size with Pixels using CSS
- Set Font Size with em using CSS
- Setting Font Size with Em Using CSS
- Setting Font Size with Keywords Using CSS
- Setting Font Size with Pixels using CSS
- Write your own memcpy() in C
- Implement your own itoa() in C
- Write your own atoi() in C++

Advertisements