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 license@zend.com so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Text_Figlet
- Version
- $Id$
Package: Zend_Text_FigletZend_Text_Figlet is a PHP implementation of FIGlet
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants


SMO_NO
= 0
Smush mode override modes


DIRECTION_RIGHT_TO_LEFT
= 1
Properties



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



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



array $_fontOptions = array()
Options of the current font
Default valuearray()
Details- Type
- array



integer $_fontSmush = 0
Smush defined by the font
Default value0
Details- Type
- integer



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
Default valuearray(196, 214, 220, 228, 246, 252, 223)
Details- Type
- array



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



integer $_inCharLineLengthLimit = 0
Maximum in character line length
Default value0
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_*
Default valuenull
Details- Type
- integer



integer $_outputWidth = 80
Output width, defaults to 80.
Default value80
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_*
Default valuenull
Details- Type
- integer



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



integer $_smushOverride = 0
Override font file smush layout
Default value0
Details- Type
- integer



integer $_userSmush = 0
Smush defined by the user
Default value0
Details- Type
- integer
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.
ParametersName | 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.
ParametersName | Type | Description |
---|
$char | string | Character which to add to the output |
---|
Returns


_getLetter(string $char) : void
Gets the requested character and sets current and previous char width.
ParametersName | 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
ParametersName | Type | Description |
---|
$fp | resource | File pointer to the font file |
---|
Returns 


_loadFont(string $fontFile) : void
ParametersName | Type | Description |
---|
$fontFile | string | Font file to load |
---|
Throws 


_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.
ParametersName | Type | Description |
---|
$string | string | The string to add to the output |
---|



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


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



_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
ParametersName | Type | Description |
---|
$leftChar | string | Left character to smush |
---|
$rightChar | string | Right character to smush |
---|
Returns


_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
ParametersName | Type | Description |
---|
$c | string | The char to get the value from |
---|
Returns 


render(string $text, string $encoding = 'UTF-8') : string
ParametersName | Type | Description |
---|
$text | string | Text to convert to a figlet text |
---|
$encoding | string | Encoding of the input string |
---|
ReturnsThrows 


setFont(string $font) : \Zend_Text_Figlet
ParametersName | Type | Description |
---|
$font | string | Path to the font |
---|
Returns 


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


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


setOptions(array $options) : \Zend_Text_Figlet
ParametersName | Type | Description |
---|
$options | array | Configuration for Zend_Text_Figlet |
---|
Returns 


setOutputWidth(integer $outputWidth) : \Zend_Text_Figlet
ParametersName | Type | Description |
---|
$outputWidth | integer | Output with which should be used for word
wrapping and justification |
---|
Returns 


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.
ParametersName | Type | Description |
---|
$rightToLeft | integer | Right-to-left mode |
---|
Returns 


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