TextStyle

class TextStyle(val fontName: String, val fontSize: Float = 10.0f, val hAlign: HAlignment = HAlignment.LEFT, val vAlign: VAlignment = VAlignment.BASELINE, val spacing: Double = 1.0, val direction: TextDirection = TextDirection.LTR, val lineSpacing: Double = 1.0, val color: Color? = null) : Customisable

A TextStyle allows you to define a style, and then use it for many Text objects, which cuts down on duplicate code.

TextStyle is immutable, and methods such as font, fontSize, hAlign etc all return a new TextStyle, leaving the original untouched.

Constructors

Link copied to clipboard
constructor()
constructor(fontName: String)
constructor(fontName: String, fontSize: Float)
constructor(fontName: String, fontSize: Float = 10.0f, hAlign: HAlignment = HAlignment.LEFT, vAlign: VAlignment = VAlignment.BASELINE, spacing: Double = 1.0, direction: TextDirection = TextDirection.LTR, lineSpacing: Double = 1.0, color: Color? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val color: Color? = null
Link copied to clipboard

The direction of the text. The default is TextDirection.LTR

Link copied to clipboard

The default is "Liberation Sans". For common font names see FontNames.

Link copied to clipboard
val fontSize: Float = 10.0f

The default font size is 10

Link copied to clipboard
Link copied to clipboard

For multi-line text, controls the spacing between lines. This is a scaling factor, e.g. a value of 2 would make the lines twice as far apart as normal. The default is 1.0

Link copied to clipboard

A scaling factor for spacing the characters out. The default is 1.0

Link copied to clipboard

Functions

Link copied to clipboard
Link copied to clipboard
fun color(colorName: String): TextStyle
fun color(color: Color): TextStyle
Link copied to clipboard
Link copied to clipboard
fun font(font: String): TextStyle
Link copied to clipboard
Link copied to clipboard
fun fontSize(fontSize: Float): TextStyle
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun lineSpacing(lineSpacing: Double): TextStyle
Link copied to clipboard
fun scale(scale: Float): TextStyle
Link copied to clipboard
Link copied to clipboard
fun spacing(spacing: Double): TextStyle
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard