Results object from a call to GetTextSize.
name | type | description |
---|---|---|
width | number |
The width of the longest line in the Text object. |
height | number |
The height of the Text object. |
lines | number |
The number of lines in the Text object. |
lineWidths | Array.<number> |
An array of the lines for each line in the Text object. |
lineSpacing | number |
The line spacing of the Text object. |
lineHeight | number |
The height of a line factoring in font and stroke. |
name | type | arguments | description |
---|---|---|---|
text | string | Array.<string> | <optional> |
The text this Text object will display. |
style | Phaser.Types.GameObjects.Text.TextStyle | <optional> |
The Text style configuration object. |
padding | Phaser.Types.GameObjects.Text.TextPadding | <optional> |
A Text Padding object. |
Font metrics for a Text Style object.
name | type | description |
---|---|---|
ascent | number |
The ascent of the font. |
descent | number |
The descent of the font. |
fontSize | number |
The size of the font. |
A Text Padding configuration object as used by the Text Style.
name | type | arguments | description |
---|---|---|---|
x | number | <optional> |
If set this value is used for both the left and right padding. |
y | number | <optional> |
If set this value is used for both the top and bottom padding. |
left | number | <optional> |
The amount of padding added to the left of the Text object. |
right | number | <optional> |
The amount of padding added to the right of the Text object. |
top | number | <optional> |
The amount of padding added to the top of the Text object. |
bottom | number | <optional> |
The amount of padding added to the bottom of the Text object. |
A Text Shadow configuration object as used by the Text Style.
name | type | arguments | Default | description |
---|---|---|---|---|
offsetX | number | <optional> | 0 |
The horizontal offset of the shadow. |
offsetY | number | <optional> | 0 |
The vertical offset of the shadow. |
color | string | <optional> | '#000' |
The color of the shadow, given as a CSS string value. |
blur | number | <optional> | 0 |
The amount of blur applied to the shadow. Leave as zero for a hard shadow. |
stroke | boolean | <optional> | false |
Apply the shadow to the stroke effect on the Text object? |
fill | boolean | <optional> | false |
Apply the shadow to the fill effect on the Text object? |
A Text Style configuration object as used by the Text Game Object.
name | type | arguments | Default | description |
---|---|---|---|---|
fontFamily | string | <optional> | 'Courier' |
The font the Text object will render with. This is a Canvas style font string. |
fontSize | number | string | <optional> | '16px' |
The font size, as a CSS size string. |
fontStyle | string | <optional> |
Any addition font styles, such as 'strong'. |
|
font | string | <optional> |
The font family or font settings to set. Overrides the other font settings. |
|
backgroundColor | string | <optional> |
A solid fill color that is rendered behind the Text object. Given as a CSS string color such as |
|
color | string | <optional> | '#fff' |
The color the Text is drawn in. Given as a CSS string color such as |
stroke | string | <optional> | '#fff' |
The color used to stroke the Text if the |
strokeThickness | number | <optional> | 0 |
The thickness of the stroke around the Text. Set to zero for no stroke. |
shadow | Phaser.Types.GameObjects.Text.TextShadow | <optional> |
The Text shadow configuration object. |
|
padding | Phaser.Types.GameObjects.Text.TextPadding | <optional> |
A Text Padding object. |
|
align | string | <optional> | 'left' |
The alignment of the Text. This only impacts multi-line text. Either |
maxLines | number | <optional> | 0 |
The maximum number of lines to display within the Text object. |
fixedWidth | number | <optional> | 0 |
Force the Text object to have the exact width specified in this property. Leave as zero for it to change accordingly to content. |
fixedHeight | number | <optional> | 0 |
Force the Text object to have the exact height specified in this property. Leave as zero for it to change accordingly to content. |
resolution | number | <optional> | 0 |
Sets the resolution (DPI setting) of the Text object. Leave at zero for it to use the game resolution. |
rtl | boolean | <optional> | false |
Set to |
testString | string | <optional> | '|MÉqgy' |
This is the string used to aid Canvas in calculating the height of the font. |
baselineX | number | <optional> | 1.2 |
The amount of horizontal padding added to the width of the text when calculating the font metrics. |
baselineY | number | <optional> | 1.4 |
The amount of vertical padding added to the height of the text when calculating the font metrics. |
wordWrap | Phaser.Types.GameObjects.Text.TextWordWrap | <optional> |
The Text Word wrap configuration object. |
|
metrics | Phaser.Types.GameObjects.Text.TextMetrics | <optional> |
A Text Metrics object. Use this to avoid expensive font size calculations in text heavy games. |
|
lineSpacing | number | <optional> |
The amount to add to the font height to achieve the overall line height. |
A Text Word Wrap configuration object as used by the Text Style configuration.
name | type | arguments | Default | description |
---|---|---|---|---|
width | number | <optional> |
The width at which text should be considered for word-wrapping. |
|
callback | TextStyleWordWrapCallback | <optional> |
Provide a custom callback when word wrapping is enabled. |
|
callbackScope | any | <optional> |
The context in which the word wrap callback is invoked. |
|
useAdvancedWrap | boolean | <optional> | false |
Use basic or advanced word wrapping? |