This library is famous for creating ASCII art in Python. It provides various functions for drawing shapes, text, and even animation.
We must install an art library before trying out all the packages inside the library.
Converts text to ASCII art using a specified font and ignoring certain characters.
Syntax:
text2art(text, font=None, chr_ignore=None, **kwargs):
Please note the following information about the parameters used for converting input text into artistic or decorative text:
Example 1
Let us consider an example for converting text to art.
Program
Output:

Explanation
We used the text2art function by giving the text as input.
Example 2
Let us consider another example of using all the parameters in the syntax:
Program
Output:

Explanation
In this example program, we used the text2art function to convert the text into art by using a different font from default by specifying the font as "block".
Example 3
If you want to print the text with different art forms without mentioning the style, you can use the rand to get different text art forms.
Program
Output:


Explanation
Here, we used rand to get different n styles of art whenever we ran the program n times.
Example 4
If we want to print multiple lines of text, we use triple quotations to generate the multiple-line texts.
Program
Output:

Explanation
Here, we mentioned the text with multiple lines using triple quotations, mentioning each word in a line. So, we generated multiple lines.
The art() method is one of the other methods to convert the text to art. This tool is similar to text2art, but it provides better control over the placement and alignment of text.
Syntax:
art(text, font=None, chr_ignore=None, **kwargs)
Let us see the how art method converts the text to art.
Program
1. To get the art of coffee
Output:
c[_]
2. To get the art of woman
Output:
▓⚗_⚗▓
3. To get the art of man
Output:
ب_ب
4. To get the random art
Output:
>++('>
:-P
[E}
5. To get the art of men of 10 times
Output:
ب_ب ب_ب ب_ب ب_ب ب_ب ب_ب ب_ب ب_ب ب_ب ب_ب
This function prints 1-line art in normal mode (return None) and raises artError in exception.
Program
Output:
òÓ ۜ\(סּںסּَ` )/ۜ (╯︵╰,) n_n :-) (^▽^) c[_] ▓⚗_⚗▓ \m/(-_-)\m/ ~(__^> n_n n_n n_n n_n n_n n_n n_n
This function prints ASCII text in normal mode (return None) and raises artError in exception.
Program
Output

Program
Output

Program
Output
Random font 1

Random font 2

Random font 3

Program
Output:

The tsave() method is part of the art module and saves a text converted into ASCII art as an image file. Below is an explanation of how to use it:
Syntax:
Arguments:
Example 1
Output:

Saved! Filename: samplefile.txt ASCII art saved to: samplefile.txt
Explanation
We used the tsave() method to save the text with font in the required file.
This code will convert the text "Hello, World!" to ASCII art using the "rand-small" font and save it to the file "helloworld.txt".
Example 2
Let us see an example program using all additional options.
Output:

Saved! Filename: longer_text4.txt Saved ASCII art to file: longer_text4
Explanation
This code will convert the longer text "welcome to javatpoint" to ASCII art using the "slant" font and save the resulting image to a file named "longer_text.png". It also uses the chr_ignore parameter set to True, which means any characters in the text that the font can't represent will be ignored instead of falling back to default characters.
The 'randart()' method generates random art.
Program
Output:
Output 1: *:o) Output 2: +:) Output 3: @__
The ASCII art library is a useful resource for those who wish to explore the world of text-based art. Its user-friendly interface, versatility, and active community make it an excellent choice for beginners and enthusiasts. However, it is important to consider its limitations regarding graphical capabilities and compatibility issues for projects that require more advanced visuals or seamless version compatibility.
Choosing an ASCII art library depends on your specific needs and priorities. Nevertheless, the art module continues to be a popular and effective option for those looking for a reliable and user-friendly way to bring their textual creations to life in ASCII art.
We request you to subscribe our newsletter for upcoming updates.

We deliver comprehensive tutorials, interview question-answers, MCQs, study materials on leading programming languages and web technologies like Data Science, MEAN/MERN full stack development, Python, Java, C++, C, HTML, React, Angular, PHP and much more to support your learning and career growth.
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India