pub struct Typography {
pub black: Rc<TextTheme>,
pub white: Rc<TextTheme>,
pub english_like: Rc<TextTheme>,
pub dense: Rc<TextTheme>,
pub tall: Rc<TextTheme>,
}Expand description
The color and geometry TextThemes for Material apps.
The text theme provided by the overall Theme,
ThemeData.text_theme, is based on the current locale’s
MaterialLocalizations.script_category and is created
by merging a color text theme - black for
Brightness::Light themes and white for Brightness::Dark
themes - and a geometry text theme, one of english_like,
dense, or tall, depending on the locale.
To lookup the localized text theme use
Theme::of(app, context).text_theme.
The color text themes are black_mountain_view,
white_mountain_view,
black_cupertino, and white_cupertino.
The Mountain View theme TextStyles
are based on the Roboto fonts as used on Android. The Cupertino themes are
based on the San Francisco
font
fonts as used by Apple on iOS.
Three sets of geometry themes are provided: 2014, 2018, and 2021. The 2014 themes correspond to the original version of the Material Design spec. The 2018 themes correspond to the second iteration of the specification and feature different font sizes, font weights, and letter spacing values. The 2021 themes correspond to the Material Design 3 specification.
By default, ThemeData.typography is Typography.material2021(platform: platform, colorScheme: colorScheme) (or Typography.material2014(platform: platform) when ThemeData.use_material3 is false). To use the 2018 text
theme geometries, specify a value using the Typography::material2018
constructor:
typography: Typography::material2018().platform(Some(platform)).build()See also:
Each text theme is shared, as Dart shares the one TextTheme object: a clone holds the
same five, and ThemeData::localize keys its cache on the geometry theme’s identity.
Fields§
§black: Rc<TextTheme>A Material Design text theme with dark glyphs.
This TextTheme should provide color but not geometry (font size,
weight, etc). A text theme’s geometry depends on the locale. To look
up a localized TextTheme, use the overall Theme, for example:
Theme::of(app, context).text_theme.
The english_like, dense, and
tall text theme’s provide locale-specific geometry.
white: Rc<TextTheme>A Material Design text theme with light glyphs.
This TextTheme provides color but not geometry (font size, weight, etc).
A text theme’s geometry depends on the locale. To look up a localized
TextTheme, use the overall Theme, for example:
Theme::of(app, context).text_theme.
The english_like, dense, and
tall text theme’s provide locale-specific geometry.
english_like: Rc<TextTheme>Defines text geometry for ScriptCategory::EnglishLike scripts, such as
English, French, Russian, etc.
This text theme is merged with either black or
white, depending on the overall ThemeData.brightness, when the
current locale’s MaterialLocalizations.script_category is
ScriptCategory::EnglishLike.
To look up a localized TextTheme, use the overall Theme, for
example: Theme::of(app, context).text_theme.
dense: Rc<TextTheme>Defines text geometry for dense scripts, such as Chinese, Japanese and Korean.
This text theme is merged with either black or
white, depending on the overall ThemeData.brightness, when the
current locale’s MaterialLocalizations.script_category is ScriptCategory::Dense.
To look up a localized TextTheme, use the overall Theme, for
example: Theme::of(app, context).text_theme.
tall: Rc<TextTheme>Defines text geometry for tall scripts, such as Farsi, Hindi, and Thai.
This text theme is merged with either black or
white, depending on the overall ThemeData.brightness, when the
current locale’s MaterialLocalizations.script_category is ScriptCategory::Tall.
To look up a localized TextTheme, use the overall Theme, for
example: Theme::of(app, context).text_theme.
Implementations§
Source§impl Typography
impl Typography
Sourcepub fn new() -> TypographyBuilder
pub fn new() -> TypographyBuilder
Creates a typography instance.
This constructor is identical to Typography::material2018.
Sourcepub fn material2014() -> TypographyBuilder
pub fn material2014() -> TypographyBuilder
Creates a typography instance using Material Design’s 2014 defaults.
If platform is TargetPlatform::IOS or TargetPlatform::MacOS, the
default values for black and white are
black_cupertino and white_cupertino
respectively. Otherwise they are black_mountain_view and
white_mountain_view. If platform is null then both
black and white must be specified.
The default values for english_like, dense,
and tall are english_like2014,
dense2014, and tall2014.
Sourcepub fn material2018() -> TypographyBuilder
pub fn material2018() -> TypographyBuilder
Creates a typography instance using Material Design’s 2018 defaults.
If platform is TargetPlatform::IOS or TargetPlatform::MacOS, the
default values for black and white are
black_cupertino and white_cupertino
respectively. Otherwise they are black_mountain_view and
white_mountain_view. If platform is null then both
black and white must be specified.
The default values for english_like, dense,
and tall are english_like2018,
dense2018, and tall2018.
Sourcepub fn material2021() -> TypographyMaterial2021Builder
pub fn material2021() -> TypographyMaterial2021Builder
Creates a typography instance using Material Design 3 2021 defaults.
Text colors are derived from color_scheme. For a light color_scheme,
every style in the resulting black uses
ColorScheme.on_surface and every style in white uses
ColorScheme.surface. For a dark color_scheme, these are reversed. The
same colors are used for TextStyle::decoration_color.
The default values for black and white depend on
platform: black_cupertino and
white_cupertino on iOS,
black_redwood_city and
white_redwood_city on macOS,
black_redmond and white_redmond on
Windows, black_helsinki and
white_helsinki on Linux, and
black_mountain_view and
white_mountain_view otherwise. If platform is
null then both black and white must be specified.
The default values for english_like, dense,
and tall are english_like2021,
dense2021, and tall2021.
The black and white parameters are deprecated. Only their non-color
properties (such as font family) are used. Any TextStyle::color or
TextStyle::decoration_color they specify is replaced with a color from
color_scheme as described above. To customize the text theme’s colors,
call copy_with on the result:
let base = Typography::material2021().color_scheme(color_scheme).build();
let typography = base
.copy_with()
.black(base.black.merge(Some(&my_black)))
.white(base.white.merge(Some(&my_white)));See also:
Sourcepub fn geometry_theme_for(&self, category: ScriptCategory) -> &Rc<TextTheme>
pub fn geometry_theme_for(&self, category: ScriptCategory) -> &Rc<TextTheme>
Returns one of english_like, dense, or
tall.
Sourcepub fn copy_with(&self) -> Typography
pub fn copy_with(&self) -> Typography
Creates a copy of this Typography with the given fields
replaced by the non-null parameter values.
Dart’s named arguments are the setters on the copy:
typography.copy_with().black(text_theme).
Sourcepub fn english_like(self, english_like: impl Into<Rc<TextTheme>>) -> Typography
pub fn english_like(self, english_like: impl Into<Rc<TextTheme>>) -> Typography
Dart copyWith(englishLike:).
Sourcepub fn lerp(a: &Typography, b: &Typography, t: f64) -> Typography
pub fn lerp(a: &Typography, b: &Typography, t: f64) -> Typography
Linearly interpolate between two Typography objects.
{@macro dart.ui.shadow.lerp}
Sourcepub fn black_mountain_view() -> TextTheme
pub fn black_mountain_view() -> TextTheme
A Material Design text theme with dark glyphs based on Roboto.
This TextTheme provides color but not geometry (font size, weight, etc).
Sourcepub fn white_mountain_view() -> TextTheme
pub fn white_mountain_view() -> TextTheme
A Material Design text theme with light glyphs based on Roboto.
This TextTheme provides color but not geometry (font size, weight, etc).
Sourcepub fn black_redmond() -> TextTheme
pub fn black_redmond() -> TextTheme
A Material Design text theme with dark glyphs based on Segoe UI.
This TextTheme provides color but not geometry (font size, weight, etc).
Sourcepub fn white_redmond() -> TextTheme
pub fn white_redmond() -> TextTheme
A Material Design text theme with light glyphs based on Segoe UI.
This TextTheme provides color but not geometry (font size, weight, etc).
Sourcepub fn black_helsinki() -> TextTheme
pub fn black_helsinki() -> TextTheme
A Material Design text theme with dark glyphs based on Roboto, with fallback fonts that are likely (but not guaranteed) to be installed on Linux.
This TextTheme provides color but not geometry (font size, weight, etc).
Sourcepub fn white_helsinki() -> TextTheme
pub fn white_helsinki() -> TextTheme
A Material Design text theme with light glyphs based on Roboto, with fallbacks of DejaVu Sans, Liberation Sans and Arial.
This TextTheme provides color but not geometry (font size, weight, etc).
Sourcepub fn black_cupertino() -> TextTheme
pub fn black_cupertino() -> TextTheme
A Material Design text theme with dark glyphs based on San Francisco.
This TextTheme provides color but not geometry (font size, weight, etc).
This theme uses the iOS version of the font names.
Sourcepub fn white_cupertino() -> TextTheme
pub fn white_cupertino() -> TextTheme
A Material Design text theme with light glyphs based on San Francisco.
This TextTheme provides color but not geometry (font size, weight, etc).
This theme uses the iOS version of the font names.
Sourcepub fn black_redwood_city() -> TextTheme
pub fn black_redwood_city() -> TextTheme
A Material Design text theme with dark glyphs based on San Francisco.
This TextTheme provides color but not geometry (font size, weight, etc).
This theme uses the macOS version of the font names.
Sourcepub fn white_redwood_city() -> TextTheme
pub fn white_redwood_city() -> TextTheme
A Material Design text theme with light glyphs based on San Francisco.
This TextTheme provides color but not geometry (font size, weight, etc).
This theme uses the macOS version of the font names.
Sourcepub fn english_like2014() -> TextTheme
pub fn english_like2014() -> TextTheme
Defines text geometry for ScriptCategory::EnglishLike scripts, such as
English, French, Russian, etc.
Sourcepub fn english_like2018() -> TextTheme
pub fn english_like2018() -> TextTheme
Defines text geometry for ScriptCategory::EnglishLike scripts, such as
English, French, Russian, etc.
The font sizes, weights, and letter spacings in this version match the 2018 Material Design specification.
Sourcepub fn dense2014() -> TextTheme
pub fn dense2014() -> TextTheme
Defines text geometry for dense scripts, such as Chinese, Japanese and Korean.
Sourcepub fn dense2018() -> TextTheme
pub fn dense2018() -> TextTheme
Defines text geometry for dense scripts, such as Chinese, Japanese and Korean.
The font sizes, weights, and letter spacings in this version match the 2018 Material Design specification.
Sourcepub fn tall2014() -> TextTheme
pub fn tall2014() -> TextTheme
Defines text geometry for tall scripts, such as Farsi, Hindi, and Thai.
Sourcepub fn tall2018() -> TextTheme
pub fn tall2018() -> TextTheme
Defines text geometry for tall scripts, such as Farsi, Hindi, and Thai.
The font sizes, weights, and letter spacings in this version match the 2018 Material Design specification.
Sourcepub fn english_like2021() -> TextTheme
pub fn english_like2021() -> TextTheme
Defines text geometry for ScriptCategory::EnglishLike scripts, such as
English, French, Russian, etc.
The font sizes, weights, and letter spacings in this version match the 2021 Material Design 3 specification.
Trait Implementations§
Source§impl Clone for Typography
impl Clone for Typography
Source§impl Debug for Typography
impl Debug for Typography
Source§impl Diagnosticable for Typography
impl Diagnosticable for Typography
Source§fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)
fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Object.runtimeType as diagnostics print it: the last segment of
the Rust type path, without generic arguments.Source§fn identity_hash(&self) -> u64
fn identity_hash(&self) -> u64
Object.hashCode as diagnostics print it: the object’s address.Source§fn to_string_short(&self) -> String
fn to_string_short(&self) -> String
Source§fn to_diagnostics_node(&self) -> DiagnosticableNode
fn to_diagnostics_node(&self) -> DiagnosticableNode
DiagnosticsNode::to_string_deep.Source§fn to_diagnostics_node_with(
&self,
name: Option<String>,
style: Option<DiagnosticsTreeStyle>,
) -> DiagnosticableNode
fn to_diagnostics_node_with( &self, name: Option<String>, style: Option<DiagnosticsTreeStyle>, ) -> DiagnosticableNode
toDiagnosticsNode(name:, style:).Source§fn to_string(&self) -> String
fn to_string(&self) -> String
toString: a single-line description with properties and no
children. Read moreSource§fn to_string_at(&self, min_level: DiagnosticLevel) -> String
fn to_string_at(&self, min_level: DiagnosticLevel) -> String
toString(minLevel:).