pub struct TextStyle {
pub span_style: SpanStyle,
pub paragraph_style: ParagraphStyle,
}Expand description
Complete style of a text: a SpanStyle and a ParagraphStyle. Compose’s TextStyle.
Fields§
§span_style: SpanStyleSettings that apply to characters.
paragraph_style: ParagraphStyleSettings that apply to the whole paragraph.
Implementations§
Source§impl TextStyle
impl TextStyle
Sourcepub fn new(span_style: SpanStyle, paragraph_style: ParagraphStyle) -> Self
pub fn new(span_style: SpanStyle, paragraph_style: ParagraphStyle) -> Self
Creates a style from span_style and paragraph_style.
Sourcepub fn from_span_style(span_style: SpanStyle) -> Self
pub fn from_span_style(span_style: SpanStyle) -> Self
Creates a style with span_style and default paragraph settings.
Sourcepub fn from_paragraph_style(paragraph_style: ParagraphStyle) -> Self
pub fn from_paragraph_style(paragraph_style: ParagraphStyle) -> Self
Creates a style with paragraph_style and default span settings.
Sourcepub fn merge(&self, other: &Self) -> Self
pub fn merge(&self, other: &Self) -> Self
Returns a style that merges the span and paragraph styles of other over those of
self.
Sourcepub fn plus(&self, other: &Self) -> Self
pub fn plus(&self, other: &Self) -> Self
Same as TextStyle::merge. Compose’s TextStyle.plus.
Sourcepub fn to_span_style(&self) -> SpanStyle
pub fn to_span_style(&self) -> SpanStyle
Returns a copy of the span style.
Sourcepub fn to_paragraph_style(&self) -> ParagraphStyle
pub fn to_paragraph_style(&self) -> ParagraphStyle
Returns a copy of the paragraph style.
Sourcepub fn platform_style(&self) -> Option<PlatformTextStyle>
pub fn platform_style(&self) -> Option<PlatformTextStyle>
Returns the platform-specific settings of the span and the paragraph, or None when
neither has any.
Sourcepub fn with_platform_style(
self,
platform_style: Option<PlatformTextStyle>,
) -> Self
pub fn with_platform_style( self, platform_style: Option<PlatformTextStyle>, ) -> Self
Returns this style with the platform-specific settings of the span and the paragraph
replaced by those in platform_style.
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. See SpanStyle::resolve_font_size.
Sourcepub fn resolve_line_height(
&self,
default_size: f32,
natural_line_height: f32,
) -> f32
pub fn resolve_line_height( &self, default_size: f32, natural_line_height: f32, ) -> f32
Returns the line height in the unit of default_size. A positive Sp line height is used
as is and a positive Em one multiplies the font size. Otherwise the result is
natural_line_height, or the font size when that is not positive and finite.
Sourcepub fn resolve_letter_spacing(&self, default_size: f32) -> f32
pub fn resolve_letter_spacing(&self, default_size: f32) -> f32
Returns the letter spacing in the unit of default_size. An Em value multiplies the
font size. An unspecified or non-finite spacing gives 0.0.
Sourcepub fn resolve_text_color(&self, default_color: Color) -> Color
pub fn resolve_text_color(&self, default_color: Color) -> Color
Returns the text color. See SpanStyle::resolve_foreground_color.
Sourcepub fn measurement_hash(&self) -> u64
pub fn measurement_hash(&self) -> u64
Hash of the settings that change how the text measures. Colors, decorations and shadows are left out.
Sourcepub fn render_hash(&self) -> u64
pub fn render_hash(&self) -> u64
Hash of every setting that changes how the text looks, as renderers use it to key caches.