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: &TextStyle) -> TextStyle
pub fn merge(&self, other: &TextStyle) -> TextStyle
Returns a style that merges the span and paragraph styles of other over those of
self.
Sourcepub fn plus(&self, other: &TextStyle) -> TextStyle
pub fn plus(&self, other: &TextStyle) -> TextStyle
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.
Trait Implementations§
impl StructuralPartialEq for TextStyle
Auto Trait Implementations§
impl Freeze for TextStyle
impl RefUnwindSafe for TextStyle
impl Send for TextStyle
impl Sync for TextStyle
impl Unpin for TextStyle
impl UnsafeUnpin for TextStyle
impl UnwindSafe for TextStyle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more