Example
import { TextStyle } from 'pixi.js';
const style = new TextStyle({
fontFamily: ['Helvetica', 'Arial', 'sans-serif'],
fontSize: 36,
});
Members
See TextStyle.align
- Default Value:
- "left"
Alignment for multiline text, does not affect single line text.
See TextStyle.breakWords
- Default Value:
- false
Indicates if lines can be wrapped within words, it needs wordWrap to be set to true.
See TextStyle.dropShadow
- Default Value:
- undefined
dropShadow TextDropShadow
Set a drop shadow for the text.
See TextStyle.fill
- Default Value:
- "black"
A fillstyle that will be used on the text e.g., 'red', '#00FF00'.
See TextStyle.fontFamily
- Default Value:
- "Arial"
The font family, can be a single font name, or a list of names where the first is the preferred font.
See TextStyle.fontSize
- Default Value:
- 26
The font size (as a number it converts to px, but as a string, equivalents are '26px','20pt','160%' or '1.6em')
See TextStyle.fontStyle
- Default Value:
- "normal"
The font style.
See TextStyle.fontVariant
- Default Value:
- "normal"
The font variant.
See TextStyle.fontWeight
- Default Value:
- "normal"
The font weight.
See TextStyle.leading
- Default Value:
- 0
The space between lines.
See TextStyle.letterSpacing
- Default Value:
- 0
The amount of spacing between letters, default is 0.
See TextStyle.lineHeight
- Default Value:
- 0
The line height, a number that represents the vertical space that a letter uses.
See TextStyle.padding
- Default Value:
- 0
Occasionally some fonts are cropped. Adding some padding will prevent this from happening by adding padding to all sides of the text.
See TextStyle.stroke
- Default Value:
- undefined
A fillstyle that will be used on the text stroke, e.g., 'blue', '#FCFF00'.
See TextStyle.textBaseline
- Default Value:
- "alphabetic"
The baseline of the text that is rendered.
See TextStyle.trim
- Default Value:
- false
Trim transparent borders. This is an expensive operation so only use this if you have to!
See TextStyle.whiteSpace
- Default Value:
- "pre"
How newlines and spaces should be handled. Default is 'pre' (preserve, preserve).
value | New lines | Spaces |
---|---|---|
'normal' | Collapse | Collapse |
'pre' | Preserve | Preserve |
'pre-line' | Preserve | Collapse |
See TextStyle.wordWrap
- Default Value:
- false
Indicates if word wrap should be used.
See TextStyle.wordWrapWidth
- Default Value:
- 100
The width at which text will wrap, it needs wordWrap to be set to true.
Methods
Creates a new TextStyle object with the same values as this one.
Returns:
Type | Description |
---|---|
TextStyle | New cloned TextStyle object |
Destroys this text style.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
options |
TypeOrBool<TextureDestroyOptions> | false |
Options parameter. A boolean will act as if all options have been set to that value |
|
options.texture |
boolean |
<optional> |
false |
Should it destroy the texture of the this style |
options.textureSource |
boolean |
<optional> |
false |
Should it destroy the textureSource of the this style |