Zend\Text\Figlet is a PHP implementation of FIGlet

category Zend
package Zend_Text_Figlet

 Methods

Instantiate the FIGlet with a specific font.

__construct(array | \Traversable $options) 

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.

Parameters

$options

array\Traversable

Options for the output

Render a FIGlet text

render(string $text, string $encoding) : 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

Set handling of paragraphs

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

Parameters

$handleParagraphs

bool

Whether to handle paragraphs or not

Returns

Set the justification.

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

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

Parameters

$justification

integer

Justification of the output text

Returns

Set options from array

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

Parameters

$options

array

Configuration for Figlet

Returns

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

Set right to left mode.

setRightToLeft(integer $rightToLeft) : \Zend\Text\Figlet\Figlet

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.

Parameters

$rightToLeft

integer

Right-to-left mode

Returns

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

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

_addChar(string $char) : bool

Returns true if this can be done, false otherwise.

Parameters

$char

string

Character which to add to the output

Returns

bool

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.

_putString(string $string) : void

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.

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.

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

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

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

 

Array containing all characters of the current font

$charList : array

 

Current char

$currentChar : array

 

Current character width

$currentCharWidth : integer

 

Indicates if a font was loaded yet

$fontLoaded : bool

 

Options of the current font

$fontOptions : array

 

Smush defined by the font

$fontSmush : integer

 

Latin-1 codes for German letters, respectively:

$germanChars : array

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 : bool

 

Hard blank character

$hardBlank : string

 

In character line

$inCharLine : string

 

In character line length

$inCharLineLength : integer

 

Maximum in character line length

$inCharLineLengthLimit : integer

 

Justification for the text, according to $outputWidth

$justification : integer

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

 

Current outline length

$outlineLength : integer

 

Maximum outline length

$outlineLengthLimit : integer

 

Current output

$output : string

 

Current output line

$outputLine : array

 

Output width, defaults to 80.

$outputWidth : integer

 

Previous character width

$previousCharWidth : integer

 

Direction of text-writing, namely right to left

$rightToLeft : integer

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

 

Smush mode

$smushMode : integer

 

Override font file smush layout

$smushOverride : integer

 

Smush defined by the user

$userSmush : integer

 Constants

 

Write directions

DIRECTION_LEFT_TO_RIGHT 

 

DIRECTION_RIGHT_TO_LEFT

DIRECTION_RIGHT_TO_LEFT 

 

Magic fontfile number

FONTFILE_MAGIC_NUMBER 

 

JUSTIFICATION_CENTER

JUSTIFICATION_CENTER 

 

Justifications

JUSTIFICATION_LEFT 

 

JUSTIFICATION_RIGHT

JUSTIFICATION_RIGHT 

 

SMO_FORCE

SMO_FORCE 

 

Smush mode override modes

SMO_NO 

 

SMO_YES

SMO_YES 

 

SM_BIGX

SM_BIGX 

 

Smush2 layout modes

SM_EQUAL 

 

SM_HARDBLANK

SM_HARDBLANK 

 

SM_HIERARCHY

SM_HIERARCHY 

 

SM_KERN

SM_KERN 

 

SM_LOWLINE

SM_LOWLINE 

 

SM_PAIR

SM_PAIR 

 

SM_SMUSH

SM_SMUSH