Skip to main content

ResolvedTextStyle

Struct ResolvedTextStyle 

Source
pub struct ResolvedTextStyle {
    pub size: f32,
    pub weight: FontWeight,
    pub italic: bool,
    pub color: Option<Color>,
    pub decoration: TextDecoration,
    pub decoration_color: Option<Color>,
    pub height: Option<f32>,
    pub family: Option<FontFamily>,
    pub letter_spacing: f32,
}
Expand description

Type as the renderer receives it, and the framework’s defaults. A TextStyle with every question answered: what to measure with, and what to draw.

The colour stays optional, and deliberately. Size, weight and slant have a framework default that is right everywhere; a colour’s last word belongs to the theme, which this type cannot see. A widget resolves it at paint against on_surface.

Fields§

§size: f32

Font size, in logical pixels.

§weight: FontWeight

Weight.

§italic: bool

Italic.

§color: Option<Color>

Explicit colour; None means the widget resolves it against the theme.

§decoration: TextDecoration

Decoration lines.

§decoration_color: Option<Color>

Decoration colour; None means the text’s own colour.

§height: Option<f32>

The line’s height as a multiple of the font size; None means DEFAULT_LINE_HEIGHT. Read it through line_height.

§family: Option<FontFamily>

The font family; None means the application’s default. See TextStyle::family for why it does not always win.

§letter_spacing: f32

The room added after every character, in logical pixels; 0 for none.

Implementations§

Source§

impl ResolvedTextStyle

Source

pub fn line_height(&self) -> f32

The height of one line, in logical pixels.

The one place this number is decided. It used to be a LINE_HEIGHT_FACTOR constant in frus-text and another in frus-gpu, which is two constants that had to agree: a measure and a paint disagreeing about how tall a line is puts the second line of every paragraph somewhere the layout did not reserve.

Source

pub const fn exact(size: f32) -> ResolvedTextStyle

A style of exactly this size — regular, upright, undecorated, and not put through the reader’s font setting.

For glyphs whose size is geometry rather than type: an icon on its 24 px grid, a marker that has to stay inside a circle drawn beside it. The reference’s Icon is sized by IconTheme and ignores the text scaler for the same reason — an icon that grew with the type would leave its own box.

Everything a reader reads wants TextStyle::new(size).resolved() instead. The two are one keyword apart on purpose: the choice is worth stating at every call, which is why there is no third form that guesses.

Trait Implementations§

Source§

impl Clone for ResolvedTextStyle

Source§

fn clone(&self) -> ResolvedTextStyle

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 Copy for ResolvedTextStyle

Source§

impl Debug for ResolvedTextStyle

Source§

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

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

impl PartialEq for ResolvedTextStyle

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ResolvedTextStyle

Auto Trait Implementations§

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<Msg> IntoMsg<Msg> for Msg

Source§

fn defer(work: impl Fn() -> Msg + 'static) -> Msg

The message that stands for work’s result.
Source§

impl<T> MaybeSend for T
where T: Send,

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.