Skip to main content

LineHeight

Enum LineHeight 

Source
pub enum LineHeight {
    Step(LineSpacing),
    Ratio(Hundredths),
}
Expand description

How far apart a block’s lines are set: a LineSpacing from the menu’s three, or the ratio the author asked for. FontSize’s peer, one property along, and with no unit at all — a line height is a multiple.

A ratio that spells one of the three names is that name: from_attr answers Step(OneHalf) for 1.50 as well as for 1.5, so that two spellings of one spacing are one value and the document is rewritten with the name a menu can tick.

And a ratio of 1 is absence, exactly as it is for LineSpacing, whose three names begin above it: single spacing is what a block with no data-line-height is set at, and a document should not carry a key that says nothing. from_attr("1") and ratio(1.0) both answer None, so a gesture given one clears the key and the query then ticks Single.

Variants§

Implementations§

Source§

impl LineHeight

Source

pub fn from_attrs(attrs: &[(String, Option<String>)]) -> Option<Self>

The spacing a block’s attributes name, if any — twig records it under data-line-height.

Source

pub fn from_attr(value: &str) -> Option<Self>

Read a data-line-height value: one of the three names, or any positive decimal other than 1, which is absence.

Source

pub fn ratio(ratio: f32) -> Option<Self>

A ratio, or None for a number this vocabulary cannot carry — the constructor an Other… field calls with what the author typed. 1 is one of those numbers: see the type’s note.

Source

pub fn is_absence(value: &str) -> bool

Whether value spells the one ratio that is absence — 1, in any of its spellings (1, 1.0, 1.00), which is single spacing and is the theme’s own.

from_attr answers None for it exactly as it does for a token outside the grammar, and the two mean opposite things: 1 is an author asking for the theme’s spacing, and huge is a typo. A binding that turns the first into a cleared key and the second into a refusal asks this to tell them apart — leaf-wasm’s setLineSpacing does.

Source

pub fn name(self) -> Cow<'static, str>

The token twig spells it with, and what from_attr reads back.

Source

pub const fn step(self) -> Option<LineSpacing>

The step, for a menu asking which of its three rows to tick — None for an exact ratio, which the menu shows as its own row.

Source

pub fn as_f32(self) -> f32

The ratio itself — what a frontend multiplies the theme’s line height by. Unlike FontSize’s points this always answers, because a step’s ratio is the name read as arithmetic (LineSpacing::ratio) and not a theme’s choice.

Trait Implementations§

Source§

impl Clone for LineHeight

Source§

fn clone(&self) -> LineHeight

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 LineHeight

Source§

impl Debug for LineHeight

Source§

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

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

impl Eq for LineHeight

Source§

impl PartialEq for LineHeight

Source§

fn eq(&self, other: &LineHeight) -> 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 LineHeight

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<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.