Typography
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 |
|---|
Public functions |
|
|---|---|
Typography |
copy(Returns a copy of this Typography, optionally overriding some of the values. |
open operator Boolean |
|
open Int |
hashCode() |
open String |
toString() |
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
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
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.
Public properties
body1
val body1: TextStyle
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
val body2: TextStyle
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
val button: 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. Button text is typically sans serif, using all caps text.
caption1
val caption1: TextStyle
Caption1 is the largest caption. Caption texts are the smallest font sizes. They are used on secondary content.
caption2
val caption2: TextStyle
Caption2 is the second largest caption. Caption texts are the smallest font sizes. They are used on secondary content.
caption3
val caption3: TextStyle
Caption3 is an exceptional small font size which is used for the extra long-form writing like legal texts.
display1
val display1: TextStyle
Display1 is the largest headline. Displays are the largest text on the screen, reserved for short, important text or numerals.
display2
val display2: TextStyle
Display2 is the second largest headline. Displays are the largest text on the screen, reserved for short, important text or numerals.
display3
val display3: TextStyle
Display3 is the third largest headline. Displays are the largest text on the screen, reserved for short, important text or numerals.
title1
val title1: TextStyle
Title1 is the largest title. Titles are smaller than Displays. They are typically reserved for medium-emphasis text that is shorter in length.