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

Use the html <code> tag to insert small source code snippets

For longer code examples use http://pastie.org/.

Get latest updates by E-mail

About this blog

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

Recent Comments

  • sameer: Check to see if the 'IDE > options > format' is set to HTML. [...]
  • sameer: Google strips any newline characters form the text. Although it does accept it with the online trans [...]
  • Arjan: Fiddler is a debugging tool for IE (not Microsoft's Fiddler) [...]
  • Susan Martin: while creating a test for site, command icons on IDE greyed out and do not respond when selected. I [...]
  • Saar: Thanks for this example. helped me a lot. I have 1 problem, I am translating chunks of code, but I [...]
  • sameer: You can add extra GET variables in the options array as below: $pager_options = array( 'mode [...]
  • Martin: How can you carry over your own variables into the URL? I am using a form to POST a couple of var [...]
  • nancy: thanks very much ! first tools [...]

  • Users Online

    • 13 Users Online
    • 11 Guests, 2 Bots