Zend_Text_Figlet.xml 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.text.figlet">
  4. <title>Zend_Text_Figlet</title>
  5. <para>
  6. <classname>Zend_Text_Figlet</classname> is a component which enables developers to
  7. create a so called FIGlet text. A FIGlet text is a string, which is
  8. represented as ASCII art. FIGlets use a special font format, called
  9. FLT (FigLet Font). By default, one standard font is shipped with
  10. <classname>Zend_Text_Figlet</classname>, but you can download additional fonts at
  11. <ulink url="http://www.figlet.org/fontdb.cgi">http://www.figlet.org</ulink>.
  12. </para>
  13. <note>
  14. <title>Compressed fonts</title>
  15. <para>
  16. <classname>Zend_Text_Figlet</classname> supports gzipped fonts. This means that
  17. you can take an <code>.flf</code> file and gzip it. To allow
  18. <classname>Zend_Text_Figlet</classname> to recognize this, the gzipped font
  19. must have the extension <code>.gz</code>. Further, to be able to use
  20. gzipped fonts, you have to have enabled the GZIP extension of PHP.
  21. </para>
  22. </note>
  23. <note>
  24. <title>Encoding</title>
  25. <para>
  26. <classname>Zend_Text_Figlet</classname> expects your strings to be UTF-8 encoded
  27. by default. If this is not the case, you can supply the character
  28. encoding as second parameter to the <code>render()</code> method.
  29. </para>
  30. </note>
  31. <para>
  32. You can define multiple options for a FIGlet. When instantiating
  33. <classname>Zend_Text_Figlet</classname>, you can supply an array or an instance of
  34. <classname>Zend_Config</classname>.
  35. <itemizedlist>
  36. <listitem>
  37. <para>
  38. <code>font</code> - Defines the font which should be used
  39. for rendering. If not defines, the built-in font will be
  40. used.
  41. </para>
  42. </listitem>
  43. <listitem>
  44. <para>
  45. <code>outputWidth</code> - Defines the maximum width of the
  46. output string. This is used for word-wrap as well as
  47. justification. Beware of too small values, they may result
  48. in an undefined behaviour. The default value is 80.
  49. </para>
  50. </listitem>
  51. <listitem>
  52. <para>
  53. <code>handleParagraphs</code> - A boolean which indicates,
  54. how new lines are handled. When set to true, single new lines
  55. are ignored and instead treated as single spaces. Only multiple
  56. new lines will be handled as such. The default value is
  57. <constant>FALSE</constant>.
  58. </para>
  59. </listitem>
  60. <listitem>
  61. <para>
  62. <code>justification</code> - May be one of the values of
  63. <classname>Zend_Text_Figlet::JUSTIFICATION_*</classname>. There is
  64. <code>JUSTIFICATION_LEFT</code>, <code>JUSTIFICATION_CENTER</code>
  65. and <code>JUSTIFICATION_RIGHT</code> The default justification
  66. is defined by the <code>rightToLeft</code> value.
  67. </para>
  68. </listitem>
  69. <listitem>
  70. <para>
  71. <code>rightToLeft</code> - Defines in which direction the
  72. text is written. May be either
  73. <classname>Zend_Text_Figlet::DIRECTION_LEFT_TO_RIGHT</classname> or
  74. <classname>Zend_Text_Figlet::DIRECTION_RIGHT_TO_LEFT</classname>. By
  75. default the setting of the font file is used. When justification
  76. is not defined, a text written from right-to-left is
  77. automatically right-aligned.
  78. </para>
  79. </listitem>
  80. <listitem>
  81. <para>
  82. <code>smushMode</code> - An integer bitfield which defines,
  83. how the single characters are smushed together. Can be the
  84. sum of multiple values from <classname>Zend_Text_Figlet::SM_*</classname>.
  85. There are the following smush modes: SM_EQUAL, SM_LOWLINE,
  86. SM_HIERARCHY, SM_PAIR, SM_BIGX, SM_HARDBLANK, SM_KERN and
  87. SM_SMUSH. A value of 0 doesn't disable the entire smushing,
  88. but forces SM_KERN to be applied, while a value of -1 disables
  89. it. An explanation of the different smush modes can be found
  90. <ulink url="http://www.jave.de/figlet/figfont.txt">here</ulink>.
  91. By default the setting of the font file is used. The smush mode
  92. option is normally used only by font designers testing the various
  93. layoutmodes with a new font.
  94. </para>
  95. </listitem>
  96. </itemizedlist>
  97. </para>
  98. <example id="zend.text.figlet.example.using">
  99. <title>Using Zend_Text_Figlet</title>
  100. <para>
  101. This example illustrates the basic use of <classname>Zend_Text_Figlet</classname>
  102. to create a simple FIGlet text:
  103. </para>
  104. <programlisting language="php"><![CDATA[
  105. $figlet = new Zend_Text_Figlet();
  106. echo $figlet->render('Zend');
  107. ]]></programlisting>
  108. <para>
  109. Assuming you are using a monospace font, this would look as follows:
  110. </para>
  111. <programlisting language="text"><![CDATA[
  112. ______ ______ _ __ ______
  113. |__ // | ___|| | \| || | __ \\
  114. / // | ||__ | ' || | | \ ||
  115. / //__ | ||___ | . || | |__/ ||
  116. /_____|| |_____|| |_|\_|| |_____//
  117. `-----`' `-----` `-` -`' -----`
  118. ]]></programlisting>
  119. </example>
  120. </sect1>
  121. <!--
  122. vim:se ts=4 sw=4 et:
  123. -->