TextStyle
final class TextStyle
Package: dev.joid.lib.font · Module: core · Source: TextStyle.java
The running style of the characters while a text is laid out, which markup tags change as they are read.
Description
Section titled “Description”A text renderer starts from TextInfo.getStyle, derives a working copy, and hands it to each ITextMarkup it meets: a tag of yours can set the weight, the color, the font or the effects of the characters that follow, and a closing tag resets them.
Each glyph keeps a copy of the style it was laid out with.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
TextStyle | create(FontWeight weight, boolean italic, Color color, ITextEffect… effects) factory | Creates a style without a base, with the given weight, italic flag, color and effects, and no font of its own. |
Properties
Section titled “Properties”| Property | Type | Default | Summary |
|---|---|---|---|
| font | IFont | set at creation | The font of the characters, or null to keep the font of the TextInfo; a font drawn by another text renderer is ignored with a dev-mode warning. |
| italic | boolean | set at creation | If true, the characters draw with the italic face, or slanted when the font has none. |
| color | Color | set at creation | The color of the characters; it applies when TextInfo.colored is true. |
| weight | FontWeight | set at creation | The FontWeight of the characters. |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
TextStyle | copy() | Returns a style with the same values and the same base. |
this | reset() fluent | Sets every value back to the base style; a style without a base is unchanged. |
TextStyle | derive() | Returns a working copy whose base is this style, so that reset() comes back to it. |
this | effect(ITextEffect effect) fluent | Adds an effect to the characters that follow, unless the style already has it. |
this | removeEffect(ITextEffect effect) fluent | Removes an effect from the characters that follow. |
TextStyle | getBase() | Returns the base style, or this style when it has none. |
List<ITextEffect> | getEffects() | Returns the effects of the characters, as a list you cannot change. |
Creation details
Section titled “Creation details”create
Section titled “create”TextStyle create(FontWeight weight, boolean italic, Color color, ITextEffect... effects) factory
Creates a style without a base, with the given weight, italic flag, color and effects, and no font of its own.
Property details
Section titled “Property details”this font(IFont font)fluentIFont getFont()
Default: set at creation
The font of the characters, or null to keep the font of the TextInfo; a font drawn by another text renderer is ignored with a dev-mode warning.
italic
Section titled “italic”this italic(boolean italic)fluentboolean isItalic()
Default: set at creation
If true, the characters draw with the italic face, or slanted when the font has none.
this color(Color color)fluentColor getColor()
Default: set at creation
The color of the characters; it applies when TextInfo.colored is true.
weight
Section titled “weight”this weight(FontWeight weight)fluentFontWeight getWeight()
Default: set at creation
The FontWeight of the characters.
Method details
Section titled “Method details”TextStyle copy()
Returns a style with the same values and the same base.
this reset() fluent
Sets every value back to the base style; a style without a base is unchanged.
derive
Section titled “derive”TextStyle derive()
Returns a working copy whose base is this style, so that reset() comes back to it.
effect
Section titled “effect”this effect(ITextEffect effect) fluent
Adds an effect to the characters that follow, unless the style already has it.
removeEffect
Section titled “removeEffect”this removeEffect(ITextEffect effect) fluent
Removes an effect from the characters that follow.
getBase
Section titled “getBase”TextStyle getBase()
Returns the base style, or this style when it has none.
getEffects
Section titled “getEffects”List<ITextEffect> getEffects()
Returns the effects of the characters, as a list you cannot change.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
