Zend\Text\Figlet is a PHP implementation of FIGlet

package Default

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

__construct(array|\Traversable $options = null

Parameters

$options

array\Traversable

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

\Zend\Text\Figlet\Exception\InvalidArgumentException When $text is not a string
\Zend\Text\Figlet\Exception\UnexpectedValueException When $text it not properly encoded

Returns

string

Set a font to use

setFont(string $font) : \Zend\Text\Figlet\Figlet

Parameters

$font

string

Path to the font

Returns

\Zend\Text\Figlet\Figlet

Set handling of paragraphs

setHandleParagraphs(boolean $handleParagraphs) : \Zend\Text\Figlet\Figlet

Parameters

$handleParagraphs

boolean

Whether to handle paragraphs or not

Returns

\Zend\Text\Figlet\Figlet

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

setJustification(integer $justification) : \Zend\Text\Figlet\Figlet

Parameters

$justification

integer

Justification of the output text

Returns

\Zend\Text\Figlet\Figlet

Set options from array

setOptions(array $options) : \Zend\Text\Figlet\Figlet

Parameters

$options

array

Configuration for Figlet

Returns

\Zend\Text\Figlet\Figlet

Set the output width

setOutputWidth(integer $outputWidth) : \Zend\Text\Figlet\Figlet

Parameters

$outputWidth

integer

Output with which should be used for word wrapping and justification

Returns

\Zend\Text\Figlet\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\Figlet

Parameters

$rightToLeft

integer

Right-to-left mode

Returns

\Zend\Text\Figlet\Figlet

Set the smush mode.

setSmushMode(integer $smushMode) : \Zend\Text\Figlet\Figlet

Use one of the constants of Zend\Text\Figlet::SM_*, you may combine them.

Parameters

$smushMode

integer

Smush mode to use for generating text

Returns

\Zend\Text\Figlet\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\RuntimeException When font file was not found
\Zend\Text\Figlet\Exception\RuntimeException When GZIP library is required but not found
\Zend\Text\Figlet\Exception\RuntimeException When font file is not readable
\Zend\Text\Figlet\Exception\UnexpectedValueException When font file is not a FIGlet 2 font file

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 smush 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

 

Whether 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\Text\Figlet::JUSTIFICATION_*

 

Max length of any character

$maxLength : integer

Default

 

Current outline length

$outlineLength : integer

Default

0
 

Maximum 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\Text\Figlet::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