Zend_Text_Figlet.xml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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 <acronym>ASCII</acronym> 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 <filename>.flf</filename> file and gzip it. To allow
  18. <classname>Zend_Text_Figlet</classname> to recognize this, the gzipped font
  19. must have the extension <filename>.gz</filename>. Further, to be able to use
  20. gzipped fonts, you have to have enabled the GZIP extension of <acronym>PHP</acronym>.
  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 <methodname>render()</methodname> 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. <property>font</property> - 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. <property>outputWidth</property> - 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. <property>handleParagraphs</property> - A boolean which indicates,
  54. how new lines are handled. When set to <constant>TRUE</constant>, single new
  55. lines 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. <property>justification</property> - May be one of the values of
  63. <classname>Zend_Text_Figlet::JUSTIFICATION_*</classname>. There is
  64. <constant>JUSTIFICATION_LEFT</constant>,
  65. <constant>JUSTIFICATION_CENTER</constant> and
  66. <constant>JUSTIFICATION_RIGHT</constant> The default justification
  67. is defined by the <property>rightToLeft</property> value.
  68. </para>
  69. </listitem>
  70. <listitem>
  71. <para>
  72. <property>rightToLeft</property> - Defines in which direction the
  73. text is written. May be either
  74. <constant>Zend_Text_Figlet::DIRECTION_LEFT_TO_RIGHT</constant> or
  75. <constant>Zend_Text_Figlet::DIRECTION_RIGHT_TO_LEFT</constant>. By
  76. default the setting of the font file is used. When justification
  77. is not defined, a text written from right-to-left is
  78. automatically right-aligned.
  79. </para>
  80. </listitem>
  81. <listitem>
  82. <para>
  83. <property>smushMode</property> - An integer bitfield which defines,
  84. how the single characters are smushed together. Can be the
  85. sum of multiple values from <classname>Zend_Text_Figlet::SM_*</classname>.
  86. There are the following smush modes: SM_EQUAL, SM_LOWLINE,
  87. SM_HIERARCHY, SM_PAIR, SM_BIGX, SM_HARDBLANK, SM_KERN and
  88. SM_SMUSH. A value of 0 doesn't disable the entire smushing,
  89. but forces SM_KERN to be applied, while a value of -1 disables
  90. it. An explanation of the different smush modes can be found
  91. <ulink url="http://www.jave.de/figlet/figfont.txt">here</ulink>.
  92. By default the setting of the font file is used. The smush mode
  93. option is normally used only by font designers testing the various
  94. layoutmodes with a new font.
  95. </para>
  96. </listitem>
  97. </itemizedlist>
  98. </para>
  99. <example id="zend.text.figlet.example.using">
  100. <title>Using Zend_Text_Figlet</title>
  101. <para>
  102. This example illustrates the basic use of <classname>Zend_Text_Figlet</classname>
  103. to create a simple FIGlet text:
  104. </para>
  105. <programlisting language="php"><![CDATA[
  106. $figlet = new Zend_Text_Figlet();
  107. echo $figlet->render('Zend');
  108. ]]></programlisting>
  109. <para>
  110. Assuming you are using a monospace font, this would look as follows:
  111. </para>
  112. <programlisting language="text"><![CDATA[
  113. ______ ______ _ __ ______
  114. |__ // | ___|| | \| || | __ \\
  115. / // | ||__ | ' || | | \ ||
  116. / //__ | ||___ | . || | |__/ ||
  117. /_____|| |_____|| |_|\_|| |_____//
  118. `-----`' `-----` `-` -`' -----`
  119. ]]></programlisting>
  120. </example>
  121. </sect1>
  122. <!--
  123. vim:se ts=4 sw=4 et:
  124. -->