Text/Figlet.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled with this package in the file LICENSE.txt. It is also available through the world-wide-web at this URL: http://framework.zend.com/license/new-bsd If you did not receive a copy of the license and are unable to obtain it through the world-wide-web, please send an email to [email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Text_Figlet
- Version
- $Id: Figlet.php 24593 2012-01-05 20:35:02Z matthew $
\Zend_Text_Figlet
Zend_Text_Figlet is a PHP implementation of FIGlet
- Category
- Zend
- Copyright
- Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants
Properties


array $_charList = array()
Array containing all characters of the current font
array()
Details- Type
- array


boolean $_fontLoaded = false
Indicates if a font was loaded yet
false
Details- Type
- boolean


array $_germanChars = array(196, 214, 220, 228, 246, 252, 223)
Latin-1 codes for German letters, respectively:
LATIN CAPITAL LETTER A WITH DIAERESIS = A-umlaut LATIN CAPITAL LETTER O WITH DIAERESIS = O-umlaut LATIN CAPITAL LETTER U WITH DIAERESIS = U-umlaut LATIN SMALL LETTER A WITH DIAERESIS = a-umlaut LATIN SMALL LETTER O WITH DIAERESIS = o-umlaut LATIN SMALL LETTER U WITH DIAERESIS = u-umlaut LATIN SMALL LETTER SHARP S = ess-zed
array(196, 214, 220, 228, 246, 252, 223)
Details- Type
- array


boolean $_handleParagraphs = false
Wether to handle paragraphs || not
false
Details- Type
- boolean


integer $_inCharLineLengthLimit = 0
Maximum in character line length
0
Details- Type
- integer


integer $_justification = null
Justification for the text, according to $_outputWidth
For using font default, this parameter should be null, else one of the values of Zend_Text_Figlet::JUSTIFICATION_*
null
Details- Type
- integer


integer $_rightToLeft = null
Direction of text-writing, namely right to left
For using font default, this parameter should be null, else one of the values of Zend_Text_Figlet::DIRECTION_*
null
Details- Type
- integer


array $_skipOptions = array('options', 'config')
Option keys to skip when calling setOptions()
array('options', 'config')
Details- Type
- array
Methods


__construct(array | \Zend_Config $options = null) : void
Instantiate the FIGlet with a specific font.
If no font is given, the standard font is used. You can also supply multiple options via the $options variable, which can either be an array or an instance of Zend_Config.
Name | Type | Description |
---|---|---|
$options | array | \Zend_Config | Options for the output |


_addChar(string $char) : boolean
Attempts to add the given character onto the end of the current line.
Returns true if this can be done, false otherwise.
Name | Type | Description |
---|---|---|
$char | string | Character which to add to the output |
Type | Description |
---|---|
boolean |


_getLetter(string $char) : void
Gets the requested character and sets current and previous char width.
Name | Type | Description |
---|---|---|
$char | string | The character from which to get the letter of |


_loadChar(resource $fp) : array
Load a single character from the font file
Name | Type | Description |
---|---|---|
$fp | resource | File pointer to the font file |
Type | Description |
---|---|
array |


_loadFont(string $fontFile) : void
Load the specified font
Name | Type | Description |
---|---|---|
$fontFile | string | Font file to load |
Exception | Description |
---|---|
\Zend_Text_Figlet_Exception | When font file was not found |
\Zend_Text_Figlet_Exception | When GZIP library is required but not found |
\Zend_Text_Figlet_Exception | When font file is not readable |


_putString(string $string) : void
Puts the given string, substituting blanks for hardblanks.
If outputWidth is 1, puts the entire string; otherwise puts at most outputWidth - 1 characters. Puts a newline at the end of the string. The string is left- justified, centered or right-justified (taking outputWidth as the screen width) if justification is 0, 1 or 2 respectively.
Name | Type | Description |
---|---|---|
$string | string | The string to add to the output |


_readMagic(resource $fp) : string
Reads a four-character magic string from a stream
Name | Type | Description |
---|---|---|
$fp | resource | File pointer to the font file |
Type | Description |
---|---|
string |


_setUsedSmush() : void
Set the used smush mode, according to smush override, user smsush and font smush.


