Phaser API Documentation

  Version: 
TextStyle

Description:

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

Properties:
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 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.

Type:
object
Since: 3.0.0