API Documentation

Zend/Text/Figlet.php

Show: inherited
Table of Contents

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-2012 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Text_Figlet  
Version
$Id: Figlet.php 24594 2012-01-05 21:27:01Z matthew $  

\Zend_Text_Figlet

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

Constant  SM_EQUAL = 0x01

Smush2 layout modes

Constant  SM_LOWLINE = 0x02
Constant  SM_HIERARCHY = 0x04
Constant  SM_PAIR = 0x08
Constant  SM_BIGX = 0x10
Constant  SM_HARDBLANK = 0x20
Constant  SM_KERN = 0x40
Constant  SM_SMUSH = 0x80
Constant  SMO_NO = 0

Smush mode override modes

Constant  SMO_YES = 1
Constant  SMO_FORCE = 2
Constant  JUSTIFICATION_LEFT = 0

Justifications

Constant  JUSTIFICATION_CENTER = 1
Constant  JUSTIFICATION_RIGHT = 2
Constant  DIRECTION_LEFT_TO_RIGHT = 0

Write directions

Constant  DIRECTION_RIGHT_TO_LEFT = 1
Constant  FONTFILE_MAGIC_NUMBER = 'flf2'

Magic fontfile number

Properties

Propertyprotectedinteger  $_charHeight= ''

Height of the characters

Details
Type
integer
Propertyprotectedarray  $_charList= 'array()'

Array containing all characters of the current font

Default valuearray()Details
Type
array
Propertyprotectedarray  $_currentChar= 'null'

Current char

Default valuenullDetails
Type
array
Propertyprotectedinteger  $_currentCharWidth= '0'

Current character width

Default value0Details
Type
integer
Propertyprotectedboolean  $_fontLoaded= 'false'

Indicates if a font was loaded yet

Default valuefalseDetails
Type
boolean
Propertyprotectedarray  $_fontOptions= 'array()'

Options of the current font

Default valuearray()Details
Type
array
Propertyprotectedinteger  $_fontSmush= '0'

Smush defined by the font

