Typography

Class

Android
public class Typography
internal constructor(
    public val display1: TextStyle,
    public val display2: TextStyle,
    public val display3: TextStyle,
    public val title1: TextStyle,
    public val title2: TextStyle,
    public val title3: TextStyle,
    public val body1: TextStyle,
    public val body2: TextStyle,
    public val button: TextStyle,
    public val caption1: TextStyle,
    public val caption2: TextStyle,
    public val caption3: TextStyle,
)

Class holding typography definitions as defined by the Wear Material typography specification.

The text styles in this typography are scaled according to the user's preferred font size in the system settings. Larger font sizes can be fixed if necessary in order to avoid pressure on screen space, because they are already sufficiently accessible. Here is an example of fixing the font size for Display1:

Secondary Constructors

public constructor(
    defaultFontFamily: FontFamily = FontFamily.Default,
    display1: TextStyle =
        DefaultTextStyle.copy(
            fontWeight = FontWeight.Medium,
            fontSize = 40.sp,
            lineHeight = 46.sp,
            letterSpacing = 0.5.sp,
        ),
    display2: TextStyle =
        DefaultTextStyle.copy(
            fontWeight = FontWeight.Medium,
            fontSize = 34.sp,
            lineHeight = 40.sp,
            letterSpacing = 1.sp,
        ),
    display3: TextStyle =
        DefaultTextStyle.copy(
            fontWeight = FontWeight.Medium,
            fontSize = 30.sp,
            lineHeight = 36.sp,
            letterSpacing = 0.8.sp,
        ),
    title1: TextStyle =
        DefaultTextStyle.copy(
            fontWeight = FontWeight.Medium,
            fontSize = 24.sp,
            lineHeight = 28.sp,
            letterSpacing = 0.2.sp,
        ),
    title2: TextStyle =
        DefaultTextStyle.copy(
            fontWeight = FontWeight.Medium,
            fontSize = 20.sp,
            lineHeight = 24.sp,
            letterSpacing = 0.2.sp,
        ),
    title3: TextStyle =
        DefaultTextStyle.copy(
            fontWeight = FontWeight.Medium,
            fontSize = 16.sp,
            lineHeight = 20.sp,
            letterSpacing = 0.2.sp,
        ),
    body1: TextStyle =
        DefaultTextStyle.copy(
            fontWeight = FontWeight.Normal,
            fontSize = 16.sp,
            lineHeight = 20.sp,
            letterSpacing = 0.18.sp,
        ),
    body2: TextStyle =
        DefaultTextStyle.copy(
            fontWeight = FontWeight.Normal,
            fontSize = 14.sp,
            lineHeight = 18.sp,
            letterSpacing = 0.2.sp,
        ),
    button: TextStyle =
        DefaultTextStyle.copy(
            fontWeight = FontWeight.Bold,
            fontSize = 15.sp,
            lineHeight = 19.sp,
            letterSpacing = 0.38.sp,
        ),
    caption1: TextStyle =
        DefaultTextStyle.copy(
            fontWeight = FontWeight.Medium,
            fontSize = 14.sp,
            lineHeight = 18.sp,
            letterSpacing = 0.1.sp,
        ),
    caption2: TextStyle =
        DefaultTextStyle.copy(
            fontWeight = FontWeight.Medium,
            fontSize = 12.sp,
            lineHeight = 16.sp,
            letterSpacing = 0.1.sp,
        ),
    caption3: TextStyle =
        DefaultTextStyle.copy(
            fontWeight = FontWeight.Medium,
            fontSize = 10.sp,
            lineHeight = 14.sp,
            letterSpacing = 0.1.sp,
        ),
) : this(
    display1 = display1.withDefaultFontFamily(defaultFontFamily),
    display2 = display2.withDefaultFontFamily(defaultFontFamily),
    display3 = display3.withDefaultFontFamily(defaultFontFamily),
    title1 = title1.withDefaultFontFamily(defaultFontFamily),
    title2 = title2.withDefaultFontFamily(defaultFontFamily),
    title3 = title3.withDefaultFontFamily(defaultFontFamily),
    body1 = body1.withDefaultFontFamily(defaultFontFamily),
    body2 = body2.withDefaultFontFamily(defaultFontFamily),
    button = button.withDefaultFontFamily(defaultFontFamily),
    caption1 = caption1.withDefaultFontFamily(defaultFontFamily),
    caption2 = caption2.withDefaultFontFamily(defaultFontFamily),
    caption3 = caption3.withDefaultFontFamily(defaultFontFamily),
)

Functions

public fun copy(
        display1: TextStyle = this.display1,
        display2: TextStyle = this.display2,
        display3: TextStyle = this.display3,
        title1: TextStyle = this.title1,
        title2: TextStyle = this.title2,
        title3: TextStyle = this.title3,
        body1: TextStyle = this.body1,
        body2: TextStyle = this.body2,
        button: TextStyle = this.button,
        caption1: TextStyle = this.caption1,
        caption2: TextStyle = this.caption2,
        caption3: TextStyle = this.caption3,
    ): Typography

Returns a copy of this Typography, optionally overriding some of the values.