pub struct TextStyle {Show 23 fields
pub inherit: bool,
pub color: Option<AnyColor>,
pub background_color: Option<AnyColor>,
pub font_family: Option<String>,
pub font_size: Option<f64>,
pub font_weight: Option<FontWeight>,
pub font_style: Option<FontStyle>,
pub letter_spacing: Option<f64>,
pub word_spacing: Option<f64>,
pub text_baseline: Option<TextBaseline>,
pub height: Option<f64>,
pub leading_distribution: Option<TextLeadingDistribution>,
pub foreground: Option<Rc<Paint>>,
pub background: Option<Rc<Paint>>,
pub decoration: Option<TextDecoration>,
pub decoration_color: Option<AnyColor>,
pub decoration_style: Option<TextDecorationStyle>,
pub decoration_thickness: Option<f64>,
pub debug_label: Option<String>,
pub shadows: Option<Vec<Shadow>>,
pub font_features: Option<Vec<FontFeature>>,
pub font_variations: Option<Vec<FontVariation>>,
pub overflow: Option<TextOverflow>,
/* private fields */
}Expand description
An immutable style describing how to format and paint text.
Fields§
§inherit: boolWhether null values in this TextStyle can be replaced with their
value in another TextStyle using merge.
color: Option<AnyColor>The color to use when painting the text.
If foreground is specified, this value must be
None. The color property is shorthand for Paint()..color = color.
background_color: Option<AnyColor>The color to use as the background for the text.
font_family: Option<String>The name of the font to use when painting the text (e.g., Roboto).
If the font is defined in a package, this is prefixed with
packages/package_name/.
font_size: Option<f64>The size of fonts (in logical pixels) to use when painting the text.
font_weight: Option<FontWeight>The typeface thickness to use when painting the text (e.g., bold).
font_style: Option<FontStyle>The typeface variant to use when drawing the letters (e.g., italics).
letter_spacing: Option<f64>The amount of space (in logical pixels) to add between each letter.
word_spacing: Option<f64>The amount of space (in logical pixels) to add at each sequence of white-space (i.e. between each word).
text_baseline: Option<TextBaseline>The common baseline that should be aligned between this text span and its parent text span, or, for the root text spans, with the line box.
height: Option<f64>The height of this text span, as a multiple of the font size.
leading_distribution: Option<TextLeadingDistribution>How the vertical space added by the height multiplier
should be distributed over and under the text.
foreground: Option<Rc<Paint>>The paint drawn as a foreground for the text.
Shared, as Dart shares the one Paint object: a clone of the style holds the same
paint, and == compares paints by identity, as Dart’s Paint has no ==.
background: Option<Rc<Paint>>The paint drawn as a background for the text.
Shared and compared by identity, as foreground is.
decoration: Option<TextDecoration>The decorations to paint near the text (e.g., an underline).
decoration_color: Option<AnyColor>The color in which to paint the text decorations.
decoration_style: Option<TextDecorationStyle>The style in which to paint the text decorations (e.g., dashed).
decoration_thickness: Option<f64>The thickness of the decoration stroke as a multiplier of the thickness defined by the font.
debug_label: Option<String>A human-readable description of this text style.
This property is maintained only in debug builds. It is not considered
when comparing text styles using == or compare_to.
shadows: Option<Vec<Shadow>>A list of Shadows that will be painted underneath the text.
font_features: Option<Vec<FontFeature>>A list of FontFeatures that affect how the font selects glyphs.
font_variations: Option<Vec<FontVariation>>A list of FontVariations that affect how a variable font is rendered.
overflow: Option<TextOverflow>How visual text overflow should be handled.
Implementations§
Source§impl TextStyle
impl TextStyle
Sourcepub fn new() -> TextStyle
pub fn new() -> TextStyle
Creates a text style.
Chain setters for the fields Dart’s constructor takes as named arguments:
TextStyle::new().color(c).font_size(14.0).
Sourcepub fn color(self, color: impl Into<AnyColor>) -> TextStyle
pub fn color(self, color: impl Into<AnyColor>) -> TextStyle
The color to use when painting the text.
Sourcepub fn background_color(
self,
background_color: impl Into<AnyColor>,
) -> TextStyle
pub fn background_color( self, background_color: impl Into<AnyColor>, ) -> TextStyle
The color to use as the background for the text.
Sourcepub fn font_family(self, font_family: impl Into<String>) -> TextStyle
pub fn font_family(self, font_family: impl Into<String>) -> TextStyle
The name of the font to use when painting the text (e.g., Roboto).
Sourcepub fn font_family_fallback(
self,
font_family_fallback: Vec<String>,
) -> TextStyle
pub fn font_family_fallback( self, font_family_fallback: Vec<String>, ) -> TextStyle
The ordered list of font families to fall back on when a glyph cannot be found in a higher priority font family.
Sourcepub fn package(self, package: impl Into<String>) -> TextStyle
pub fn package(self, package: impl Into<String>) -> TextStyle
The package argument must be provided if the font family is defined in a
package. It is combined with font_family to set
that property.
Sourcepub fn font_size(self, font_size: f64) -> TextStyle
pub fn font_size(self, font_size: f64) -> TextStyle
The size of fonts (in logical pixels) to use when painting the text.
Sourcepub fn font_weight(self, font_weight: FontWeight) -> TextStyle
pub fn font_weight(self, font_weight: FontWeight) -> TextStyle
The typeface thickness to use when painting the text (e.g., bold).
Sourcepub fn font_style(self, font_style: FontStyle) -> TextStyle
pub fn font_style(self, font_style: FontStyle) -> TextStyle
The typeface variant to use when drawing the letters (e.g., italics).
Sourcepub fn letter_spacing(self, letter_spacing: f64) -> TextStyle
pub fn letter_spacing(self, letter_spacing: f64) -> TextStyle
The amount of space (in logical pixels) to add between each letter.
Sourcepub fn word_spacing(self, word_spacing: f64) -> TextStyle
pub fn word_spacing(self, word_spacing: f64) -> TextStyle
The amount of space (in logical pixels) to add at each sequence of white-space (i.e. between each word).
Sourcepub fn text_baseline(self, text_baseline: TextBaseline) -> TextStyle
pub fn text_baseline(self, text_baseline: TextBaseline) -> TextStyle
The common baseline that should be aligned between this text span and its parent text span.
Sourcepub fn height(self, height: f64) -> TextStyle
pub fn height(self, height: f64) -> TextStyle
The height of this text span, as a multiple of the font size.
Sourcepub fn leading_distribution(
self,
leading_distribution: TextLeadingDistribution,
) -> TextStyle
pub fn leading_distribution( self, leading_distribution: TextLeadingDistribution, ) -> TextStyle
How the vertical space added by the height multiplier
should be distributed over and under the text.
Sourcepub fn foreground(self, foreground: impl Into<Rc<Paint>>) -> TextStyle
pub fn foreground(self, foreground: impl Into<Rc<Paint>>) -> TextStyle
The paint drawn as a foreground for the text.
Sourcepub fn background(self, background: impl Into<Rc<Paint>>) -> TextStyle
pub fn background(self, background: impl Into<Rc<Paint>>) -> TextStyle
The paint drawn as a background for the text.
Sourcepub fn decoration(self, decoration: TextDecoration) -> TextStyle
pub fn decoration(self, decoration: TextDecoration) -> TextStyle
The decorations to paint near the text (e.g., an underline).
Sourcepub fn decoration_color(
self,
decoration_color: impl Into<AnyColor>,
) -> TextStyle
pub fn decoration_color( self, decoration_color: impl Into<AnyColor>, ) -> TextStyle
The color in which to paint the text decorations.
Sourcepub fn decoration_style(
self,
decoration_style: TextDecorationStyle,
) -> TextStyle
pub fn decoration_style( self, decoration_style: TextDecorationStyle, ) -> TextStyle
The style in which to paint the text decorations (e.g., dashed).
Sourcepub fn decoration_thickness(self, decoration_thickness: f64) -> TextStyle
pub fn decoration_thickness(self, decoration_thickness: f64) -> TextStyle
The thickness of the decoration stroke as a multiplier of the thickness defined by the font.
Sourcepub fn debug_label(self, debug_label: impl Into<String>) -> TextStyle
pub fn debug_label(self, debug_label: impl Into<String>) -> TextStyle
A human-readable description of this text style.
Sourcepub fn shadows(self, shadows: Vec<Shadow>) -> TextStyle
pub fn shadows(self, shadows: Vec<Shadow>) -> TextStyle
A list of Shadows that will be painted underneath the text.
Sourcepub fn font_features(self, font_features: Vec<FontFeature>) -> TextStyle
pub fn font_features(self, font_features: Vec<FontFeature>) -> TextStyle
A list of FontFeatures that affect how the font selects glyphs.
Sourcepub fn font_variations(self, font_variations: Vec<FontVariation>) -> TextStyle
pub fn font_variations(self, font_variations: Vec<FontVariation>) -> TextStyle
A list of FontVariations that affect how a variable font is rendered.
Sourcepub fn overflow(self, overflow: TextOverflow) -> TextStyle
pub fn overflow(self, overflow: TextOverflow) -> TextStyle
How visual text overflow should be handled.
Sourcepub fn font_family_fallback_list(&self) -> Option<Vec<String>>
pub fn font_family_fallback_list(&self) -> Option<Vec<String>>
The ordered list of font families to fall back on when a glyph cannot be found in a higher priority font family.
If the font is defined in a package, each font family in the list is
prefixed with packages/package_name/.
Sourcepub fn copy_with(&self) -> TextStyle
pub fn copy_with(&self) -> TextStyle
Creates a copy of this text style but with the given fields replaced with the new values.
Chain setters: style.copy_with().color(c).
Sourcepub fn apply(&self) -> TextStyleApply
pub fn apply(&self) -> TextStyleApply
Creates a copy of this text style replacing or altering the specified properties.
Chain replacements and factors, then TextStyleApply::into_style.
style.apply() with no further setters is Dart apply() with defaults.
Sourcepub fn merge(&self, other: Option<&TextStyle>) -> TextStyle
pub fn merge(&self, other: Option<&TextStyle>) -> TextStyle
Returns a new text style that is a combination of this style and the
given other style.
If other has inherit set to true, its null
properties are replaced with the non-null properties of this text style.
If other has inherit set to false, returns other unchanged.
Sourcepub fn lerp(
a: Option<&TextStyle>,
b: Option<&TextStyle>,
t: f64,
) -> Option<TextStyle>
pub fn lerp( a: Option<&TextStyle>, b: Option<&TextStyle>, t: f64, ) -> Option<TextStyle>
Interpolate between two text styles for animated transitions.
Sourcepub fn get_text_style(&self) -> TextStyle
pub fn get_text_style(&self) -> TextStyle
The style information for text runs, encoded for use by dart:ui.
Sourcepub fn get_text_style_with(&self, text_scaler: &TextScaler) -> TextStyle
pub fn get_text_style_with(&self, text_scaler: &TextScaler) -> TextStyle
The style information for text runs, encoded for use by dart:ui, with the font
size scaled by text_scaler (Dart’s getTextStyle(textScaler: scaler)).
Sourcepub fn get_paragraph_style(&self) -> GetParagraphStyle<'_>
pub fn get_paragraph_style(&self) -> GetParagraphStyle<'_>
The style information for paragraphs, encoded for use by dart:ui.
Chain optional Dart named arguments, then GetParagraphStyle::build.
Sourcepub fn compare_to(&self, other: &TextStyle) -> RenderComparison
pub fn compare_to(&self, other: &TextStyle) -> RenderComparison
Describe the difference between this style and another, in terms of how much damage it will make to the rendering.
Source§impl TextStyle
impl TextStyle
Sourcepub fn debug_fill_properties_with_prefix(
&self,
properties: &mut DiagnosticPropertiesBuilder,
prefix: &str,
)
pub fn debug_fill_properties_with_prefix( &self, properties: &mut DiagnosticPropertiesBuilder, prefix: &str, )
Dart debugFillProperties(properties, {String prefix = ''}).
TextSpan calls this to add the style’s properties to its own node, where Dart’s
InlineSpan.debugFillProperties does.
Trait Implementations§
Source§impl Animatable<TextStyle> for TextStyleTween
impl Animatable<TextStyle> for TextStyleTween
Source§fn transform(&self, _app: &App, t: f64) -> TextStyle
fn transform(&self, _app: &App, t: f64) -> TextStyle
t. Read moreSource§fn evaluate(&self, app: &App, animation: AnyAnimation<f64>) -> Twhere
Self: Sized,
fn evaluate(&self, app: &App, animation: AnyAnimation<f64>) -> Twhere
Self: Sized,
Source§fn animate(
self,
app: &mut App,
parent: Retained<AnyAnimation<f64>>,
) -> Retained<AnyAnimation<T>>
fn animate( self, app: &mut App, parent: Retained<AnyAnimation<f64>>, ) -> Retained<AnyAnimation<T>>
parent; whoever keeps the result keeps both.Source§fn chain<P>(self, parent: P) -> ChainedEvaluation<P, Self>
fn chain<P>(self, parent: P) -> ChainedEvaluation<P, Self>
Animatable whose value is determined by first
evaluating the given parent and then evaluating this object at the
result.Source§impl Diagnosticable for TextStyle
impl Diagnosticable for TextStyle
Source§fn to_string_short(&self) -> String
fn to_string_short(&self) -> String
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_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:).Source§impl From<TextStyle> for AnyTextStyle
impl From<TextStyle> for AnyTextStyle
Source§fn from(value: TextStyle) -> AnyTextStyle
fn from(value: TextStyle) -> AnyTextStyle
Source§impl From<TextStyleApply> for TextStyle
impl From<TextStyleApply> for TextStyle
Source§fn from(apply: TextStyleApply) -> TextStyle
fn from(apply: TextStyleApply) -> TextStyle
Source§impl MaybeWidgetStateProperty<TextStyle> for AnyTextStyle
impl MaybeWidgetStateProperty<TextStyle> for AnyTextStyle
Source§fn as_widget_state_property(
&self,
) -> Option<&dyn WidgetStateProperty<TextStyle>>
fn as_widget_state_property( &self, ) -> Option<&dyn WidgetStateProperty<TextStyle>>
Source§fn from_resolved(value: TextStyle) -> AnyTextStyle
fn from_resolved(value: TextStyle) -> AnyTextStyle
T is both).Source§impl TweenValue for TextStyle
impl TweenValue for TextStyle
Source§impl WidgetStateProperty<TextStyle> for WidgetStateTextStyle
impl WidgetStateProperty<TextStyle> for WidgetStateTextStyle
Source§fn resolve(&self, states: &WidgetStates) -> TextStyle
fn resolve(&self, states: &WidgetStates) -> TextStyle
Source§fn as_mapper(&self) -> Option<&WidgetStateMapper<TextStyle>>
fn as_mapper(&self) -> Option<&WidgetStateMapper<TextStyle>>
other is WidgetStateMapper<T>: the mapper this property is, if it is one,
as the private mapper subclasses of WidgetStateColor and the rest are.Source§fn eq_property(&self, other: &dyn WidgetStateProperty<TextStyle>) -> bool
fn eq_property(&self, other: &dyn WidgetStateProperty<TextStyle>) -> bool
==. Identity unless a class overrides it, as WidgetStatePropertyAll and
WidgetStateMapper do.Source§fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)
fn debug_fill_properties(&self, properties: &mut DiagnosticPropertiesBuilder)
WidgetStateProperty.debugFillProperties, from Diagnosticable: a property
adds its own fields.