Skip to content

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.

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.

ReturnsSignatureSummary
TextStylecreate(FontWeight weight, boolean italic, Color color, ITextEffect… effects) factoryCreates a style without a base, with the given weight, italic flag, color and effects, and no font of its own.

PropertyTypeDefaultSummary
fontIFontset at creationThe 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.
italicbooleanset at creationIf true, the characters draw with the italic face, or slanted when the font has none.
colorColorset at creationThe color of the characters; it applies when TextInfo.colored is true.
weightFontWeightset at creationThe FontWeight of the characters.

ReturnsSignatureSummary
TextStylecopy()Returns a style with the same values and the same base.
thisreset() fluentSets every value back to the base style; a style without a base is unchanged.
TextStylederive()Returns a working copy whose base is this style, so that reset() comes back to it.
thiseffect(ITextEffect effect) fluentAdds an effect to the characters that follow, unless the style already has it.
thisremoveEffect(ITextEffect effect) fluentRemoves an effect from the characters that follow.
TextStylegetBase()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.

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.

  • this font(IFont font) fluent
  • IFont 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.

  • this italic(boolean italic) fluent
  • boolean 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) fluent
  • Color getColor()

Default: set at creation

The color of the characters; it applies when TextInfo.colored is true.

  • this weight(FontWeight weight) fluent
  • FontWeight getWeight()

Default: set at creation

The FontWeight of the characters.

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.


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

Report a problem with this page