pub struct SpanStyle {Show 18 fields
pub color: Option<Color>,
pub brush: Option<Brush>,
pub alpha: Option<f32>,
pub font_size: TextUnit,
pub font_weight: Option<FontWeight>,
pub font_style: Option<FontStyle>,
pub font_synthesis: Option<FontSynthesis>,
pub font_family: Option<FontFamily>,
pub font_feature_settings: Option<FontFeatureSettings>,
pub letter_spacing: TextUnit,
pub baseline_shift: Option<BaselineShift>,
pub text_geometric_transform: Option<TextGeometricTransform>,
pub locale_list: Option<LocaleList>,
pub background: Option<Color>,
pub text_decoration: Option<TextDecoration>,
pub shadow: Option<Shadow>,
pub platform_style: Option<PlatformSpanStyle>,
pub draw_style: Option<TextDrawStyle>,
}Expand description
Style of a span of characters: color, font, spacing and decoration. Compose’s SpanStyle.
A field left unset (None or Unspecified) keeps the inherited value when styles merge.
Fields§
§color: Option<Color>Text color.
brush: Option<Brush>Brush that paints the glyphs, for example a gradient. Merging a style that sets color
clears an inherited brush, and the reverse.
alpha: Option<f32>Opacity from 0.0 to 1.0, multiplied into the color or brush. None leaves it unchanged.
font_size: TextUnitFont size in Sp or as a multiple of the default size with Em.
font_weight: Option<FontWeight>Weight of the font.
font_style: Option<FontStyle>Upright or italic glyphs.
font_synthesis: Option<FontSynthesis>Which missing bold or italic faces may be faked. None allows both.
font_family: Option<FontFamily>Font family.
font_feature_settings: Option<FontFeatureSettings>OpenType feature settings in CSS font-feature-settings syntax, such as smcp, liga 0.
letter_spacing: TextUnitExtra space added after each character, in Sp or as a multiple of the font size.
baseline_shift: Option<BaselineShift>Vertical shift of the glyphs from the baseline.
text_geometric_transform: Option<TextGeometricTransform>Horizontal scale and skew of the glyphs. Text rendering does not apply it yet.
locale_list: Option<LocaleList>Languages of the text, which select language-specific glyph forms and hyphenation rules.
background: Option<Color>Color drawn behind the glyphs.
text_decoration: Option<TextDecoration>Underline and line through.
shadow: Option<Shadow>Shadow drawn behind the glyphs.
platform_style: Option<PlatformSpanStyle>Platform-specific settings.
draw_style: Option<TextDrawStyle>Fill or stroke. None fills the glyphs.
Implementations§
Source§impl SpanStyle
impl SpanStyle
Sourcepub fn merge(&self, other: &Self) -> Self
pub fn merge(&self, other: &Self) -> Self
Returns a style where each field set in other replaces the one in self. Fields unset
in other keep the value of self.
Sourcepub fn plus(&self, other: &Self) -> Self
pub fn plus(&self, other: &Self) -> Self
Same as SpanStyle::merge. Compose’s SpanStyle.plus.
Sourcepub fn resolve_font_size(&self, default_size: f32) -> f32
pub fn resolve_font_size(&self, default_size: f32) -> f32
Returns the font size in sp. An Sp size is used as is, an Em size multiplies
default_size, and an unspecified, non-positive or non-finite size gives default_size.
A default_size that is not positive and finite counts as 14.0.
Sourcepub fn resolve_foreground_color(&self, default_color: Color) -> Color
pub fn resolve_foreground_color(&self, default_color: Color) -> Color
Returns color, else the color of a solid brush, else default_color, with alpha
multiplied into the result’s alpha channel.
Sourcepub fn render_hash(&self) -> u64
pub fn render_hash(&self) -> u64
Hash of every field that changes how the text looks, as renderers use it to key caches.