Class: I2CE TextCell (4.1.7)

From IHRIS Wiki
(Redirected from Class: I2CE TextCell)


This article describes the class I2CE_TextCell .

A word-wrapping text cell class. Uses the i2ce_hyphen class.

Variables

$font_metric

protected @var I2CE_FontMetrics $font_metric the font we are using

$encoding

protected @var I2CE_Encoding $encoding the encoding we are using

$space_char

The space character in this encoding

$hyphen_char

The hyphen character in this encoding

$width

protected @var mixed $width the width of the cell (float or int)

$hyphen

protected @var I2CE_Hyphen $hyphen a hyphenation dictionary

Methods

Greedy()

Word-wrap a paragraph using simple truncation. Assume no \n Removes all \r All white spaces are squased to a single space

  • Defined in textlayout/lib/I2CE_TextCell.php on line 350
  • Signature: protected function Greedy($paragraph,$text_lines)
  • Parameters:
    • $paragraph
    • array $text_lines
      the array to store the text lines. It starts appending on the last element of the array

Knuth()

Truncate()

Word-wrap a paragraph using simple truncation. Assume no \n Removes all \r All white spaces are squased to a single space

__construct()

Construct a text cell object

  • Defined in textlayout/lib/I2CE_TextCell.php on line 127
  • 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' @param I2CE_Encoding encoding -- the encoding we want to use
      • Default Value: 'Greedy'

getEncoding()

getFontMetric()

Get the font metrics to be used in calculating word-wrapping

  • Defined in textlayout/lib/I2CE_TextCell.php on line 61
  • 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

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

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

getWidth()

Gets the column's width @param int/float $width

getWords()

setEncoding()

setFontMetric()

Set the font metrics to be used in calculating word-wrapping

setHyphenationDictionary()

Set the hyphenation dictionary to use

setWidth()

Set the column's width

setWordWrapAlgorithm()

Set the algorithm to use for word wrapping

  • Defined in textlayout/lib/I2CE_TextCell.php on line 116
  • Signature: public function setWordWrapAlgorithm($algorithm)
  • Parameters:
    • int $algorithm Values are:
      • 'Truncate'
      • 'Greedy'
      • 'Knuth'