A mini FIGlet



A FIGlet is useful to mark the beginning of chapters or sections in the source code of a TeX document or to highlight some comments. There are several online FIGlets. The code below is a extremely simple one that composes a result from a given font set. Here we have some examples.


 Math
rules!
 
Font set: ./images/f_ascii.txt




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


Font set: ./images/f_graceful.txt




      __  __   __   ____  _  _
      (  \/  ) (  ) (_  _)( )( )
      )    (  /__\   )(   )__(
      (_/\/\_)(_)(_) (__) (_)(_)
___   _  _  __    ___  ___  _
(  ,) ( )( )(  )  (  _)/ __)/ \
 )  \  )()(  )(__  ) _)\__ \\_/
(_)\_) \__/ (____)(___)(___/(_)


Font set: ./images/f_serifcap.txt




         __  __           _     _    
        |  \/  |         | |   | |   
        | \  / |   __ _  | |_  | |__ 
        | |\/| |  / _` | | __| | '_ \
         | |  | | | (_| | | |_  | | | |
         |_|  |_|  \__,_|  \__| |_| |_|
                                      
                                      
                 _                _
                | |              | |
  _ __   _   _  | |   ___   ___  | |
 | '__| | | | | | |  / _ \ / __| | |
 | |    | |_| | | | |  __/ \__ \ |_|
 |_|     \__,_| |_|  \___| |___/ (_)
                                   

 
Font set: ./images/f_big.txt




     _____       _    _  
    |     | ___ | |_ | |_
     | | | || .'||  _||   |
     |_|_|_||__,||_|  |_|_|
                          
                        __
           _           |  |
 ___  _ _ | | ___  ___ |  |
|  _|| | || || -_||_ -||__|
|_|  |___||_||___||___||__|
                       
 
Font set: ./images/f_rectangles.txt




         __  __           _     _    
        |  \/  |   __ _  | |_  | |__ 
        | |\/| |  / _` | | __| | '_ \
         | |  | | | (_| | | |_  | | | |
         |_|  |_|  \__,_|  \__| |_| |_|
                                      
                 _                _
  _ __   _   _  | |   ___   ___  | |
 | '__| | | | | | |  / _ \ / __| | |
 | |    | |_| | | | |  __/ \__ \ |_|
 |_|     \__,_| |_|  \___| |___/ (_)
                                   
 
Font set: ./images/f_standard.txt





                ___ __ __      ________      _________  ___   ___    
               /__//_//_/\    /_______/\    /________/\/__/\ /__/\   
               \::\| \| \ \   \::: _  \ \   \__.::.__\/\::\ \\  \ \  
                \:.      \ \   \::(_)  \ \     \::\ \   \::\/_\ .\ \ 
                 \:.\-/\  \ \   \:: __  \ \     \::\ \   \:: ___::\ \
                   \. \  \  \ \   \:.\ \  \ \     \::\ \   \: \ \\::\ \
                    \__\/ \__\/    \__\/\__\/      \__\/    \__\/ \::\/
                                                                     
 ______       __  __      __          ______      ______      __     
/_____/\     /_/\/_/\    /_/\        /_____/\    /_____/\    /__/\   
\:::_ \ \    \:\ \:\ \   \:\ \       \::::_\/_   \::::_\/_   \.:\ \  
 \:(_) ) )_   \:\ \:\ \   \:\ \       \:\/___/\   \:\/___/\   \::\ \ 
  \: __ `\ \   \:\ \:\ \   \:\ \____   \::___\/_   \_::._\:\   \__\/_
    \ \ `\ \ \   \:\_\:\ \   \:\/___/\   \:\____/\    /____\:\    /__/\
     \_\/ \_\/    \_____\/    \_____\/    \_____\/    \_____\/    \__\/
                                                                     

 
Font set: ./images/f_swamp_land.txt

I have not created these font sets. I guess they are public domain. To get more visit the online figlets Ascii Set and Text to ASCII Art Generator.




The code

This is the Python code of the extra-mini-figlet:


#!/usr/bin/env python                                                          
# -*- coding: iso-8859-15 -*-                                                  


# the function minifiglet(text, name, h)
# prints text using figlet fonts in name.txt of height h


# To get new figlet fonts, paste and copy ascii.txt
# in http://patorjk.com/software/taag/
# with full height and width.
# The output with some font has to be copied to an empty
# file f_font.txt (use select text option in the web page).

import string


# Append font lines of the font included
# in name.txt with font size h to the list font_l
def readfont(font_l, name, h):
        with open(name+'.txt', 'r') as entr:
                for n in range(32, 127):
                        tmp_chr = h*['']
                        tmp_len = h*[0]
                        for lin in range(h):
                                tmp_chr[lin] = (entr.readline()).rstrip()
                                tmp_len[lin] = len(tmp_chr[lin])
                        max_len = max(tmp_len)
                        for lin in range(h):
                                font_l.append(tmp_chr[lin].ljust(max_len))
        # Length of space = length of 'n'
        max_len = len( font_l[h*(ord('n')-32)] )
        for n in range(h):
                font_l[n] = max_len*' '

def minifiglet(text, name, h):
        text_o = ''
        # load font
        font_l = []
        readfont(font_l, name, h)
        text.replace('\t','    ')
        # divide text into lines
        temp = text.split('\n')
        # loop
        for item in temp:
                for n in range(h):
                        for letter in item:
                                text_o += font_l[ h*(ord(letter)-32)+n ]
                        text_o += '\n'
        return text_o


sentence = ' Math\nrules!'
print( minifiglet(sentence,'./images/f_ascii',1) )

print( minifiglet(sentence,'./images/f_graceful',4) )

print( minifiglet(sentence,'./images/f_serifcap',4) )

print( minifiglet(sentence,'./images/f_big',8) )

print( minifiglet(sentence,'./images/f_rectangles',6) )

print( minifiglet(sentence,'./images/f_standard',6) )

print( minifiglet(sentence,'./images/f_swamp_land',8) )