Name | Type | Description |
---|---|---|
text |
string |
the text that was measured |
style |
PIXI.TextStyle |
the style that was measured |
width |
number |
the measured width of the text |
height |
number |
the measured height of the text |
lines |
Array |
an array of the lines of text broken by new lines and wrapping if specified in style |
lineWidths |
Array |
an array of the line widths for each line matched to |
lineHeight |
number |
the measured line height for this style |
maxLineWidth |
number |
the maximum line width for all measured lines |
fontProperties |
Object |
the font properties object from TextMetrics.measureFont |
Members
Baseline multiplier for calculate font metrics.
- Default Value:
- 1.4
Baseline symbol for calculate font metrics.
- Default Value:
- M
String used for calculate font metrics. These characters are all tall to help calculate the height required for text.
- Default Value:
- |ÉqÅ
fontProperties PIXI.IFontMetrics
The font properties object from TextMetrics.measureFont
The measured height of the text
The measured line height for this style
An array of lines of the text broken by new lines and wrapping is specified in style
An array of the line widths for each line matched to lines
The maximum line width for all measured lines
style PIXI.TextStyle
The style that was measured
The text that was measured
The measured width of the text
Methods
Overridable helper method used internally by TextMetrics, exposed to allow customizing the class's behavior.
It allows one to determine whether a pair of characters should be broken by newlines For example certain characters in CJK langs or numbers. It must return a boolean.
Name | Type | Description |
---|---|---|
char |
string |
The character |
nextChar |
string |
The next character |
token |
string |
The token/word the characters are from |
index |
number |
The index in the token of the char |
breakWords |
boolean |
The style attr break words |
Returns:
Type | Description |
---|---|
boolean | whether to break word or not |
Overridable helper method used internally by TextMetrics, exposed to allow customizing the class's behavior.
It allows one to customise which words should break Examples are if the token is CJK or numbers. It must return a boolean.
Name | Type | Description |
---|---|---|
token |
string |
The token |
breakWords |
boolean |
The style attr break words |
Returns:
Type | Description |
---|---|
boolean | whether to break word or not |
Clear font metrics in metrics cache.
Name | Type | Attributes | Description |
---|---|---|---|
font |
string |
<optional> |
font name. If font name not set then clear cache for all fonts. |
PIXI.TextMetrics.measureFont (font) PIXI.IFontMetrics static
Calculates the ascent, descent and fontSize of a given font-style
Name | Type | Description |
---|---|---|
font |
string |
String representing the style of the font |
Returns:
Type | Description |
---|---|
PIXI.IFontMetrics | Font properties object |
PIXI.TextMetrics.measureText (text, style, wordWrap, canvas) PIXI.TextMetrics static
Measures the supplied string of text and returns a Rectangle.
Name | Type | Attributes | Description |
---|---|---|---|
text |
string |
the text to measure. |
|
style |
PIXI.TextStyle |
the text style to use for measuring |
|
wordWrap |
boolean |
<optional> |
optional override for if word-wrap should be applied to the text. |
canvas |
HTMLCanvasElement |
<optional> |
optional specification of the canvas to use for measuring. |
Returns:
Type | Description |
---|---|
PIXI.TextMetrics | measured width and height of the text. |
Overridable helper method used internally by TextMetrics, exposed to allow customizing the class's behavior.
It is called when a token (usually a word) has to be split into separate pieces in order to determine the point to break a word. It must return an array of characters.
Name | Type | Description |
---|---|---|
token |
string |
The token to split |
Returns:
Type | Description |
---|---|
Array |
The characters of the token |
Example
// Correctly splits emojis, eg "🤪🤪" will result in two element array, each with one emoji.
TextMetrics.wordWrapSplit = (token) => [...token];