JavaScript Editor Javascript validator     Web page editor 


Render text using FIGlet fonts.

With Text_Figlet you can create ASCII-art like text using FIGlet font description files (FIGlet fonts). The package supports horizontal smushing, German symbols (e.g. äöü), RTL and LTR writing directions as well as incomplete and gzipped fonts (as long as php's zlib extension is installed).

Using the Text_Figlet class

Text_Figlet has only two methods you can use: loadFont() to select a FIGlet font file that will be used later on, and lineEcho() that actually returns the passed text, rendered with the previously selected font.

loadFont() takes the name/path of the FIGlet font file (*.flf or *.flf.gz) as first parameter, and the option if German characters should also be loaded as second, optional parameter (defaults to true). The method either returns true if the font could be loaded, or a PEAR_Error in case of a problem.

lineEcho() can be called (multiple times if needed) after loading the font with loadFont(). The method takes the text that should be rendered using the font as first parameter, and an optional second parameter that determines if the text should be outputted in HTML text. In this case, special characters are escaped and everything is setup so that the text will look correctly. This parameter defaults to false. You should also wrap the line into <pre> tags, since they will monospace the text. Unlike the name implies, the rendered text is not echoed but returned.

The Text_Figlet package already ships some fonts. They are stored in its data directory which can be found calling pear config-get data_dir, and appending Text_Figlet/fonts/ to it. It will contain the following fonts:

Passing one of the font names to loadFont() will automatically look them up in the Text_Figlet font data directory if they are not found.

JavaScript Editor Javascript validator     Web page editor