🌈 Create new beautiful Compose Gradients with our new wesite ->
Class

CurvedTextStyle

Styling configuration for a curved text.

Source set: Android
public class CurvedTextStyle(
    public val background: Color = Color.Unspecified,
    public val color: Color = Color.Unspecified,
    public val fontSize: TextUnit = TextUnit.Unspecified,
    public val fontFamily: FontFamily? = null,
    public val fontWeight: FontWeight? = null,
    public val fontStyle: FontStyle? = null,
    public val fontSynthesis: FontSynthesis? = null,
    public val letterSpacing: TextUnit = TextUnit.Unspecified,
    public val letterSpacingCounterClockwise: TextUnit = TextUnit.Unspecified,
    public val lineHeight: TextUnit = TextUnit.Unspecified,
    public val warpOffset: WarpOffset = WarpOffset.Unspecified,
)

Styling configuration for a curved text.

Sample using different letter spacings for top & bottom text:

Sample using different warping:

Parameters

background The background color for the text.
color The text color.
fontSize The size of glyphs (in logical pixels) to use when painting the text. This may be TextUnit.Unspecified for inheriting from another CurvedTextStyle.
fontFamily The font family to be used when rendering the text.
fontWeight The thickness of the glyphs, in a range of [1, 1000]. see FontWeight
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.
letterSpacing The amount of space (in em or sp) to add between each letter, when text is going clockwise.
letterSpacingCounterClockwise The amount of space (in em or sp) to add between each letter, when text is going counterClockwise. Note that this usually needs to be bigger than letterSpacing to account for the fact that going clockwise, text fans out from the baseline while going counter clockwise text fans in. If not specified, the value for letterSpacing will be used.
lineHeight Line height for the text in TextUnit unit, e.g. SP or EM. Note that since curved text only has one line, this used the equivalent of a lineHeightStyle: alignment = Center, trim = None, mode = Fixed
warpOffset specifies if we want to warp the text, and if so, the offset for warping. Warping the text will cause each character to be modified in shape so that it is thinner when it is closer to the center of the center of the screen and wider when it's further away. This also makes adjacent characters share a line, so this is particularly useful for cursive fonts. When warping is active, this parameter specifies which horizontal line of the text will keep its width.

Functions

merge

Source set: Android
public 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

Source set: Android
public operator fun plus(other: CurvedTextStyle): CurvedTextStyle

Plus operator overload that applies a merge.

copy

Source set: Android
@Deprecated(
        "This overload is provided for backwards compatibility with Compose for " +
            "Wear OS 1.0. A newer overload is available with additional font parameters.",
        level = DeprecationLevel.HIDDEN,
    )
    public fun copy(
        background: Color = this.background,
        color: Color = this.color,
        fontSize: TextUnit = this.fontSize,
    ): CurvedTextStyle

copy

Source set: Android
@Deprecated(
        "This overload is provided for backwards compatibility with Compose for " +
            "Wear OS 1.4. A newer overload is available with additional letter spacing parameters.",
        level = DeprecationLevel.HIDDEN,
    )
    public 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

copy

Source set: Android
@Deprecated(
        "This overload is provided for backwards compatibility with Compose for " +
            "Wear OS 1.4. A newer overload is available with additional letter spacing parameters.",
        level = DeprecationLevel.HIDDEN,
    )
    public 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,
        // We do this so when the user doesn't specify letterSpacing, neither letterSpacing nor
        // letterSpacingCounterClockwise are modified, and when they do specify it we update both.
        letterSpacing: TextUnit = TextUnit.Unspecified,
    ): CurvedTextStyle

copy

Source set: Android
@Deprecated(
        "This overload is provided for backwards compatibility with Compose for " +
            "Wear OS 1.5. A newer overload is available with additional warpOffset parameter.",
        level = DeprecationLevel.HIDDEN,
    )
    public 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,
        letterSpacing: TextUnit = this.letterSpacing,
        letterSpacingCounterClockwise: TextUnit = this.letterSpacingCounterClockwise,
        lineHeight: TextUnit = this.lineHeight,
    ): CurvedTextStyle

copy

Source set: Android
public 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,
        letterSpacing: TextUnit = this.letterSpacing,
        letterSpacingCounterClockwise: TextUnit = this.letterSpacingCounterClockwise,
        lineHeight: TextUnit = this.lineHeight,
        warpOffset: WarpOffset = this.warpOffset,
    ): CurvedTextStyle

equals

Source set: Android
override fun equals(other: Any?): Boolean

hashCode

Source set: Android
override fun hashCode(): Int

toString

Source set: Android
override fun toString(): String

Members

WarpOffset

Source set: Android
public class WarpOffset internal constructor(internal val option: Byte)

Used to specify if we want to warp the text, and if so, the offset for warping. Warping the text will cause each character to be modified in shape so that it is thinner when it is closer to the center of the center of the screen and wider when it's further away. This also makes adjacent characters share a line, so this is particularly useful for cursive fonts. When warping is active, this parameter specifies which horizontal line of the text will keep its width.

Properties

isSpecified

Source set: Android
public inline val isSpecified: Boolean

false when this is WarpOffset.Unspecified.

isUnspecified

Source set: Android
public inline val isUnspecified: Boolean

true when this is WarpOffset.Unspecified.

Functions

toString

Source set: Android
override fun toString(): String

takeOrElse

Source set: Android
public inline fun takeOrElse(block: () -> WarpOffset): WarpOffset

If this WarpOffset isSpecified then this is returned, otherwise block is executed and its result is returned.

Members

Companion

Source set: Android
public companion object

Properties

Unspecified

Source set: Android
public val Unspecified: WarpOffset = WarpOffset(0)

Unspecified, used for merging styles

None

Source set: Android
public val None: WarpOffset = WarpOffset(1)

Do not warp, use the standard Android rendering

Baseline

Source set: Android
public val Baseline: WarpOffset = WarpOffset(2)

Warp using the baseline of the text.

HalfAscent

Source set: Android
public val HalfAscent: WarpOffset = WarpOffset(3)

Warp using half the ascent of the text.

HalfOpticalHeight

Source set: Android
public val HalfOpticalHeight: WarpOffset = WarpOffset(4)

Warp using the middle point between ascent and descent of the text. This is the default

Ascent

Source set: Android
public val Ascent: WarpOffset = WarpOffset(5)

Warp using the ascent of the text.

Descent

Source set: Android
public val Descent: WarpOffset = WarpOffset(6)

Warp using the descent of the text.