Text-to-ASCII art generator in Python

Adam Matan picture Adam Matan · Jul 8, 2012 · Viewed 24.7k times · Source

I would like to add an easter egg to one our developers' command line tools, which will greet its user if a certain date is matched. Basically, I'm looking for:

>>> print big_text("Happy\nBirthday")                                                                                   

   .                   _________   _...._    _________   _...._                    
 .'|                   \        |.'      '-. \        |.'      '-. .-.          .- 
<  |                    \        .'```'.    '.\        .'```'.    '.\ \        / / 
 | |             __      \      |       \     \\      |       \     \\ \      / /  
 | | .'''-.   .:--.'.     |     |        |    | |     |        |    | \ \    / /   
 | |/.'''. \ / |   \ |    |      \      /    .  |      \      /    .   \ \  / /    
 |  /    | | `" __ | |    |     |\`'-.-'   .'   |     |\`'-.-'   .'     \ `  /     
 | |     | |  .'.''| |    |     | '-....-'`     |     | '-....-'`        \  /      
 | |     | | / /   | |_  .'     '.             .'     '.                 / /       
 | '.    | '.\ \._,\ '/'-----------'         '-----------'           |`-' /        
 '---'   '---'`--'  `"                    _______                     '..'         
/|        .--.                   .        \  ___ `'.                               
||        |__|                 .'|         ' |--.\  \          .-.          .-     
||        .--..-,.--.      .| <  |         | |    \  '          \ \        / /     
||  __    |  ||  .-. |   .' |_ | |         | |     |  '    __    \ \      / /      
||/'__ '. |  || |  | | .'     || | .'''-.  | |     |  | .:--.'.   \ \    / /       
|:/`  '. '|  || |  | |'--.  .-'| |/.'''. \ | |     ' .'/ |   \ |   \ \  / /        
||     | ||  || |  '-    |  |  |  /    | | | |___.' /' `" __ | |    \ `  /         
||\    / '|__|| |        |  |  | |     | |/_______.'/   .'.''| |     \  /          
|/\'..' /     | |        |  '.'| |     | |\_______|/   / /   | |_    / /           
'  `'-'`      |_|        |   / | '.    | '.            \ \._,\ '/|`-' /            
                         `'-'  '---'   '---'            `--'  `"  '..'             

Is there a package for that?

Credit where credit is due.

Answer

patorjk picture patorjk · Jul 10, 2012

Author of the TAAG app you linked here. Most of the fonts in TAAG are FIGlet fonts (figlet.org). FIGlet is a command line linux app, but FIGlet drivers have been written in several languages. I released the driver I wrote in JavaScript here:

https://github.com/patorjk/figlet.js

Though that would need to be ported to Python to work. I did a search for FIGlet Python libraries and found this:

https://github.com/pwaller/pyfiglet

I'm not sure how well it works, or how much of the spec it implements, but it looks pretty complete.