Text/Figlet.php

Show: PublicProtectedPrivateinherited
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-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  
Package
Zend_Text_Figlet  
Version
$Id$  

\Zend_Text_Figlet

Package: Zend_Text_Figlet
Zend_Text_Figlet is a PHP implementation of FIGlet
Category
Zend  
Copyright
Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)  
License
New BSD License  

Constants

>VConstant  SM_EQUAL = 1
Smush2 layout modes
>VConstant  SM_LOWLINE = 2
>VConstant  SM_HIERARCHY = 4
>VConstant  SM_PAIR = 8
>VConstant  SM_BIGX = 16
>VConstant  SM_HARDBLANK = 32
>VConstant  SM_KERN = 64
>VConstant  SM_SMUSH = 128
>VConstant  SMO_NO = 0
Smush mode override modes
>VConstant  SMO_YES = 1
>VConstant  SMO_FORCE = 2
>VConstant  JUSTIFICATION_LEFT = 0
Justifications
>VConstant  JUSTIFICATION_CENTER = 1
>VConstant  JUSTIFICATION_RIGHT = 2
>VConstant  DIRECTION_LEFT_TO_RIGHT = 0
Write directions
>VConstant  DIRECTION_RIGHT_TO_LEFT = 1
>VConstant  FONTFILE_MAGIC_NUMBER = 'flf2'
Magic fontfile number

Properties

>VPropertyprotectedinteger $_charHeight
Height of the characters
Details
Type
integer
>VPropertyprotectedarray $_charList = array()
Array containing all characters of the current font
Default valuearray()Details
Type
array
>VPropertyprotectedarray $_currentChar = null
Current char
Default valuenullDetails
Type
array
>VPropertyprotectedinteger $_currentCharWidth = 0
Current character width
Default value0Details
Type
integer
>VPropertyprotectedboolean $_fontLoaded = false
Indicates if a font was loaded yet
Default valuefalseDetails
Type
boolean
>VPropertyprotectedarray $_fontOptions = array()
Options of the current font
Default valuearray()Details
Type
array
>VPropertyprotectedinteger $_fontSmush = 0
Smush defined by the font
Default value0Details
Type
integer
>VPropertyprotectedarray $_germanChars = array(196, 214, 220, 228, 246, 252, 223)
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(196, 214, 220, 228, 246, 252, 223)Details
Type
array
>VPropertyprotectedboolean $_handleParagraphs = false
Wether to handle paragraphs || not
Default valuefalseDetails
Type
boolean
>VPropertyprotectedstring $_hardBlank
Hard blank character
Details
Type
string
>VPropertyprotectedstring $_inCharLine
In character line
Details
Type
string
>VPropertyprotectedinteger $_inCharLineLength = 0
In character line length
Default value0Details
Type
integer
>VPropertyprotectedinteger $_inCharLineLengthLimit = 0
Maximum in character line length
Default value0Details
Type
integer
>VPropertyprotectedinteger $_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
>VPropertyprotectedinteger $_maxLength
Max length of any character
Details
Type
integer
>VPropertyprotectedinteger $_outlineLength = 0
Current outline length
Default value0Details
Type
integer
>VPropertyprotectedinteger $_outlineLengthLimit = 0
Maxmimum outline length
Default value0Details
Type
integer
>VPropertyprotectedstring $_output
Current output
Details
Type
string
>VPropertyprotectedarray $_outputLine
Current output line
Details
Type
array
>VPropertyprotectedinteger $_outputWidth = 80
Output width, defaults to 80.
Default value80Details
Type
integer
>VPropertyprotectedinteger $_previousCharWidth = 0
Previous character width
Default value0Details
Type
integer
>VPropertyprotectedinteger $_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
>VPropertyprotectedarray $_skipOptions = array('options', 'config')
Option keys to skip when calling setOptions()
Default valuearray('options', 'config')Details
Type
array
>VPropertyprotectedinteger $_smushMode = 0
Smush mode
Default value0Details
Type
integer
>VPropertyprotectedinteger $_smushOverride = 0
Override font file smush layout
Default value0Details
Type
integer
>VPropertyprotectedinteger $_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
NameTypeDescription
$optionsarray | \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
NameTypeDescription
$charstring

Character which to add to the output

Returns
TypeDescription
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
NameTypeDescription
$charstring

The character from which to get the letter of

methodprotected_loadChar(resource $fp) : array

Load a single character from the font file

Parameters
NameTypeDescription
$fpresource

File pointer to the font file

Returns
TypeDescription
array
methodprotected_loadFont(string $fontFile) : void

Load the specified font

Parameters
NameTypeDescription
$fontFilestring

Font file to load

Throws
ExceptionDescription
\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
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
NameTypeDescription
$stringstring

The string to add to the output

methodprotected_readMagic(resource $fp) : string

Reads a four-character magic string from a stream

Parameters
NameTypeDescription
$fpresource

File pointer to the font file

Returns
TypeDescription
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
NameTypeDescription
$fpresource

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
TypeDescription
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
NameTypeDescription
$leftCharstring

Left character to smush

$rightCharstring

Right character to smush

Returns
TypeDescription
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
NameTypeDescription
$cstring

The char to get the value from

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

Render a FIGlet text

Parameters
NameTypeDescription
$textstring

Text to convert to a figlet text

$encodingstring

Encoding of the input string

Returns
TypeDescription
string
Throws
ExceptionDescription
\InvalidArgumentExceptionWhen $text is not a string
\Zend_Text_Figlet_ExceptionWhen $text it not properly encoded
methodpublicsetConfig(\Zend_Config $config) : \Zend_Text_Figlet

Set options from config object

Parameters
NameTypeDescription
$config\Zend_Config

Configuration for Zend_Text_Figlet

Returns
TypeDescription
\Zend_Text_Figlet
methodpublicsetFont(string $font) : \Zend_Text_Figlet

Set a font to use

Parameters
NameTypeDescription
$fontstring

Path to the font

Returns
TypeDescription
\Zend_Text_Figlet
methodpublicsetHandleParagraphs(boolean $handleParagraphs) : \Zend_Text_Figlet

Set handling of paragraphs

Parameters
NameTypeDescription
$handleParagraphsboolean

Wether to handle paragraphs or not

Returns
TypeDescription
\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
NameTypeDescription
$justificationinteger

Justification of the output text

Returns
TypeDescription
\Zend_Text_Figlet
methodpublicsetOptions(array $options) : \Zend_Text_Figlet

Set options from array

Parameters
NameTypeDescription
$optionsarray

Configuration for Zend_Text_Figlet

Returns
TypeDescription
\Zend_Text_Figlet
methodpublicsetOutputWidth(integer $outputWidth) : \Zend_Text_Figlet

Set the output width

Parameters
NameTypeDescription
$outputWidthinteger

Output with which should be used for word wrapping and justification

Returns
TypeDescription
\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
NameTypeDescription
$rightToLeftinteger

Right-to-left mode

Returns
TypeDescription
\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
NameTypeDescription
$smushModeinteger

Smush mode to use for generating text

Returns
TypeDescription
\Zend_Text_Figlet
Documentation was generated by phpDocumentor 2.2.0 .