Transform Your Text with FIGlet (with examples)

Transform Your Text with FIGlet (with examples)

FIGlet is a command-line utility that transforms plain text into artistic ASCII art banners suitable for a variety of applications. It’s particularly useful for creating impact with text on a terminal or for enhancing scripts and programs with stylized text, offering a multitude of fonts and formatting options. This tutorial dives into several use cases of FIGlet, demonstrating the flexibility and creative potential of this tool.

Generate by directly inputting text:

Code:

figlet input_text

Motivation: You might want to quickly convert a simple piece of text into a decorative banner to display on a terminal or within a script, creating a visually appealing introduction or section header.

Explanation: In this straightforward example, figlet is invoked with the basic argument input_text, which is replaced by the text you want to transform into ASCII art. FIGlet uses the default font style to render your text.

Example Output:

Suppose the input_text is “Hello”. The output would resemble:

 _   _      _ _
| | | | ___| | | ___
| |_| |/ _ \ | |/ _ \
|  _  |  __/ | | (_) |
|_| |_|\___|_|_|\___/

Use a custom [f]ont file:

Code:

figlet input_text -f path/to/font_file.flf

Motivation: To give your text a unique appearance that aligns better with the theme or style of your project, you can utilize a custom font file.

Explanation: The -f flag specifies that a font file should be used. Following this flag, provide the path path/to/font_file.flf to indicate the specific font file you desire to apply. This allows for a much greater customization of the ASCII art output.

Example Output:

With a custom font applied, “Hello” might appear as:

 #     #                                  #
 #     # ###### #####  ########  ######   #
 ####### #      #     ##       ## #          #
 # #### #  #####  ##    ###    ##  #####     #
 #     # #    # #    #      #    #    #    #
 #     # #### # ##### #######   #####    #

Use a [f]ont from the default font directory (the extension can be omitted):

Code:

figlet input_text -f font_filename

Motivation: When the desired font file is already located in FIGlet’s default font directory, easily access it without specifying a path, leading to simpler commands.

Explanation: Again, using the -f option allows you to choose a font specific to the global FIGlet directory. The font_filename is the name of the font file sans extension, letting FIGlet locate and apply it effortlessly.

Example Output:

“Hello” with an available default font may render as:

  ______    _ _ _       
 /  ___|  | _   __ | 
| |        |  |  |   | |
| |     _  |  _  _  __/
\ \ |__  | |  |   _  \  
 \_____| |_| |_ | |

Pipe command output through FIGlet:

Code:

command | figlet

Motivation: For dynamically generated data or strings, you might want to automatically convert outputs from other commands into creative banners without manually typing it out.

Explanation: This use case leverages the pipe | operator, redirecting the output of command to FIGlet. Thus, the output of one command becomes the input text for FIGlet, enabling on-the-fly ASCII conversion.

Example Output:

If command generates the text “Dynamic”, you will see:

 _____                           _     
|  __ \                         | |    
| |  \/_   _  _ __    ___ _ __  | |__  
| | __| | | || '_ \  / _ \ '__| | '_ \ 
| |_\ \ |_| || | | ||  __/ |    | |_) |
 \____/\__,_||_| |_| \___|_|    |_.__/ 

Show available FIGlet fonts:

Code:

showfigfonts optional_string_to_display

Motivation: Discovering different font options can help determine which style best suits your needs, displaying the same string in various formats for easy comparison.

Explanation: The showfigfonts function lists all available FIGlet fonts. By appending optional_string_to_display, each font is demonstrated using your specified string, allowing you to preview the output directly.

Example Output:

If the optional string is “Hello”, the display might include:

  _   _      _ _
 | | | | ___| | | ___
 | |_| |/ _ \ | |/ _ \
 |  _  |  __/ | | (_) |
 |_| |_|\___|_|_|\___/

Next font:
#  #                              #
#  # #  # ####### ###### ######## 
## #   #     #    #      _  #    
###  #      ###   #####     #    
##     #  #  #   #     #      #  
#        ###   ######         #

Use the full width of the [t]erminal and [c]enter the input text:

Code:

figlet -t -c input_text

Motivation: Using the terminal’s full width and centering text can create a professional, polished appearance, especially useful for title screens or emphasized messages.

Explanation: The -t option commands FIGlet to utilize the full width of the terminal to render the text, ensuring it occupies as much space as possible. The -c option centers the ASCII art, aligning it aesthetically within the context of the terminal view.

Example Output:

For a wide terminal with “Welcome”:





  ____  _     _
 / ___|| |__ (_)_ __
 \___ \| '_ \| | '_ \
  ___) | | | | | | | |
 |____/|_| |_|_|_| |_|
                              

Display all characters at full [W]idth to avoid overlapping:

Code:

figlet -W input_text

Motivation: When complex fonts are used, overlapping can distort the output. Guaranteeing full character width prevents such visual mishaps.

Explanation: The -W argument prompts FIGlet to ensure that each letter in the resulting ASCII art is at maximum width, thus preventing any characters from overlapping, ensuring clarity in complex designs.

Example Output:

With “Overlap” and a complex font:

  __    _____
 /  |  |  _   
 |   |  | |  | 
 |   |  | |  '--.
 | .  . | |  |--' 
 |_|   \___/ 
               

Conclusion:

Through these diverse use cases, FIGlet demonstrates its utility as a versatile tool for creating eye-catching ASCII art banners. Whether for simple scripts or complex program interfaces, understanding these examples equips you with the flexibility to customize and enhance your textual presentations effectively.

Related Posts

How to use the command 'rmdir' (with examples)

How to use the command 'rmdir' (with examples)

The rmdir command is a powerful utility in Unix-like operating systems that allows you to remove empty directories from your file system.

Read More
How to Use the Command `tlp-stat` (with examples)

How to Use the Command `tlp-stat` (with examples)

The tlp-stat command is a comprehensive tool used to generate status reports about the power management configuration and status of a Linux system.

Read More
How to Use the Command 'mm2gv' (with Examples)

How to Use the Command 'mm2gv' (with Examples)

The mm2gv command is a specialized tool designed to convert graphs from the Matrix Market (mm) format to the Graphviz (gv) format.

Read More