Skip to main content

TextStyleExt

Trait TextStyleExt 

pub trait TextStyleExt: Sized {
Show 17 methods // Required method fn get_text_style_data(&mut self) -> &mut TextStyleData; // Provided methods fn text_style(self, data: TextStyleData) -> Self { ... } fn color(self, color: impl Into<Color>) -> Self { ... } fn color_conic_gradient<S>(self, color: S) -> Self where S: Into<ConicGradient> { ... } fn color_linear_gradient<S>(self, color: S) -> Self where S: Into<LinearGradient> { ... } fn color_radial_gradient<S>(self, color: S) -> Self where S: Into<RadialGradient> { ... } fn color_shader(self, color: impl Into<ShaderFill>) -> Self { ... } fn text_align(self, text_align: impl Into<TextAlign>) -> Self { ... } fn font_size(self, font_size: impl Into<FontSize>) -> Self { ... } fn font_family(self, font_family: impl Into<Cow<'static, str>>) -> Self { ... } fn font_slant(self, font_slant: impl Into<FontSlant>) -> Self { ... } fn font_weight(self, font_weight: impl Into<FontWeight>) -> Self { ... } fn font_width(self, font_width: impl Into<FontWidth>) -> Self { ... } fn text_height(self, text_height: impl Into<TextHeightBehavior>) -> Self { ... } fn text_overflow(self, text_overflow: impl Into<TextOverflow>) -> Self { ... } fn text_shadow(self, text_shadow: impl Into<TextShadow>) -> Self { ... } fn text_decoration(self, text_decoration: impl Into<TextDecoration>) -> Self { ... }
}
Expand description

Methods for styling the text rendered by an element and inherited by its children.

Required Methods§

fn get_text_style_data(&mut self) -> &mut TextStyleData

Returns a mutable reference to the element’s text style data.

Provided Methods§

fn text_style(self, data: TextStyleData) -> Self

Replace all of the element’s text style data at once. See TextStyleData.

fn color(self, color: impl Into<Color>) -> Self

Set the text color to a solid Color.

fn color_conic_gradient<S>(self, color: S) -> Self
where S: Into<ConicGradient>,

Paint the text with a ConicGradient.

fn color_linear_gradient<S>(self, color: S) -> Self
where S: Into<LinearGradient>,

Paint the text with a LinearGradient.

fn color_radial_gradient<S>(self, color: S) -> Self
where S: Into<RadialGradient>,

Paint the text with a RadialGradient.

fn color_shader(self, color: impl Into<ShaderFill>) -> Self

Paint the text with a custom shader. See ShaderFill.

fn text_align(self, text_align: impl Into<TextAlign>) -> Self

Set the horizontal alignment of the text. See TextAlign.

fn font_size(self, font_size: impl Into<FontSize>) -> Self

Set the text size in pixels. See FontSize.

fn font_family(self, font_family: impl Into<Cow<'static, str>>) -> Self

Add a font family to try, in order of preference.

fn font_slant(self, font_slant: impl Into<FontSlant>) -> Self

Set the slant (style) of the font. See FontSlant.

fn font_weight(self, font_weight: impl Into<FontWeight>) -> Self

Set the thickness of the font. See FontWeight.

fn font_width(self, font_width: impl Into<FontWidth>) -> Self

Set the horizontal width of the font. See FontWidth.

fn text_height(self, text_height: impl Into<TextHeightBehavior>) -> Self

Set how the leading of the first and last lines is handled. See TextHeightBehavior.

fn text_overflow(self, text_overflow: impl Into<TextOverflow>) -> Self

Set how text that does not fit its bounds is truncated. See TextOverflow.

fn text_shadow(self, text_shadow: impl Into<TextShadow>) -> Self

Add a shadow cast behind the text. See TextShadow.

fn text_decoration(self, text_decoration: impl Into<TextDecoration>) -> Self

Set a line drawn through, under or over the text. See TextDecoration.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§