Zend Framework  1.12
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Zend_Text_Figlet Class Reference

Public Member Functions

 __construct ($options=null)
 Instantiate the FIGlet with a specific font.
 
 setOptions (array $options)
 Set options from array.
 
 setConfig (Zend_Config $config)
 Set options from config object.
 
 setFont ($font)
 Set a font to use.
 
 setHandleParagraphs ($handleParagraphs)
 Set handling of paragraphs.
 
 setJustification ($justification)
 Set the justification.
 
 setOutputWidth ($outputWidth)
 Set the output width.
 
 setRightToLeft ($rightToLeft)
 Set right to left mode.
 
 setSmushMode ($smushMode)
 Set the smush mode.
 
 render ($text, $encoding= 'UTF-8')
 Render a FIGlet text.
 

Public Attributes

const SM_EQUAL = 0x01
 Smush2 layout modes.
 
const SM_LOWLINE = 0x02
 
const SM_HIERARCHY = 0x04
 
const SM_PAIR = 0x08
 
const SM_BIGX = 0x10
 
const SM_HARDBLANK = 0x20
 
const SM_KERN = 0x40
 
const SM_SMUSH = 0x80
 
const SMO_NO = 0
 Smush mode override modes.
 
const SMO_YES = 1
 
const SMO_FORCE = 2
 
const JUSTIFICATION_LEFT = 0
 Justifications.
 
const JUSTIFICATION_CENTER = 1
 
const JUSTIFICATION_RIGHT = 2
 
const DIRECTION_LEFT_TO_RIGHT = 0
 Write directions.
 
const DIRECTION_RIGHT_TO_LEFT = 1
 
const FONTFILE_MAGIC_NUMBER = 'flf2'
 Magic fontfile number.
 

Protected Member Functions

 _putString ($string)
 Puts the given string, substituting blanks for hardblanks.
 
 _appendLine ()
 Appends the current line to the output.
 
 _splitLine ()
 Splits inCharLine at the last word break (bunch of consecutive blanks).
 
 _clearLine ()
 Clears the current line.
 
 _addChar ($char)
 Attempts to add the given character onto the end of the current line.
 
 _getLetter ($char)
 Gets the requested character and sets current and previous char width.
 
 _smushAmount ()
 Returns the maximum amount that the current character can be smushed into the current line.
 
 _smushem ($leftChar, $rightChar)
 Given two characters, attempts to smush them into one, according to the current smushmode.
 
 _loadFont ($fontFile)
 Load the specified font.
 
 _setUsedSmush ()
 Set the used smush mode, according to smush override, user smsush and font smush.
 
 _readMagic ($fp)
 Reads a four-character magic string from a stream.
 
 _skipToEol ($fp)
 Skip a stream to the end of line.
 
 _loadChar ($fp)
 Load a single character from the font file.
 
 _uniOrd ($c)
 Unicode compatible ord() method.
 

Protected Attributes

 $_charList = array()
 
 $_fontLoaded = false
 
 $_germanChars = array(196, 214, 220, 228, 246, 252, 223)
 
 $_outputWidth = 80
 
 $_hardBlank
 
 $_charHeight
 
 $_maxLength
 
 $_smushMode = 0
 
 $_fontSmush = 0
 
 $_userSmush = 0
 
 $_handleParagraphs = false
 
 $_justification = null
 
 $_rightToLeft = null
 
 $_smushOverride = 0
 
 $_fontOptions = array()
 
 $_previousCharWidth = 0
 
 $_currentCharWidth = 0
 
 $_outlineLength = 0
 
 $_outlineLengthLimit = 0
 
 $_inCharLine
 
 $_inCharLineLength = 0
 
 $_inCharLineLengthLimit = 0
 
 $_currentChar = null
 
 $_outputLine
 
 $_output
 
 $_skipOptions
 

Constructor & Destructor Documentation

__construct (   $options = null)

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
array | Zend_Config$optionsOptions for the output

Member Function Documentation

_addChar (   $char)
protected

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

Returns true if this can be done, false otherwise.

Parameters
string$charCharacter which to add to the output
Returns
boolean
_appendLine ( )
protected

Appends the current line to the output.

Returns
void
_clearLine ( )
protected

Clears the current line.

Returns
void
_getLetter (   $char)
protected

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

Parameters
string$charThe character from which to get the letter of
Returns
void
_loadChar (   $fp)
protected

Load a single character from the font file.

Parameters
resource$fpFile pointer to the font file
Returns
array
_loadFont (   $fontFile)
protected

Load the specified font.

