cvs: peardoc /en/package/text text-figlet.xml
| From: | Christian Weiske | Date: | Mon, 09 Apr 2007 18:19:53 +0000 |
| Subject: | cvs: peardoc /en/package/text text-figlet.xml | ||
| Groups: | php.pear.doc | ||
| Request: | Send a blank email to pear-doc+get-9610@lists.php.net to get a copy of this message | ||
cweiske Mon Apr 9 18:19:53 2007 UTC
Added files:
/peardoc/en/package/text text-figlet.xml
Log:
Text_Figlet documentation
http://cvs.php.net/viewvc.cgi/peardoc/en/package/text/text-figlet.xml?view=markup&rev=1.1
Index: peardoc/en/package/text/text-figlet.xml
+++ peardoc/en/package/text/text-figlet.xml
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 1.1 $ -->
<sect1 id="package.text.text-figlet">
<title>Text_Figlet</title>
<para>
Render text using FIGlet fonts.
</para>
<para>
With <classname>Text_Figlet</classname> 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).
</para>
<example>
<title>"Hello, world!" written using a FIGlet font</title>
<screen><![CDATA[.
/ / / /__ / / /___ _ ______ _____/ /___/ / /
/ /_/ / _ \/ / / __ \ | | /| / / __ \/ ___/ / __ / /
/ __ / __/ / / /_/ / | |/ |/ / /_/ / / / / /_/ /_/
/_/ /_/\___/_/_/\____( ) |__/|__/\____/_/ /_/\__,_(_)
|/
]]></screen>
</example>
<sect2>
<title>Using the Text_Figlet class</title>
<para>
<classname>Text_Figlet</classname> has only two methods you can use:
<function>LoadFont</function> to select a FIGlet font file that will be used
later on, and <function>LineEcho</function> that actually returns the
passed text, rendered with the previously selected font.
</para>
<para>
<function>LoadFont</function> takes the name/path of the FIGlet font file
(<literal>*.flf</literal> or <literal>*.flf.gz</literal>) as first
parameter,
and the option if German characters should also be loaded as second, optional
parameter (defaults to <literal>true</literal>).
The method either returns <literal>true</literal> if the font could
be loaded, or a <classname>PEAR_Error</classname> in case of a problem.
</para>
<para>
<function>LineEcho</function> can be called (multiple times if needed) after
loading the font with <function>LoadFont</function>. 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
<literal>false</literal>. You should also wrap the line into <pre> tags,
since they will monospace the text. Unlike the name implies, the rendered text
is <emphasis>not</emphasis> echoed but returned.
</para>
<example>
<title>Rendering "Hello, world!" using PHP</title>
<programlisting role="php"><![CDATA[
<?php
require_once 'Text/Figlet.php';
$figlet = new Text_Figlet();
$error = $figlet->LoadFont('slant.flf');
if (PEAR::isError($error)) {
echo 'Error: ' . $error->getMessage() . "\n";
} else {
echo $figlet->LineEcho('Hello, world!') . "\n";
}
?>
]]></programlisting>
</example>
<para>
The <classname>Text_Figlet</classname> package already ships some fonts.
They are stored in its data directory which can be found calling
<command>pear config-get data_dir</command>, and appending
<literal>Text_Figlet/fonts/</literal> to it. It will contain the following
fonts:
<itemizedlist>
<listitem><para>3-d.flf</para></listitem>
<listitem><para>alligator2.flf</para></listitem>
<listitem><para>bell.flf</para></listitem>
<listitem><para>block.flf</para></listitem>
<listitem><para>contessa.flf</para></listitem>
<listitem><para>cybermedium.flf</para></listitem>
<listitem><para>isometric1.flf</para></listitem>
<listitem><para>larry3d.flf</para></listitem>
<listitem><para>script.flf</para></listitem>
<listitem><para>slant.flf</para></listitem>
</itemizedlist>
Passing one of the font names to <function>LoadFont</function> will
automatically look them up in the <classname>Text_Figlet</classname> font
data directory if they are not found.
</para>
</sect2>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
sgml-parent-document:nil
sgml-default-dtd-file:"../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->