Creating a Figlet text in php


Posted in: php | Save to del.icio.us | Twit This! 18 Nov 2008

Zend_Text_Figlet is a Zend component which enables developers to create a FIGlet text. A Figlet is nothing but a technique of creating large letters using ordinary text. I don’t know how to make a use of this in my daily matters, but its a nice recreation. A short history on Figlet can be found here. An example and the code to generate it is shown below.

  ____     __   _     ____
 |  _ \\  | || | ||  |  _ \\
 | |_| || | '--' ||  | |_| ||
 | .__//  | .--. ||  | .__//
 |_|--`   |_|| |_||  |_|--`
 `-`      `-`  `-`   `-`
<?php
 
require_once("zend/text/figlet.php");
$figlet = new Zend_Text_Figlet();
echo $figlet->render('PHP');
 
?>

If you are displaying the output on a web page make sure to use the ‘pre’ tags around the Figlet. The Figlet looks good in a pure text format.
You can also define various options for the Figlet by passing the function an array of options, like say changing the font.

<?php
 
require_once("zend/text/figlet.php");
/* use a different font */
$options = array('font' => 'graffiti.flf');               
 
$figlet = new Zend_Text_Figlet($options);
echo $figlet->render('PHP');
 
?>
__________   ___ ___  __________
\______   \ /   |   \ \______   \
 |     ___//    ~    \ |     ___/
 |    |    \    Y    / |    |
 |____|     \___|_  /  |____|
                  \/

You can download more fonts from here.
The default width of the Figlet output is set to 80 characters, which you can change with the ‘outputWidth’ option.

.
.
$options = array('outputWidth' => 120);

For more options you can take a look at the documentation.

Share this post

Share on Facebook
Share on Twitter
Share on StumbleUpon
Share on Delicious
Share on Digg
Share on Technorati
Share on Reddit
Feeds RSS Subscribe to site Feed

Other related posts

2 Responses

1

Sameer’s Blog: Creating a Figlet text in php : Dragonfly Networks

November 19th, 2008 at 4:20 am

[...] has posted an example of a new(ish) component of the Zend Framework - the Zend_Figlet component - and how you can use it [...]

2

Ben Scholzen 'DASPRiD'

November 22nd, 2008 at 3:11 pm

Heh, at least one article about my Zend_Text_Figlet, nice one ;)

Comment Form

About this blog

This site is a digital habitat of Sameer, a freelance web developer working from Pune.More

On Twitter

Posting tweet...


  • Users Online

    • 2 Users Online
    • 1 Guest, 1 Bot
  • Categories