#

API Docs for: 1.4.0
Show: Inherited Protected Private Deprecated

# Text Class

Extends Sprite
Defined in: `src/pixi/text/Text.js:5`
Module: PIXI

A Text Object will create a line(s) of text to split a line you can use '\n'

## Constructor

### `Text`

(

- `text`
- `[style]`

)

Defined in `src/pixi/text/Text.js:5`

#### Parameters:

- `text` String

  The copy that you would like the text to display

- `[style]` Object optional

  The style parameters

  - `[font]` String optional

    default 'bold 20pt Arial' The style and size of the font

  - `[fill='black']` Object optional

    A canvas fillstyle that will be used on the text eg 'red', '#00FF00'

  - `[align='left']` String optional

    An alignment of the multiline text ('left', 'center' or 'right')

  - `[stroke]` String optional

    A canvas fillstyle that will be used on the text stroke eg 'blue', '#FCFF00'

  - `[strokeThickness=0]` Number optional

    A number that represents the thickness of the stroke. Default is 0 (no stroke)

  - `[wordWrap=false]` Boolean optional

    Indicates if word wrap should be used

  - `[wordWrapWidth=100]` Number optional

    The width at which text will wrap

- Index
- Methods

## Item Index

### Methods

- destroy
- setStyle
- setText
- updateText
- updateTexture
- updateTransform
- wordWrap

## Methods

### `destroy`

(

- `destroyTexture`

)

Defined in `src/pixi/text/Text.js:260`

Destroys this text object

#### Parameters:

- `destroyTexture` Boolean

### `setStyle`

(

- `[style]`
- `[style.font='bold`

)

Defined in `src/pixi/text/Text.js:38`

Set the style of the text

#### Parameters:

- `[style]` Object optional

  The style parameters

  - `[fill='black']` Object optional

    A canvas fillstyle that will be used on the text eg 'red', '#00FF00'

  - `[align='left']` String optional

    An alignment of the multiline text ('left', 'center' or 'right')

  - `[stroke='black']` String optional

    A canvas fillstyle that will be used on the text stroke eg 'blue', '#FCFF00'

  - `[strokeThickness=0]` Number optional

    A number that represents the thickness of the stroke. Default is 0 (no stroke)

  - `[wordWrap=false]` Boolean optional

    Indicates if word wrap should be used

  - `[wordWrapWidth=100]` Number optional

    The width at which text will wrap

- `[style.font='bold` String

  20pt Arial'] The style and size of the font

### `setText`

(

- `text`

)

Defined in `src/pixi/text/Text.js:65`

Set the copy for the text object. To split a line you can use '\n'

#### Parameters:

- `text` String

  The copy that you would like the text to display

### `updateText`

() private

Defined in `src/pixi/text/Text.js:77`

Renders text

### `updateTexture`

() private

Defined in `src/pixi/text/Text.js:148`

Updates texture size based on canvas size

### `updateTransform`

() private

Defined in `src/pixi/text/Text.js:167`

Updates the transfor of this object

### `wordWrap`

(

- `text`

)
private

Defined in `src/pixi/text/Text.js:216`

Applies newlines to a string to have it optimally fit into the horizontal bounds set by the Text object's wordWrapWidth property.

#### Parameters:

- `text` String