Static
defaultDefault drop shadow settings used when enabling drop shadows on text. These values are used as the base configuration when drop shadows are enabled without specific settings.
Static
defaultDefault text style settings used when creating new text objects. These values serve as the base configuration and can be customized globally.
Alignment for multiline text, does not affect single line text.
Indicates if lines can be wrapped within words, it needs wordWrap to be set to true.
Set a drop shadow for the text.
The fill style that will be used to color the text. This can be:
When using a FillGradient, vertical gradients (angle of 90 degrees) are applied per line of text, while gradients at any other angle are spread across the entire text body as a whole.
// Vertical gradient applied per line
const verticalGradient = new FillGradient(0, 0, 0, 1)
.addColorStop(0, 0xff0000)
.addColorStop(1, 0x0000ff);
const text = new Text({
text: 'Line 1\nLine 2',
style: { fill: verticalGradient }
});
To manage the gradient in a global scope, set the textureSpace property of the FillGradient to 'global'.
An optional filter or array of filters to apply to the text, allowing for advanced visual effects. These filters will be applied to the text as it is created, resulting in faster rendering for static text compared to applying the filter directly to the text object (which would be applied at run time).
The font family, can be a single font name, or a list of names where the first is the preferred font.
The font size (as a number it converts to px, but as a string, equivalents are '26px','20pt','160%' or '1.6em')
The font style.
The font variant.
The font weight.
The space between lines.
The amount of spacing between letters, default is 0.
The line height, a number that represents the vertical space that a letter uses.
Occasionally some fonts are cropped. Adding some padding will prevent this from happening by adding padding to all sides of the text.
This will NOT affect the positioning or bounds of the text.
A fillstyle that will be used on the text stroke, e.g., 'blue', '#FCFF00'.
The baseline of the text that is rendered.
Trim transparent borders from the text texture.
PERFORMANCE WARNING:
This is a costly operation as it requires scanning pixel alpha values.
Avoid using trim: true
for dynamic text, as it could significantly impact performance.
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 |
Indicates if word wrap should be used.
The width at which text will wrap, it needs wordWrap to be set to true.
Creates a new TextStyle object with the same values as this one.
New cloned TextStyle object
Destroys this text style.
Options parameter. A boolean will act as if all options have been set to that value
Resets all properties to the default values
A TextStyle Object contains information to decorate Text objects. An instance can be shared between multiple Text objects; then changing the style will update all text objects using it.
Example
Key Features: