Namespace: Text

Phaser.Types.GameObjects. Text

Type Definitions


GetTextSizeObject

Results object from a call to GetTextSize.

Type:
  • object
Properties:
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.

Since: 3.0.0
Source: src/gameobjects/text/typedefs/GetTextSizeObject.js (Line 1)

TextConfig

Type:
  • object
Properties:
Name Type Argument 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.

Since: 3.0.0
Source: src/gameobjects/text/typedefs/TextConfig.js (Line 1)

TextMetrics

Font metrics for a Text Style object.

Type:
  • object
Properties:
Name Type Description
ascent number

The ascent of the font.

descent number

The descent of the font.

fontSize number

The size of the font.

Since: 3.0.0
Source: src/gameobjects/text/typedefs/TextMetrics.js (Line 1)

TextPadding

A Text Padding configuration object as used by the Text Style.

Type:
  • object
Properties:
Name Type Argument 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.

Since: 3.18.0
Source: src/gameobjects/text/typedefs/TextPadding.js (Line 1)

TextShadow

A Text Shadow configuration object as used by the Text Style.

Type:
  • object
Properties:
Name Type Argument 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?

Since: 3.0.0
Source: src/gameobjects/text/typedefs/TextShadow.js (Line 1)

TextStyle

A Text Style configuration object as used by the Text Game Object.

Type:
  • object
Properties:
Name Type Argument Default Description
fontFamily string <optional>
'Courier'

The font the Text object will render with. This is a Canvas style font string.

fontSize 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 #ff0.

color string <optional>
'#fff'

The color the Text is drawn in. Given as a CSS string color such as #fff or rgb().

stroke string <optional>
'#fff'

The color used to stroke the Text if the strokeThickness property is greater than zero.

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 left, right, center or justify.

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 true if this Text object should render from right-to-left.

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.

Since: 3.0.0
Source: src/gameobjects/text/typedefs/TextStyle.js (Line 1)

TextWordWrap

A Text Word Wrap configuration object as used by the Text Style configuration.

Type:
  • object
Properties:
Name Type Argument 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?

Since: 3.0.0
Source: src/gameobjects/text/typedefs/TextWordWrap.js (Line 1)