Extends
Members
List of style overrides that will be applied to the HTML text.
tagStyles Record<string, HTMLTextStyleOptions>
List of styles per tag.
Example
new HTMLText({
text:'<red>Red</red>,<blue>Blue</blue>,<green>Green</green>',
style:{
fontFamily: 'DM Sans',
fill: 'white',
fontSize:100,
tagStyles:{
red:{
fill:'red',
},
blue:{
fill:'blue',
},
green:{
fill:'green',
}
}
}
);
Methods
Add a style override, this can be any CSS property
it will override any built-in style. This is the
property and the value as a string (e.g., color: red
).
This will override any other internal style.
Name | Type | Description |
---|---|---|
value |
string |
CSS style(s) to add. |
Example
style.addOverride('background-color: red');
clone () HTMLTextStyle overrides
Creates a new HTMLTextStyle object with the same values as this one.
Returns:
Type | Description |
---|---|
HTMLTextStyle | New cloned HTMLTextStyle object |
Remove any overrides that match the value.
Name | Type | Description |
---|---|---|
value |
string |
CSS style to remove. |
Example
style.removeOverride('background-color: red');
Inherited Properties
From class TextStyle
align 'left' | 'center' | 'right' | 'justify' inherited
Alignment for multiline text, does not affect single line text.
breakWords boolean inherited
Indicates if lines can be wrapped within words, it needs wordWrap to be set to true.
dropShadow TextDropShadow inherited
Set a drop shadow for the text.
A fillstyle that will be used on the text e.g., 'red', '#00FF00'.
fontFamily string | string[] inherited
The font family, can be a single font name, or a list of names where the first is the preferred font.
fontSize number inherited
The font size (as a number it converts to px, but as a string, equivalents are '26px','20pt','160%' or '1.6em')
fontStyle 'normal' | 'italic' | 'oblique' inherited
The font style.
fontVariant 'normal' | 'small-caps' inherited
The font variant.
fontWeight 'normal' | 'bold' | 'bolder' | 'lighter' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900' inherited
The font weight.
leading number inherited
The space between lines.
letterSpacing number inherited
The amount of spacing between letters, default is 0.
lineHeight number inherited
The line height, a number that represents the vertical space that a letter uses.
padding number inherited
Occasionally some fonts are cropped. Adding some padding will prevent this from happening by adding padding to all sides of the text.
stroke StrokeInput inherited
A fillstyle that will be used on the text stroke, e.g., 'blue', '#FCFF00'.
textBaseline 'alphabetic' | 'top' | 'hanging' | 'middle' | 'ideographic' | 'bottom' inherited
The baseline of the text that is rendered.
trim boolean inherited
Trim transparent borders. This is an expensive operation so only use this if you have to!
whiteSpace 'normal' | 'pre' | 'pre-line' inherited
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 |
wordWrap boolean inherited
Indicates if word wrap should be used.
wordWrapWidth number inherited
The width at which text will wrap, it needs wordWrap to be set to true.
Inherited Methods
From class TextStyle
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 |
Resets all properties to the default values