_skipToEol(resource $fp) : void
Skip a stream to the end of line
Name | Type | Description |
---|---|---|
$fp | resource | File pointer to the font file |


_smushAmount() : integer
Returns the maximum amount that the current character can be smushed into the current line.
Type | Description |
---|---|
integer |


_smushem(string $leftChar, string $rightChar) : string
Given two characters, attempts to smush them into one, according to the current smushmode.
Returns smushed character or false if no smushing can be done.
Smushmode values are sum of following (all values smush blanks):
1: Smush equal chars (not hardblanks) 2: Smush '_' with any char in hierarchy below 4: hierarchy: "|", "/\", "[]", "{}", "()", "<>" Each class in hier. can be replaced by later class. 8: [ + ] -> |, { + } -> |, ( + ) -> | 16: / + \ -> X, > + < -> X (only in that order) 32: hardblank + hardblank -> hardblank
Name | Type | Description |
---|---|---|
$leftChar | string | Left character to smush |
$rightChar | string | Right character to smush |
Type | Description |
---|---|
string |


_splitLine() : void
Splits inCharLine at the last word break (bunch of consecutive blanks).
Makes a new line out of the first part and appends it using appendLine(). Makes a new line out of the second part and returns.


_uniOrd(string $c) : integer
Unicode compatible ord() method
Name | Type | Description |
---|---|---|
$c | string | The char to get the value from |
Type | Description |
---|---|
integer |


render(string $text, string $encoding = 'UTF-8') : string
Render a FIGlet text
Name | Type | Description |
---|---|---|
$text | string | Text to convert to a figlet text |
$encoding | string | Encoding of the input string |
Type | Description |
---|---|
string |
Exception | Description |
---|---|
\InvalidArgumentException | When $text is not a string |
\Zend_Text_Figlet_Exception | When $text it not properly encoded |


setConfig(\Zend_Config $config) : \Zend_Text_Figlet
Set options from config object
Name | Type | Description |
---|---|---|
$config | \Zend_Config | Configuration for Zend_Text_Figlet |
Type | Description |
---|---|
\Zend_Text_Figlet |


setFont(string $font) : \Zend_Text_Figlet
Set a font to use
Name | Type | Description |
---|---|---|
$font | string | Path to the font |
Type | Description |
---|---|
\Zend_Text_Figlet |


setHandleParagraphs(boolean $handleParagraphs) : \Zend_Text_Figlet
Set handling of paragraphs
Name | Type | Description |
---|---|---|
$handleParagraphs | boolean | Wether to handle paragraphs or not |
Type | Description |
---|---|
\Zend_Text_Figlet |


setJustification(integer $justification) : \Zend_Text_Figlet
Set the justification.
0 stands for left aligned, 1 for centered and 2 for right aligned.
Name | Type | Description |
---|---|---|
$justification | integer | Justification of the output text |
Type | Description |
---|---|
\Zend_Text_Figlet |


setOptions(array $options) : \Zend_Text_Figlet
Set options from array
Name | Type | Description |
---|---|---|
$options | array | Configuration for Zend_Text_Figlet |
Type | Description |
---|---|
\Zend_Text_Figlet |


setOutputWidth(integer $outputWidth) : \Zend_Text_Figlet
Set the output width
Name | Type | Description |
---|---|---|
$outputWidth | integer | Output with which should be used for word wrapping and justification |
Type | Description |
---|---|
\Zend_Text_Figlet |


setRightToLeft(integer $rightToLeft) : \Zend_Text_Figlet
Set right to left mode.
For writing from left to right, use Zend_Text_Figlet::DIRECTION_LEFT_TO_RIGHT. For writing from right to left, use Zend_Text_Figlet::DIRECTION_RIGHT_TO_LEFT.
Name | Type | Description |
---|---|---|
$rightToLeft | integer | Right-to-left mode |
Type | Description |
---|---|
\Zend_Text_Figlet |


setSmushMode(integer $smushMode) : \Zend_Text_Figlet
Set the smush mode.
Use one of the constants of Zend_Text_Figlet::SM_*, you may combine them.
Name | Type | Description |
---|---|---|
$smushMode | integer | Smush mode to use for generating text |
Type | Description |
---|---|
\Zend_Text_Figlet |