Class: Text

Text

A Text Object will create a line or multiple lines of text.

To split a line you can use '\n' in your text string, or, on the style object, change its wordWrap property to true and and givae the wordWrapWidth property a value.

The primary advantage of this class over BitmapText is that you have great control over the style of the text, which you can change at runtime.

The primary disadvantages is that each piece of text has it's own texture, which can use more memory. When text changes, this texture has to be re-generated and re-uploaded to the GPU, taking up time.

new Text (…options)

Name Type Description
options TextOptions

The options of the text.

Example

 import { Text } from 'pixi.js';

 const text = new Text({
     text: 'Hello Pixi!',
     style: {
         fontFamily: 'Arial',
         fontSize: 24,
         fill: 0xff1010,
         align: 'center',
     }
 });

Implements