Class: I2CE TextCell
This article desrcibes the class I2CE_TextCell It is contained in the module textlayout in the package TextLayout Tools The class is defined in the file: lib/I2CE_TextCell.php A word-wrapping text cell class. Uses the i2ce_hyphen class.
@package I2CE @subpackage TextLayout @author Carl Leitner <litlfred@ibiblio.org>
@version 0.1 @access public
Variables
$font_metric
protected @var I2CE_FontMetrics $font_metric the font we are using
- Type: protected $font_metric
$encoding
protected @var I2CE_Encoding $encoding the encoding we are using
- Type: protected $encoding
$space_char
The space character in this encoding
- Type: protected ng $space_char
$hyphen_char
The hyphen character in this encoding
- Type: protected ng $hyphen_char
$width
protected @var mixed $width the width of the cell (float or int)
- Type: protected $width
$hyphen
protected @var I2CE_Hyphen $hyphen a hyphenation dictionary
- Type: protected $hyphen
Methods
Greedy()
Word-wrap a paragraph using simple truncation. Assume no \n Removes all \r All white spaces are squased to a single space the last element of the array
- Signature: protected function Greedy($paragraph,$text_lines)
Parameters:
- $paragraph
- array $text_lines
the array to store the text lines. It starts appending on
Knuth()
- Signature: protected function Knuth($paragraph,$text_lines)
Parameters:
- $paragraph
- &$text_lines
Truncate()
Word-wrap a paragraph using simple truncation. Assume no \n Removes all \r All white spaces are squased to a single space
- Signature: protected function Truncate($paragraph,$text_lines)
Parameters:
__construct()
Construct a text cell object @param I2CE_Encoding encoding -- the encoding we want to use
- Signature: public function __construct($font_metric,$hyphen,$encoding,$algorithm)
Parameters:
- I2CE_FontMetric $font_metric
- I2CE_Hyphen $hyphen
default is null- Default Value: null
- &$encoding
- int $algorithm
the word wrapping algorithm: default = 'Greedy'- Default Value: 'Greedy'
getEncoding()
- Signature: public function getEncoding($encoding)
Parameters:
- $encoding
getFontMetric()
Get the font metrics to be used in calculating word-wrapping
- Signature: public &function getFontMetric()
- Returns (By Reference): I2ce_FontMetric $font_metric if null we are word-wrapping on characters
getHyphenDictionary()
Get the hyphenation dictionary to use
- Signature: public function getHyphenDictionary()
- Returns: I2CE_Hyphen $hyphen The hyphenation dictionary
getLineBreaks()
Function to get the line breaks in a paragraph for the text to fit in the current collumn
@param string $paragraph The text we want to fit in the text column
- Signature: public function getLineBreaks($text)
- Returns: array eof strings -- the rows of text
Parameters:
- $text
getParagraphs()
Function to split up a text based on newlines, or the characters corresponding to unicode codepoints:
- 0x2080 -- Line separator 0x2029 -- Paragraph separatory
Note: This works quickest if $text is ASCII friendly, then UTF-8, then in an arbitrary encoding
- Signature: public function getParagraphs($text)
- Returns: array of (possibly multibyte) strings the paragraphs
Parameters:
- $text
getWidth()
Gets the column's width @param int/float $width
- Signature: public function getWidth()
getWords()
- Signature: public function getWords($paragraph)
Parameters:
- $paragraph
setEncoding()
- Signature: public function setEncoding($encoding)
Parameters:
- $encoding
setFontMetric()
Set the font metrics to be used in calculating word-wrapping
- Signature: public function setFontMetric($font_metric)
Parameters:
- I2CE_FontMetric $font_metric
if null we are word-wrapping on characters
setHyphenationDictionary()
Set the hyphenation dictionary to use If null, no hyphenation is used
- Signature: public function setHyphenationDictionary($hyphen)
Parameters:
- I2CE_Hyphen $hyphen
The hyphenation dictionary
setWidth()
Set the column's width
- Signature: public function setWidth($width)
- Returns: numeric $width
Parameters:
- $width
setWordWrapAlgorithm()
Set the algorithm to use for word wrapping
Values are:
- 'Truncate'
- 'Greedy'
- 'Knuth'
- Signature: public function setWordWrapAlgorithm($algorithm)
- int $algorithm