\src\Utils\Font\FontMetric.inc

Show: inherited
Table of Contents

\Utils\Font\FontMetric

Package: Default

This class encapsulates font metrics, i.e. for a given font family and font size given as text stlye, it can calculate the width and height of a string or a collection of strings.

Properties

Propertyprivate\Utils\Font\ArrayObject  $metrics= 'null'

the metrics of the TextStyle, i.e. a mapping from the ASCII code of the TextStyle to the width of the respective character

Default valuenullDetails
Type
\Utils\Font\ArrayObject
Propertyprivate\Utils\Graphics2D\Shapes\Styles\TextStyle  $textStyle= 'null'

the TextStyle the FontMetric is based on

Default valuenullDetails
Type
\Utils\Graphics2D\Shapes\Styles\TextStyle

Methods

methodpublic__construct( \Utils\Graphics2D\Shapes\Styles\TextStyle $textStyle, \int[] $charMetrics ) : void

This acts as the constructor of the class.

Parameters
Name Type Description
$textStyle \Utils\Graphics2D\Shapes\Styles\TextStyle

the text style to use for the metric

$charMetrics \int[]

the metrics of the text style, i.e. a mapping from the ASCII code of the TextStyle to the width of the respective character

methodpublicgetHash( ) : string

This method return a hash of the FontMetric.

Returns
Type Description
string the hash of the FontMetric
methodpublicgetHeight( string $string ) : int

This method calculates the height of a string in pixel.

Parameters
Name Type Description
$string string

the string whose height has to be calculated

Returns
Type Description
int the height of the string in pixels
methodpublicgetMaxHeight( \Traversable $strings ) : int

This method calculates the maximal height of a string in a collection of strings.

Parameters
Name Type Description
$strings \Traversable

the collection of strings

Returns
Type Description
int the maximal height of the strings in the collection
methodpublicgetMaxWidth( \Traversable $strings ) : int

This method calculates the maximal width of a string in a collection of strings.

Parameters
Name Type Description
$strings \Traversable

the collection of strings

Returns
Type Description
int the maximal width of the strings in the collection
methodpublicgetWidth( string $string ) : int

This method calculates the width of a string in pixel.

Parameters
Name Type Description
$string string

the string whose width has to be calculated

Returns
Type Description
int the width of the string in pixels
methodprivatesplitToLines( \Traversable $strings ) : \Utils\Font\ArrayObject
static

This method splits each string in a collection of strings into a set of strings with no line breaks, and returns all line-break-free strings as ArrayObject.

Parameters
Name Type Description
$strings \Traversable

the collection of string to split

Returns
Type Description
\Utils\Font\ArrayObject the collection of strings without line breaks
Documentation was generated by DocBlox 0.15.1.