Skip to main content

TextStyle

Struct TextStyle 

Source
pub struct TextStyle<F> {
Show 14 fields pub color: Rgba, pub font_family: F, pub font_size: f32, pub font_weight: u16, pub font_style: FontStyle, pub letter_spacing: f32, pub line_height: Length, pub white_space: WhiteSpace, pub word_break: WordBreak, pub overflow_wrap: OverflowWrap, pub text_align: TextAlign, pub text_decoration: TextDecoration, pub vertical_align: VerticalAlign, pub max_lines: u32,
}
Expand description

Fully resolved, inherited typography of one node: everything a host needs to measure text exactly as it paints it. F is the family: a ResolvedFamily into the store while layout keeps it per node (ResolvedTextStyle), a borrowed &str when handed to a TextMeasurer.

Fields§

§color: Rgba§font_family: F

CSS font-family list as authored; empty = the host’s default UI font.

§font_size: f32

Logical points, finite and >= 0.

§font_weight: u16

CSS weight (100..=900 once a host clamps it).

§font_style: FontStyle§letter_spacing: f32

Extra advance after every character, logical points.

§line_height: Length

Points = absolute; percent = unit-less multiplier × 100 of font_size; auto = normal.

§white_space: WhiteSpace§word_break: WordBreak§overflow_wrap: OverflowWrap§text_align: TextAlign§text_decoration: TextDecoration§vertical_align: VerticalAlign§max_lines: u32

Maximum painted lines (0 = unlimited); measured height never exceeds them.

Implementations§

Source§

impl<F> TextStyle<F>

Source

pub fn map_family<'s, G>(&'s self, f: impl FnOnce(&'s F) -> G) -> TextStyle<G>

The same style with the family mapped to another representation.

Source

pub fn wraps(&self) -> bool

false for white-space: nowrap | pre: lines break only at \n, never at max_width.

Source

pub fn line_height_points(&self) -> Option<f32>

The line height in points, None for normal (the font’s own metrics).

Source§

impl<F: PartialEq> TextStyle<F>

Source

pub fn measure_eq(&self, other: &Self) -> bool

true when both styles measure identically: every field except paint-only color, floats compared by bits (so NaN never forces endless re-measurement).

Source

pub fn style_eq(&self, other: &Self) -> bool

true when all typography fields (including paint-only color, text_align, text_decoration) match bitwise.

Source§

impl<F: AsRef<str>> TextStyle<F>

Source

pub fn borrowed(&self) -> TextStyle<&str>

The measurer view of an owned-family style.

Source§

impl TextStyle<&str>

Source

pub fn sized(font_size: f32) -> Self

Default typography at font_size (the host’s default family).

Source§

impl TextStyle<ResolvedFamily>

Source

pub fn in_store<'a>(&self, store: &'a NodeStore) -> TextStyle<&'a str>

The measurer view of this style, its family read from store.

Trait Implementations§

Source§

impl<F: Clone> Clone for TextStyle<F>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<F: Copy> Copy for TextStyle<F>

Source§

impl<F: Debug> Debug for TextStyle<F>

Source§

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

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

impl<F: Default> Default for TextStyle<F>

Source§

fn default() -> Self

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

impl<F: PartialEq> PartialEq for TextStyle<F>

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl<F: PartialEq> StructuralPartialEq for TextStyle<F>

Auto Trait Implementations§

§

impl<F> Forget for TextStyle<F>

§

impl<F> Freeze for TextStyle<F>
where F: Freeze,

§

impl<F> Move for TextStyle<F>

§

impl<F> RefUnwindSafe for TextStyle<F>
where F: RefUnwindSafe,

§

impl<F> Send for TextStyle<F>
where F: Send,

§

impl<F> Sync for TextStyle<F>
where F: Sync,

§

impl<F> Unpin for TextStyle<F>
where F: Unpin,

§

impl<F> UnsafeUnpin for TextStyle<F>
where F: UnsafeUnpin,

§

impl<F> UnwindSafe for TextStyle<F>
where F: UnwindSafe,

Blanket Implementations§

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.