Default value0Details
Type
integer
Propertyprotectedarray  $_germanChars= 'array(196'

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(196Details
Type
array
Propertyprotectedboolean  $_handleParagraphs= 'false'

Wether to handle paragraphs || not

Default valuefalseDetails
Type
boolean
Propertyprotectedstring  $_hardBlank= ''

Hard blank character

Details
Type
string
Propertyprotectedstring  $_inCharLine= ''

In character line

Details
Type
string
Propertyprotectedinteger  $_inCharLineLength= '0'

In character line length

Default value0Details
Type
integer
Propertyprotectedinteger  $_inCharLineLengthLimit= '0'

Maximum in character line length

Default value0Details
Type
integer
Propertyprotectedinteger  $_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 valuenullDetails
Type
integer
Propertyprotectedinteger  $_maxLength= ''

Max length of any character

Details
Type
integer
Propertyprotectedinteger  $_outlineLength= '0'

Current outline length

Default value0Details
Type
integer
Propertyprotectedinteger  $_outlineLengthLimit= '0'

Maxmimum outline length

Default value0Details
Type
integer
Propertyprotectedstring  $_output= ''

Current output

Details
Type
string
Propertyprotectedarray  $_outputLine= ''

Current output line

Details
Type
array
Propertyprotectedinteger  $_outputWidth= '80'

Output width, defaults to 80.

Default value80Details
Type
integer
Propertyprotectedinteger  $_previousCharWidth= '0'

Previous character width

Default value0Details
Type
integer
Propertyprotectedinteger  $_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 valuenullDetails
Type
integer
Propertyprotectedarray  $_skipOptions= 'array( 'options''

Option keys to skip when calling setOptions()

Default valuearray( 'options'Details
Type
array
Propertyprotectedinteger  $_smushMode= '0'

Smush mode

Default value0Details
Type
integer
Propertyprotectedinteger  $_smushOverride= '0'

Override font file smush layout

Default value0Details
Type
integer
Propertyprotectedinteger  $_userSmush= '0'

Smush defined by the user

Default value0Details
Type
integer

Methods

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

Parameters
Name Type Description
$options array|\Zend_Config

Options for the output

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

Parameters
Name Type Description
$char string

Character which to add to the output

Returns
Type Description
boolean
methodprotected_appendLine( ) : void

Appends the current line to the output

methodprotected_clearLine( ) : void

Clears the current line

methodprotected_getLetter( string $char ) : void

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

Parameters
Name Type Description
$char string

The character from which to get the letter of

methodprotected_loadChar( resource $fp ) : array

Load a single character from the font file

Parameters
Name Type Description
$fp resource

File pointer to the font file

Returns
Type Description
array
methodprotected_loadFont( string $fontFile ) : void

Load the specified font

Parameters
Name Type Description
$fontFile string

Font file to load

Throws
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
methodprotected_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.

Parameters
Name Type Description
$string string

The string to add to the output

methodprotected_readMagic( resource $fp ) : string

Reads a four-character magic string from a stream

Parameters
Name Type Description
$fp resource

File pointer to the font file

Returns
Type Description
string
methodprotected_setUsedSmush( ) : void

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

methodprotected_skipToEol( resource $fp ) : void

Skip a stream to the end of line

Parameters
Name Type Description
$fp resource

File pointer to the font file

methodprotected_smushAmount( ) : integer

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

Returns
Type Description
integer
methodprotected_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

Parameters
Name Type Description
$leftChar string

Left character to smush

$rightChar string

Right character to smush

Returns
Type Description
string
methodprotected_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.

methodprotected_uniOrd( string $c ) : integer

Unicode compatible ord() method

Parameters
Name Type Description
$c string

The char to get the value from

Returns
Type Description
integer
methodpublicrender( string $text, string $encoding = 'UTF-8' ) : string

Render a FIGlet text

Parameters
Name Type Description
$text string

Text to convert to a figlet text

$encoding string

Encoding of the input string

Returns
Type Description
string
Throws
Exception Description
\InvalidArgumentException When $text is not a string
\Zend_Text_Figlet_Exception When $text it not properly encoded
methodpublicsetConfig( \Zend_Config $config ) : \Zend_Text_Figlet

Set options from config object

Parameters
Name Type Description
$config \Zend_Config

Configuration for Zend_Text_Figlet

Returns
Type Description
\Zend_Text_Figlet
methodpublicsetFont( string $font ) : \Zend_Text_Figlet

Set a font to use

Parameters
Name Type Description
$font string

Path to the font

Returns
Type Description
\Zend_Text_Figlet
methodpublicsetHandleParagraphs( boolean $handleParagraphs ) : \Zend_Text_Figlet

Set handling of paragraphs

Parameters
Name Type Description
$handleParagraphs boolean

Wether to handle paragraphs or not

Returns
Type Description
\Zend_Text_Figlet
methodpublicsetJustification( integer $justification ) : \Zend_Text_Figlet

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

Parameters
Name Type Description
$justification integer

Justification of the output text

Returns
Type Description
\Zend_Text_Figlet
methodpublicsetOptions( array $options ) : \Zend_Text_Figlet

Set options from array

Parameters
Name Type Description
$options array

Configuration for Zend_Text_Figlet

Returns
Type Description
\Zend_Text_Figlet
methodpublicsetOutputWidth( integer $outputWidth ) : \Zend_Text_Figlet

Set the output width

Parameters
Name Type Description
$outputWidth integer

Output with which should be used for word wrapping and justification

Returns
Type Description
\Zend_Text_Figlet
methodpublicsetRightToLeft( 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.

Parameters
Name Type Description
$rightToLeft integer

Right-to-left mode

Returns
Type Description
\Zend_Text_Figlet
methodpublicsetSmushMode( integer $smushMode ) : \Zend_Text_Figlet

Set the smush mode.

Use one of the constants of Zend_Text_Figlet::SM_*, you may combine them.

Parameters
Name Type Description
$smushMode integer

Smush mode to use for generating text

Returns
Type Description
\Zend_Text_Figlet
Documentation was generated by DocBlox 0.15.1.