Class: I2CE TextCell (Development): Difference between revisions
No edit summary |
No edit summary |
||
Line 3: | Line 3: | ||
*Child Classes: | *Child Classes: | ||
** [[Class: I2CE_TextTable (Development) | I2CE_TextTable]] | ** [[Class: I2CE_TextTable (Development) | I2CE_TextTable]] | ||
*Location: Part of the module [[TextLayout Tools Module List (Development)#textlayout|textlayout]] in the package [https://launchpad.net/textlayout TextLayout Tools] 4. | *Location: Part of the module [[TextLayout Tools Module List (Development)#textlayout|textlayout]] in the package [https://launchpad.net/textlayout TextLayout Tools] 4.1-dev | ||
*Source: Defined in the file [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Source: Defined in the file [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L21 lib/I2CE_TextCell.php] on line 21 | ||
*Author: Carl Leitner <litlfred@ibiblio.org> | *Author: Carl Leitner <litlfred@ibiblio.org> | ||
A word-wrapping text cell class. Uses the i2ce_hyphen class. | A word-wrapping text cell class. Uses the i2ce_hyphen class. | ||
Line 10: | Line 10: | ||
===$font_metric=== | ===$font_metric=== | ||
protected @var I2CE_FontMetrics $font_metric the font we are using | protected @var I2CE_FontMetrics $font_metric the font we are using | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L25 textlayout/lib/I2CE_TextCell.php] on line 25 | ||
*Type: protected $font_metric | *Type: protected $font_metric | ||
===$encoding=== | ===$encoding=== | ||
protected @var I2CE_Encoding $encoding the encoding we are using | protected @var I2CE_Encoding $encoding the encoding we are using | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L30 textlayout/lib/I2CE_TextCell.php] on line 30 | ||
*Type: protected $encoding | *Type: protected $encoding | ||
===$space_char=== | ===$space_char=== | ||
The space character in this encoding | The space character in this encoding | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L35 textlayout/lib/I2CE_TextCell.php] on line 35 | ||
*Type: protected [http://www.php.net/manual/en/language.types.string.php string ] $space_char | *Type: protected [http://www.php.net/manual/en/language.types.string.php string ] $space_char | ||
===$hyphen_char=== | ===$hyphen_char=== | ||
The hyphen character in this encoding | The hyphen character in this encoding | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L39 textlayout/lib/I2CE_TextCell.php] on line 39 | ||
*Type: protected [http://www.php.net/manual/en/language.types.string.php string ] $hyphen_char | *Type: protected [http://www.php.net/manual/en/language.types.string.php string ] $hyphen_char | ||
===$width=== | ===$width=== | ||
protected @var mixed $width the width of the cell (float or int) | protected @var mixed $width the width of the cell (float or int) | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L68 textlayout/lib/I2CE_TextCell.php] on line 68 | ||
*Type: protected $width | *Type: protected $width | ||
===$hyphen=== | ===$hyphen=== | ||
protected @var I2CE_Hyphen $hyphen a hyphenation dictionary | protected @var I2CE_Hyphen $hyphen a hyphenation dictionary | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L90 textlayout/lib/I2CE_TextCell.php] on line 90 | ||
*Type: protected $hyphen | *Type: protected $hyphen | ||
Line 41: | Line 41: | ||
===Greedy()=== | ===Greedy()=== | ||
Word-wrap a paragraph using simple truncation. Assume no \n Removes all \r All white spaces are squased to a single space | Word-wrap a paragraph using simple truncation. Assume no \n Removes all \r All white spaces are squased to a single space | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L350 textlayout/lib/I2CE_TextCell.php] on line 350 | ||
*Signature: protected function Greedy($paragraph,$text_lines) | *Signature: protected function Greedy($paragraph,$text_lines) | ||
*Parameters: | *Parameters: | ||
Line 47: | Line 47: | ||
** [http://www.php.net/manual/en/language.types.array.php array ] $text_lines <br/>the array to store the text lines. It starts appending on the last element of the array | ** [http://www.php.net/manual/en/language.types.array.php array ] $text_lines <br/>the array to store the text lines. It starts appending on the last element of the array | ||
===Knuth()=== | ===Knuth()=== | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L633 textlayout/lib/I2CE_TextCell.php] on line 633 | ||
*Signature: protected function Knuth($paragraph,$text_lines) | *Signature: protected function Knuth($paragraph,$text_lines) | ||
*Parameters: | *Parameters: | ||
Line 54: | Line 54: | ||
===Truncate()=== | ===Truncate()=== | ||
Word-wrap a paragraph using simple truncation. Assume no \n Removes all \r All white spaces are squased to a single space | Word-wrap a paragraph using simple truncation. Assume no \n Removes all \r All white spaces are squased to a single space | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L268 textlayout/lib/I2CE_TextCell.php] on line 268 | ||
*Signature: protected function Truncate($paragraph,$text_lines) | *Signature: protected function Truncate($paragraph,$text_lines) | ||
*Parameters: | *Parameters: | ||
Line 61: | Line 61: | ||
===__construct()=== | ===__construct()=== | ||
Construct a text cell object | Construct a text cell object | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L127 textlayout/lib/I2CE_TextCell.php] on line 127 | ||
*Signature: public function __construct($font_metric,$hyphen,$encoding,$algorithm) | *Signature: public function __construct($font_metric,$hyphen,$encoding,$algorithm) | ||
*Parameters: | *Parameters: | ||
Line 71: | Line 71: | ||
***Default Value: 'Greedy' | ***Default Value: 'Greedy' | ||
===getEncoding()=== | ===getEncoding()=== | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L45 textlayout/lib/I2CE_TextCell.php] on line 45 | ||
*Signature: public function getEncoding($encoding) | *Signature: public function getEncoding($encoding) | ||
*Parameters: | *Parameters: | ||
Line 77: | Line 77: | ||
===getFontMetric()=== | ===getFontMetric()=== | ||
Get the font metrics to be used in calculating word-wrapping | Get the font metrics to be used in calculating word-wrapping | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L61 textlayout/lib/I2CE_TextCell.php] on line 61 | ||
*Signature: public &function getFontMetric() | *Signature: public &function getFontMetric() | ||
*Returns (By Reference): I2ce_FontMetric<br/>$font_metric if null we are word-wrapping on characters | *Returns (By Reference): I2ce_FontMetric<br/>$font_metric if null we are word-wrapping on characters | ||
===getHyphenDictionary()=== | ===getHyphenDictionary()=== | ||
Get the hyphenation dictionary to use | Get the hyphenation dictionary to use | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L105 textlayout/lib/I2CE_TextCell.php] on line 105 | ||
*Signature: public function getHyphenDictionary() | *Signature: public function getHyphenDictionary() | ||
*Returns: [[Class: I2CE_Hyphen (Development) | I2CE_Hyphen]]<br/>$hyphen The hyphenation dictionary | *Returns: [[Class: I2CE_Hyphen (Development) | I2CE_Hyphen]]<br/>$hyphen The hyphenation dictionary | ||
===getLineBreaks()=== | ===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 | 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 | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L203 textlayout/lib/I2CE_TextCell.php] on line 203 | ||
*Signature: public function getLineBreaks($text) | *Signature: public function getLineBreaks($text) | ||
*Parameters: | *Parameters: | ||
Line 94: | Line 94: | ||
===getParagraphs()=== | ===getParagraphs()=== | ||
Function to split up a text based on newlines, or the characters corresponding to unicode codepoints: <ul><li>0x2080 -- Line separator</li> <li></li>0x2029 -- Paragraph separatory</ul> Note: This works quickest if $text is ASCII friendly, then UTF-8, then in an arbitrary encoding | Function to split up a text based on newlines, or the characters corresponding to unicode codepoints: <ul><li>0x2080 -- Line separator</li> <li></li>0x2029 -- Paragraph separatory</ul> Note: This works quickest if $text is ASCII friendly, then UTF-8, then in an arbitrary encoding | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L152 textlayout/lib/I2CE_TextCell.php] on line 152 | ||
*Signature: public function getParagraphs($text) | *Signature: public function getParagraphs($text) | ||
*Parameters: | *Parameters: | ||
Line 101: | Line 101: | ||
===getWidth()=== | ===getWidth()=== | ||
Gets the column's width @param int/float $width | Gets the column's width @param int/float $width | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L82 textlayout/lib/I2CE_TextCell.php] on line 82 | ||
*Signature: public function getWidth() | *Signature: public function getWidth() | ||
===getWords()=== | ===getWords()=== | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L239 textlayout/lib/I2CE_TextCell.php] on line 239 | ||
*Signature: public function getWords($paragraph) | *Signature: public function getWords($paragraph) | ||
*Parameters: | *Parameters: | ||
**$paragraph | **$paragraph | ||
===setEncoding()=== | ===setEncoding()=== | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L41 textlayout/lib/I2CE_TextCell.php] on line 41 | ||
*Signature: public function setEncoding($encoding) | *Signature: public function setEncoding($encoding) | ||
*Parameters: | *Parameters: | ||
Line 115: | Line 115: | ||
===setFontMetric()=== | ===setFontMetric()=== | ||
Set the font metrics to be used in calculating word-wrapping | Set the font metrics to be used in calculating word-wrapping | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L53 textlayout/lib/I2CE_TextCell.php] on line 53 | ||
*Signature: public function setFontMetric($font_metric) | *Signature: public function setFontMetric($font_metric) | ||
*Parameters: | *Parameters: | ||
Line 121: | Line 121: | ||
===setHyphenationDictionary()=== | ===setHyphenationDictionary()=== | ||
Set the hyphenation dictionary to use | Set the hyphenation dictionary to use | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L97 textlayout/lib/I2CE_TextCell.php] on line 97 | ||
*Signature: public function setHyphenationDictionary($hyphen) | *Signature: public function setHyphenationDictionary($hyphen) | ||
*Parameters: | *Parameters: | ||
Line 127: | Line 127: | ||
===setWidth()=== | ===setWidth()=== | ||
Set the column's width | Set the column's width | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L74 textlayout/lib/I2CE_TextCell.php] on line 74 | ||
*Signature: public function setWidth($width) | *Signature: public function setWidth($width) | ||
*Parameters: | *Parameters: | ||
Line 134: | Line 134: | ||
===setWordWrapAlgorithm()=== | ===setWordWrapAlgorithm()=== | ||
Set the algorithm to use for word wrapping | Set the algorithm to use for word wrapping | ||
*Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4. | *Defined in [http://bazaar.launchpad.net/~intrahealth+informatics/textlayout/4.1-dev/annotate/head:/lib/I2CE_TextCell.php#L116 textlayout/lib/I2CE_TextCell.php] on line 116 | ||
*Signature: public function setWordWrapAlgorithm($algorithm) | *Signature: public function setWordWrapAlgorithm($algorithm) | ||
*Parameters: | *Parameters: |
Latest revision as of 08:20, 6 May 2015
This article describes the class I2CE_TextCell .
- Child Classes:
- Location: Part of the module textlayout in the package TextLayout Tools 4.1-dev
- Source: Defined in the file lib/I2CE_TextCell.php on line 21
- Author: Carl Leitner <litlfred@ibiblio.org>
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
- Defined in textlayout/lib/I2CE_TextCell.php on line 25
- Type: protected $font_metric
$encoding
protected @var I2CE_Encoding $encoding the encoding we are using
- Defined in textlayout/lib/I2CE_TextCell.php on line 30
- Type: protected $encoding
$space_char
The space character in this encoding
- Defined in textlayout/lib/I2CE_TextCell.php on line 35
- Type: protected string $space_char
$hyphen_char
The hyphen character in this encoding
- Defined in textlayout/lib/I2CE_TextCell.php on line 39
- Type: protected string $hyphen_char
$width
protected @var mixed $width the width of the cell (float or int)
- Defined in textlayout/lib/I2CE_TextCell.php on line 68
- Type: protected $width
$hyphen
protected @var I2CE_Hyphen $hyphen a hyphenation dictionary
- Defined in textlayout/lib/I2CE_TextCell.php on line 90
- 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
- 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()
- Defined in textlayout/lib/I2CE_TextCell.php on line 633
- 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
- Defined in textlayout/lib/I2CE_TextCell.php on line 268
- Signature: protected function Truncate($paragraph,$text_lines)
- Parameters:
__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()
- Defined in textlayout/lib/I2CE_TextCell.php on line 45
- Signature: public function getEncoding($encoding)
- Parameters:
- $encoding
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
- Defined in textlayout/lib/I2CE_TextCell.php on line 105
- 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
- Defined in textlayout/lib/I2CE_TextCell.php on line 203
- Signature: public function getLineBreaks($text)
- Parameters:
- $text
- Returns: array
eof strings -- the rows of 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
- Defined in textlayout/lib/I2CE_TextCell.php on line 152
- Signature: public function getParagraphs($text)
- Parameters:
- $text
- Returns: array
of (possibly multibyte) strings the paragraphs
getWidth()
Gets the column's width @param int/float $width
- Defined in textlayout/lib/I2CE_TextCell.php on line 82
- Signature: public function getWidth()
getWords()
- Defined in textlayout/lib/I2CE_TextCell.php on line 239
- Signature: public function getWords($paragraph)
- Parameters:
- $paragraph
setEncoding()
- Defined in textlayout/lib/I2CE_TextCell.php on line 41
- Signature: public function setEncoding($encoding)
- Parameters:
- $encoding
setFontMetric()
Set the font metrics to be used in calculating word-wrapping
- Defined in textlayout/lib/I2CE_TextCell.php on line 53
- Signature: public function setFontMetric($font_metric)
- Parameters:
- I2CE_FontMetric $font_metric
if null we are word-wrapping on characters
- I2CE_FontMetric $font_metric
setHyphenationDictionary()
Set the hyphenation dictionary to use
- Defined in textlayout/lib/I2CE_TextCell.php on line 97
- Signature: public function setHyphenationDictionary($hyphen)
- Parameters:
- I2CE_Hyphen $hyphen
The hyphenation dictionary If null, no hyphenation is used
- I2CE_Hyphen $hyphen
setWidth()
Set the column's width
- Defined in textlayout/lib/I2CE_TextCell.php on line 74
- Signature: public function setWidth($width)
- Parameters:
- $width
- Returns: numeric
$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'
- int $algorithm Values are: