CurvedTextStyle

class CurvedTextStyle


Styling configuration for a curved text.

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.text.BasicText
import androidx.compose.ui.text.TextStyle
import androidx.wear.compose.foundation.CurvedLayout
import androidx.wear.compose.foundation.CurvedTextStyle
import androidx.wear.compose.foundation.background
import androidx.wear.compose.foundation.basicCurvedText
import androidx.wear.compose.foundation.curvedComposable
import androidx.wear.compose.foundation.padding
import androidx.wear.compose.foundation.size

CurvedLayout(modifier = Modifier.fillMaxSize()) {
    basicCurvedText(
        "Curved Text",
        CurvedModifier.padding(10.dp),
        style = {
            CurvedTextStyle(
                fontSize = 16.sp,
                color = Color.Black,
                background = Color.White
            )
        }
    )
    curvedComposable {
        Box(modifier = Modifier
            .size(20.dp)
            .background(Color.Gray))
    }
    curvedComposable {
        BasicText(
            "Normal Text",
            Modifier.padding(5.dp),
            TextStyle(
                fontSize = 16.sp,
                color = Color.Black,
                background = Color.White
            )
        )
    }
}

Summary

Public constructors

Create a curved text style from the given text style.

CurvedTextStyle(
    background: Color,
    color: Color,
    fontSize: TextUnit,
    fontFamily: FontFamily?,
    fontWeight: FontWeight?,
    fontStyle: FontStyle?,
    fontSynthesis: FontSynthesis?
)

Public functions

CurvedTextStyle
copy(background: Color, color: Color, fontSize: TextUnit)

This function is deprecated. This overload is provided for backwards compatibility with Compose for Wear OS 1.0.

CurvedTextStyle
copy(
    background: Color,
    color: Color,
    fontSize: TextUnit,
    fontFamily: FontFamily?,
    fontWeight: FontWeight?,
    fontStyle: FontStyle?,
    fontSynthesis: FontSynthesis?
)
open operator Boolean
equals(other: Any?)
open Int
CurvedTextStyle

Returns a new curved text style that is a combination of this style and the given other style.

operator CurvedTextStyle

Plus operator overload that applies a merge.

open String

Public properties

Color

The background color for the text.

Color

The text color.

FontFamily?

The font family to be used when rendering the text.

TextUnit

The size of glyphs (in logical pixels) to use when painting the text.

FontStyle?

The typeface variant to use when drawing the letters (e.g. italic).

FontSynthesis?

Whether to synthesize font weight and/or style when the requested weight or style cannot be found in the provided font family.

FontWeight?

The thickness of the glyphs, in a range of 1, 1000. see FontWeight

Public constructors

CurvedTextStyle

Added in 1.0.0
CurvedTextStyle(style: TextStyle)

Create a curved text style from the given text style.

Note that not all parameters in the text style will be used, only TextStyle.color, TextStyle.fontSize, TextStyle.background, TextStyle.fontFamily, TextStyle.fontWeight, TextStyle.fontStyle and TextStyle.fontSynthesis.

CurvedTextStyle

CurvedTextStyle(
    background: Color = Color.Unspecified,
    color: Color = Color.Unspecified,
    fontSize: TextUnit = TextUnit.Unspecified,
    fontFamily: FontFamily? = null,
    fontWeight: FontWeight? = null,
    fontStyle: FontStyle? = null,
    fontSynthesis: FontSynthesis? = null
)
Parameters
background: Color = Color.Unspecified

The background color for the text.

color: Color = Color.Unspecified

The text color.

fontSize: TextUnit = TextUnit.Unspecified

The size of glyphs (in logical pixels) to use when painting the text. This may be TextUnit.Unspecified for inheriting from another CurvedTextStyle.

fontFamily: FontFamily? = null

The font family to be used when rendering the text.

fontWeight: FontWeight? = null

The thickness of the glyphs, in a range of 1, 1000. see FontWeight

fontStyle: FontStyle? = null

The typeface variant to use when drawing the letters (e.g. italic).

fontSynthesis: FontSynthesis? = null

Whether to synthesize font weight and/or style when the requested weight or style cannot be found in the provided font family.

Public functions

copy

fun copy(
    background: Color = this.background,
    color: Color = this.color,
    fontSize: TextUnit = this.fontSize
): CurvedTextStyle

copy

fun copy(
    background: Color = this.background,
    color: Color = this.color,
    fontSize: TextUnit = this.fontSize,
    fontFamily: FontFamily? = this.fontFamily,
    fontWeight: FontWeight? = this.fontWeight,
    fontStyle: FontStyle? = this.fontStyle,
    fontSynthesis: FontSynthesis? = this.fontSynthesis
): CurvedTextStyle

equals

Added in 1.0.0
open operator fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

merge

Added in 1.0.0
fun merge(other: CurvedTextStyle? = null): CurvedTextStyle

Returns a new curved text style that is a combination of this style and the given other style.

other curved text style's null or inherit properties are replaced with the non-null properties of this curved text style. Another way to think of it is that the "missing" properties of the other style are filled by the properties of this style.

If the given curved text style is null, returns this curved text style.

plus

Added in 1.0.0
operator fun plus(other: CurvedTextStyle): CurvedTextStyle

Plus operator overload that applies a merge.

toString

open fun toString(): String

Public properties

background

Added in 1.0.0
val backgroundColor

The background color for the text.

color

Added in 1.0.0
val colorColor

The text color.

fontFamily

Added in 1.1.0
val fontFamilyFontFamily?

The font family to be used when rendering the text.

fontSize

Added in 1.0.0
val fontSizeTextUnit

The size of glyphs (in logical pixels) to use when painting the text. This may be TextUnit.Unspecified for inheriting from another CurvedTextStyle.

fontStyle

Added in 1.1.0
val fontStyleFontStyle?

The typeface variant to use when drawing the letters (e.g. italic).

fontSynthesis

Added in 1.1.0
val fontSynthesisFontSynthesis?

Whether to synthesize font weight and/or style when the requested weight or style cannot be found in the provided font family.

fontWeight

Added in 1.1.0
val fontWeightFontWeight?

The thickness of the glyphs, in a range of 1, 1000. see FontWeight