Zend_Text_Figlet is a PHP implementation of FIGlet

category Zend
package Zend_Text_Figlet
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License

 Methods

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.

__construct(array|\Zend_Config $options = null

Parameters

$options

array\Zend_Config

Options for the output

Render a FIGlet text

render(string $text, string $encoding = 'UTF-8') : string

Parameters

$text

string

Text to convert to a figlet text

$encoding

string

Encoding of the input string

Exceptions

\InvalidArgumentException When $text is not a string
\Zend_Text_Figlet_Exception When $text it not properly encoded

Returns

string

Set options from config object

setConfig(\Zend_Config $config) : \Zend_Text_Figlet

Parameters

$config

\Zend_Config

Configuration for Zend_Text_Figlet

Returns

\Zend_Text_Figlet

Set a font to use

setFont(string $font) : \Zend_Text_Figlet

Parameters

$font

string

Path to the font

Returns

\Zend_Text_Figlet

Set handling of paragraphs

setHandleParagraphs(boolean $handleParagraphs) : \Zend_Text_Figlet

Parameters

$handleParagraphs

boolean

Wether to handle paragraphs or not

Returns

\Zend_Text_Figlet

Set the justification. 0 stands for left aligned, 1 for centered and 2 for right aligned.

setJustification(integer $justification) : \Zend_Text_Figlet

Parameters

$justification

integer

Justification of the output text

Returns

\Zend_Text_Figlet

Set options from array

setOptions(array $options) : \Zend_Text_Figlet

Parameters

$options

array

Configuration for Zend_Text_Figlet

Returns

\Zend_Text_Figlet

Set the output width

setOutputWidth(integer $outputWidth) : \Zend_Text_Figlet

Parameters

$outputWidth

integer

Output with which should be used for word wrapping and justification

Returns

\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.

setRightToLeft(integer $rightToLeft) : \Zend_Text_Figlet

Parameters

$rightToLeft

integer

Right-to-left mode

Returns

\Zend_Text_Figlet

Set the smush mode.

setSmushMode(integer $smushMode) : \Zend_Text_Figlet

Use one of the constants of Zend_TextFiglet::SM*, you may combine them.

Parameters

$smushMode

integer

Smush mode to use for generating text

Returns

\Zend_Text_Figlet

Attempts to add the given character onto the end of the current line.

_addChar(string $char) : boolean

Returns true if this can be done, false otherwise.

Parameters

$char

string

Character which to add to the output

Returns

boolean

Appends the current line to the output

_appendLine() : void

Clears the current line

_clearLine() : void

Gets the requested character and sets current and previous char width.

_getLetter(string $char) : void

Parameters

$char

string

The character from which to get the letter of

Load a single character from the font file

_loadChar(resource $fp) : array

Parameters

$fp

resource

File pointer to the font file

Returns

array

Load the specified font

_loadFont(string $fontFile) : void

Parameters

$fontFile

string

Font file to load

Exceptions

\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

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.

_putString(string $string) : void

Parameters

$string

string

The string to add to the output

Reads a four-character magic string from a stream

_readMagic(resource $fp) : string

Parameters

$fp

resource

File pointer to the font file

Returns

string

Set the used smush mode, according to smush override, user smsush and font smush.

_setUsedSmush() : void

Skip a stream to the end of line

_skipToEol(resource $fp) : void

Parameters

$fp

resource

File pointer to the font file

Returns the maximum amount that the current character can be smushed into the current line.

_smushAmount() : integer

Returns

integer

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.

_smushem(string $leftChar, string $rightChar) : string

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

Parameters

$leftChar

string

Left character to smush

$rightChar

string

Right character to smush

Returns

string

Splits inCharLine at the last word break (bunch of consecutive blanks).

_splitLine() : void

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.

Unicode compatible ord() method

_uniOrd(string $c) : integer

Parameters

$c

string

The char to get the value from

Returns

integer

 Properties

 

Height of the characters

$_charHeight : integer

Default

 

Array containing all characters of the current font

$_charList : array

Default

array()
 

Current char

$_currentChar : array

Default

null
 

Current character width

$_currentCharWidth : integer

Default

0
 

Indicates if a font was loaded yet

$_fontLoaded : boolean

Default

false
 

Options of the current font

$_fontOptions : array

Default

array()
 

Smush defined by the font

$_fontSmush : integer

Default

0
 

Latin-1 codes for German letters, respectively:

$_germanChars : array

Default

array(196, 214, 220, 228, 246, 252, 223)

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

 

Wether to handle paragraphs || not

$_handleParagraphs : boolean

Default

false
 

Hard blank character

$_hardBlank : string

Default

 

In character line

$_inCharLine : string

Default

 

In character line length

$_inCharLineLength : integer

Default

0
 

Maximum in character line length

$_inCharLineLengthLimit : integer

Default

0
 

Justification for the text, according to $_outputWidth

$_justification : integer

Default

null

For using font default, this parameter should be null, else one of the values of Zend_TextFiglet::JUSTIFICATION*

 

Max length of any character

$_maxLength : integer

Default

 

Current outline length

$_outlineLength : integer

Default

0
 

Maxmimum outline length

$_outlineLengthLimit : integer

Default

0
 

Current output

$_output : string

Default

 

Current output line

$_outputLine : array

Default

 

Output width, defaults to 80.

$_outputWidth : integer

Default

80
 

Previous character width

$_previousCharWidth : integer

Default

0
 

Direction of text-writing, namely right to left

$_rightToLeft : integer

Default

null

For using font default, this parameter should be null, else one of the values of Zend_TextFiglet::DIRECTION*

 

Option keys to skip when calling setOptions()

$_skipOptions : array

Default

array('options', 'config')
 

Smush mode

$_smushMode : integer

Default

0
 

Override font file smush layout

$_smushOverride : integer

Default

0
 

Smush defined by the user

$_userSmush : integer

Default

0

 Constants

 

Write directions

DIRECTION_LEFT_TO_RIGHT = 0 
 

DIRECTION_RIGHT_TO_LEFT

DIRECTION_RIGHT_TO_LEFT = 1 
 

Magic fontfile number

FONTFILE_MAGIC_NUMBER = 'flf2' 
 

JUSTIFICATION_CENTER

JUSTIFICATION_CENTER = 1 
 

Justifications

JUSTIFICATION_LEFT = 0 
 

JUSTIFICATION_RIGHT

JUSTIFICATION_RIGHT = 2 
 

SMO_FORCE

SMO_FORCE = 2 
 

Smush mode override modes

SMO_NO = 0 
 

SMO_YES

SMO_YES = 1 
 

SM_BIGX

SM_BIGX = 16 
 

Smush2 layout modes

SM_EQUAL = 1 
 

SM_HARDBLANK

SM_HARDBLANK = 32 
 

SM_HIERARCHY

SM_HIERARCHY = 4 
 

SM_KERN

SM_KERN = 64 
 

SM_LOWLINE

SM_LOWLINE = 2 
 

SM_PAIR

SM_PAIR = 8 
 

SM_SMUSH

SM_SMUSH = 128