Parameters
string$fontFileFont file to load
Exceptions
Zend_Text_Figlet_ExceptionWhen font file was not found
Zend_Text_Figlet_ExceptionWhen GZIP library is required but not found
Zend_Text_Figlet_ExceptionWhen font file is not readable
Returns
void
_putString (   $string)
protected

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
string$stringThe string to add to the output
Returns
void
_readMagic (   $fp)
protected

Reads a four-character magic string from a stream.

Parameters
resource$fpFile pointer to the font file
Returns
string
_setUsedSmush ( )
protected

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

Returns
void
_skipToEol (   $fp)
protected

Skip a stream to the end of line.

Parameters
resource$fpFile pointer to the font file
Returns
void
_smushAmount ( )
protected

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

Returns
integer
_smushem (   $leftChar,
  $rightChar 
)
protected

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
string$leftCharLeft character to smush
string$rightCharRight character to smush
Returns
string
_splitLine ( )
protected

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.

Returns
void
_uniOrd (   $c)
protected

Unicode compatible ord() method.

Parameters
string$cThe char to get the value from
Returns
integer
render (   $text,
  $encoding = 'UTF-8' 
)

Render a FIGlet text.

Parameters
string$textText to convert to a figlet text
string$encodingEncoding of the input string
Exceptions
InvalidArgumentExceptionWhen $text is not a string
Zend_Text_Figlet_ExceptionWhen $text it not properly encoded
Returns
string
setConfig ( Zend_Config  $config)

Set options from config object.

Parameters
Zend_Config$configConfiguration for Zend_Text_Figlet
Returns
Zend_Text_Figlet
setFont (   $font)

Set a font to use.

Parameters
string$fontPath to the font
Returns
Zend_Text_Figlet
setHandleParagraphs (   $handleParagraphs)

Set handling of paragraphs.

Parameters
boolean$handleParagraphsWether to handle paragraphs or not
Returns
Zend_Text_Figlet
setJustification (   $justification)

Set the justification.

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

Parameters
integer$justificationJustification of the output text
Returns
Zend_Text_Figlet
setOptions ( array  $options)

Set options from array.

Parameters
array$optionsConfiguration for Zend_Text_Figlet
Returns
Zend_Text_Figlet
setOutputWidth (   $outputWidth)

Set the output width.

Parameters
integer$outputWidthOutput with which should be used for word wrapping and justification
Returns
Zend_Text_Figlet
setRightToLeft (   $rightToLeft)

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
integer$rightToLeftRight-to-left mode
Returns
Zend_Text_Figlet
setSmushMode (   $smushMode)

Set the smush mode.

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

Parameters
integer$smushModeSmush mode to use for generating text
Returns
Zend_Text_Figlet

Member Data Documentation

$_charHeight
protected
$_charList = array()
protected
$_currentChar = null
protected
$_currentCharWidth = 0
protected
$_fontLoaded = false
protected
$_fontOptions = array()
protected
$_fontSmush = 0
protected
$_germanChars = array(196, 214, 220, 228, 246, 252, 223)
protected
$_handleParagraphs = false
protected
$_hardBlank
protected
$_inCharLine
protected
$_inCharLineLength = 0
protected
$_inCharLineLengthLimit = 0
protected
$_justification = null
protected
$_maxLength
protected
$_outlineLength = 0
protected
$_outlineLengthLimit = 0
protected
$_output
protected
$_outputLine
protected
$_outputWidth = 80
protected
$_previousCharWidth = 0
protected
$_rightToLeft = null
protected
$_skipOptions
protected
Initial value:
= array(
'options',
'config',
)
$_smushMode = 0
protected
$_smushOverride = 0
protected
$_userSmush = 0
protected
const DIRECTION_LEFT_TO_RIGHT = 0

Write directions.

const DIRECTION_RIGHT_TO_LEFT = 1
const FONTFILE_MAGIC_NUMBER = 'flf2'

Magic fontfile number.

const JUSTIFICATION_CENTER = 1
const JUSTIFICATION_LEFT = 0

Justifications.

const JUSTIFICATION_RIGHT = 2
const SM_BIGX = 0x10
const SM_EQUAL = 0x01

Smush2 layout modes.

const SM_HARDBLANK = 0x20
const SM_HIERARCHY = 0x04
const SM_KERN = 0x40
const SM_LOWLINE = 0x02
const SM_PAIR = 0x08
const SM_SMUSH = 0x80
const SMO_FORCE = 2
const SMO_NO = 0

Smush mode override modes.

const SMO_YES = 1