Struct Text

Source
pub struct Text {
Show 19 fields pub color: Option<Color>, pub direction: Option<Direction>, pub letter_spacing: Option<LetterSpacing>, pub word_spacing: Option<WordSpacing>, pub line_height: Option<LineHeight>, pub align: Option<TextAlign>, pub align_last: Option<TextAlignLast>, pub justify: Option<TextJustify>, pub shadow: Option<TextShadow>, pub indent: Option<TextIndent>, pub decoration: Option<TextDecoration>, pub white_space: Option<WhiteSpace>, pub unicode_bidi: Option<UnicodeBidi>, pub transform: Option<TextTransform>, pub overflow: Option<TextOverflow>, pub vertical_align: Option<VerticalAlign>, pub writing_mode: Option<WritingMode>, pub word_wrap: Option<WordWrap>, pub word_break: Option<WordBreak>,
}
Expand description
use css_style::{prelude::*, color, unit::{em, px}, text::{TextAlign, TextTransform}};
use palette::rgb::Rgb;

style()
    .and_text(|conf| {
        conf.line_height(1.7)
            // rgb value f32 based, we can pass u32 hex value too e.g. 0xFFFFFFFF
            .color((0.5, 0.1, 0.1))
            // or we can use HTML colors
            .color(color::named::BLUEVIOLET)
            .align(TextAlign::Center)
            .transform(TextTransform::Capitalize)
            .indent(em(2.))
            // for single text shadow
            .and_shadow(|conf| {
                conf.x(px(3))
                    .y(px(4))
                    .color(color::named::BLUE)
                    .blur(px(2))
            })
            // for multiple text shadows
            .and_shadow(|conf| {
                conf.push(|conf| conf.x(px(2))).y(px(-4))
                    .push(|conf| conf.x(px(9)))
            })
    });

Fields§

§color: Option<Color>§direction: Option<Direction>§letter_spacing: Option<LetterSpacing>§word_spacing: Option<WordSpacing>§line_height: Option<LineHeight>§align: Option<TextAlign>§align_last: Option<TextAlignLast>§justify: Option<TextJustify>§shadow: Option<TextShadow>§indent: Option<TextIndent>§decoration: Option<TextDecoration>§white_space: Option<WhiteSpace>§unicode_bidi: Option<UnicodeBidi>§transform: Option<TextTransform>§overflow: Option<TextOverflow>§vertical_align: Option<VerticalAlign>§writing_mode: Option<WritingMode>§word_wrap: Option<WordWrap>§word_break: Option<WordBreak>

Implementations§

Source§

impl Text

Source

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

Source

pub fn try_color(self, value: Option<impl Into<Color>>) -> Self

Source

pub fn direction(self, value: impl Into<Direction>) -> Self

Source

pub fn try_direction(self, value: Option<impl Into<Direction>>) -> Self

Source

pub fn letter_spacing(self, value: impl Into<LetterSpacing>) -> Self

Source

pub fn try_letter_spacing(self, value: Option<impl Into<LetterSpacing>>) -> Self

Source

pub fn word_spacing(self, value: impl Into<WordSpacing>) -> Self

Source

pub fn try_word_spacing(self, value: Option<impl Into<WordSpacing>>) -> Self

Source

pub fn line_height(self, value: impl Into<LineHeight>) -> Self

Source

pub fn try_line_height(self, value: Option<impl Into<LineHeight>>) -> Self

Source

pub fn align(self, value: impl Into<TextAlign>) -> Self

Source

pub fn try_align(self, value: Option<impl Into<TextAlign>>) -> Self

Source

pub fn align_last(self, value: impl Into<TextAlignLast>) -> Self

Source

pub fn try_align_last(self, value: Option<impl Into<TextAlignLast>>) -> Self

Source

pub fn justify(self, value: impl Into<TextJustify>) -> Self

Source

pub fn try_justify(self, value: Option<impl Into<TextJustify>>) -> Self

Source

pub fn shadow(self, value: impl Into<TextShadow>) -> Self

Source

pub fn try_shadow(self, value: Option<impl Into<TextShadow>>) -> Self

Source

pub fn and_shadow( self, set_value: impl FnOnce(TextShadow) -> TextShadow, ) -> Self

Source

pub fn indent(self, value: impl Into<TextIndent>) -> Self

Source

pub fn try_indent(self, value: Option<impl Into<TextIndent>>) -> Self

Source

pub fn decoration(self, value: impl Into<TextDecoration>) -> Self

Source

pub fn try_decoration(self, value: Option<impl Into<TextDecoration>>) -> Self

Source

pub fn and_decoration( self, set_value: impl FnOnce(TextDecoration) -> TextDecoration, ) -> Self

Source

pub fn white_space(self, value: impl Into<WhiteSpace>) -> Self

Source

pub fn try_white_space(self, value: Option<impl Into<WhiteSpace>>) -> Self

Source

pub fn unicode_bidi(self, value: impl Into<UnicodeBidi>) -> Self

Source

pub fn try_unicode_bidi(self, value: Option<impl Into<UnicodeBidi>>) -> Self

Source

pub fn transform(self, value: impl Into<TextTransform>) -> Self

Source

pub fn try_transform(self, value: Option<impl Into<TextTransform>>) -> Self

Source

pub fn overflow(self, value: impl Into<TextOverflow>) -> Self

Source

pub fn try_overflow(self, value: Option<impl Into<TextOverflow>>) -> Self

Source

pub fn vertical_align(self, value: impl Into<VerticalAlign>) -> Self

Source

pub fn try_vertical_align(self, value: Option<impl Into<VerticalAlign>>) -> Self

Source

pub fn writing_mode(self, value: impl Into<WritingMode>) -> Self

Source

pub fn try_writing_mode(self, value: Option<impl Into<WritingMode>>) -> Self

Source

pub fn word_wrap(self, value: impl Into<WordWrap>) -> Self

Source

pub fn try_word_wrap(self, value: Option<impl Into<WordWrap>>) -> Self

Source

pub fn word_break(self, value: impl Into<WordBreak>) -> Self

Source

pub fn try_word_break(self, value: Option<impl Into<WordBreak>>) -> Self

Trait Implementations§

Source§

impl Clone for Text

Source§

fn clone(&self) -> Text

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Text

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Text

Source§

fn default() -> Text

Returns the “default value” for a type. Read more
Source§

impl<T: Into<Color>> From<T> for Text

Source§

fn from(source: T) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Text

Source§

fn eq(&self, other: &Text) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StyleUpdater for Text

Source§

fn update_style(self, style: Style) -> Style

Source§

impl StructuralPartialEq for Text

Auto Trait Implementations§

§

impl Freeze for Text

§

impl RefUnwindSafe for Text

§

impl Send for Text

§

impl Sync for Text

§

impl Unpin for Text

§

impl UnwindSafe for Text

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: FloatComponent, Swp: WhitePoint, Dwp: WhitePoint, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<Swp, Dwp, T>,

Convert the source color to the destination color using the specified method
Source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more