class Typography


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:

import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.unit.dp
import androidx.wear.compose.material.MaterialTheme
import androidx.wear.compose.material.Text

val typography =
    MaterialTheme.typography.copy(
        display1 =
            MaterialTheme.typography.display1.copy(
                fontSize = with(LocalDensity.current) { 40.dp.toSp() }
            )
    )
MaterialTheme(typography = typography) {
    Text(
        text = "Fixed Font",
        maxLines = 1,
        style = MaterialTheme.typography.display1,
        color = MaterialTheme.colors.onBackground,
    )
}

Summary

Public constructors

Typography(
    defaultFontFamily: FontFamily,
    display1: TextStyle,
    display2: TextStyle,
    display3: TextStyle,
    title1: TextStyle,
    title2: TextStyle,
    title3: TextStyle,
    body1: TextStyle,
    body2: TextStyle,
    button: TextStyle,
    caption1: TextStyle,
    caption2: TextStyle,
    caption3: TextStyle
)

Public functions

Typography
copy(
    display1: TextStyle,
    display2: TextStyle,
    display3: TextStyle,
    title1: TextStyle,
    title2: TextStyle,
    title3: TextStyle,
    body1: TextStyle,
    body2: TextStyle,
    button: TextStyle,
    caption1: TextStyle,
    caption2: TextStyle,
    caption3: TextStyle
)

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

open operator Boolean
equals(other: Any?)
open Int
open String

Public properties

TextStyle

Body1 is the largest body.

TextStyle

Body2 is the smallest body.

TextStyle

Button text is a call to action used in different types of buttons (such as text, outlined and contained buttons) and in tabs, dialogs, and cards.

TextStyle

Caption1 is the largest caption.

TextStyle

Caption2 is the second largest caption.

TextStyle

Caption3 is an exceptional small font size which is used for the extra long-form writing like legal texts.

TextStyle

Display1 is the largest headline.

TextStyle

Display2 is the second largest headline.

TextStyle

Display3 is the third largest headline.

TextStyle

Title1 is the largest title.

TextStyle

Title2 is the medium title.

TextStyle

Title3 is the smallest title.

Public constructors

Typography

Added in 1.0.0
Typography(
    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 )
)

Public functions

copy

Added in 1.0.0
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.

equals

open operator fun equals(other: Any?): Boolean

hashCode

open fun hashCode(): Int

toString

open fun toString(): String

Public properties

body1

Added in 1.0.0
val body1TextStyle

Body1 is the largest body. Body texts are typically used for long-form writing as it works well for small text sizes. For longer sections of text, a serif or sans serif typeface is recommended.

body2

Added in 1.0.0
val body2TextStyle

Body2 is the smallest body. Body texts are typically used for long-form writing as it works well for small text sizes. For longer sections of text, a serif or sans serif typeface is recommended.

button

Added in 1.0.0
val buttonTextStyle

Button text is a call to action used in different types of buttons (such as text, outlined and contained buttons) and in tabs, dialogs, and cards. Button text is typically sans serif, using all caps text.

caption1

Added in 1.0.0
val caption1TextStyle

Caption1 is the largest caption. Caption texts are the smallest font sizes. They are used on secondary content.

caption2

Added in 1.0.0
val caption2TextStyle

Caption2 is the second largest caption. Caption texts are the smallest font sizes. They are used on secondary content.

caption3

Added in 1.0.0
val caption3TextStyle

Caption3 is an exceptional small font size which is used for the extra long-form writing like legal texts.

display1

Added in 1.0.0
val display1TextStyle

Display1 is the largest headline. Displays are the largest text on the screen, reserved for short, important text or numerals.

display2

Added in 1.0.0
val display2TextStyle

Display2 is the second largest headline. Displays are the largest text on the screen, reserved for short, important text or numerals.

display3

Added in 1.0.0
val display3TextStyle

Display3 is the third largest headline. Displays are the largest text on the screen, reserved for short, important text or numerals.

title1

Added in 1.0.0
val title1TextStyle

Title1 is the largest title. Titles are smaller than Displays. They are typically reserved for medium-emphasis text that is shorter in length.

title2

Added in 1.0.0
val title2TextStyle

Title2 is the medium title. Titles are smaller than Displays. They are typically reserved for medium-emphasis text that is shorter in length.

title3

Added in 1.0.0
val title3TextStyle

Title3 is the smallest title. Titles are smaller than Displays. They are typically reserved for medium-emphasis text that is shorter in length.