
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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.
Advertisements