Skip to main content

SizeStep

Enum SizeStep 

Source
pub enum SizeStep {
    XxSmall,
    XSmall,
    Small,
    Large,
    XLarge,
    XxLarge,
    XxxLarge,
}
Expand description

How large a run is set relative to the text around it — CSS’s <absolute-size> keyword set with medium removed, because medium is absence.

A step, never a measurement, for the reason MarkColor is a name and not a hex triple: a run set to 14pt in a theme whose body is 12pt is a step up, and the same run under a 16pt theme is a step down — the author’s intent inverted by a change they never made. A run set to Large is a step up under every theme.

A heading keeps its own ramp: a data-size on a heading scales the heading’s size, not the body’s.

Variants§

§

XxSmall

§

XSmall

§

Small

§

Large

§

XLarge

§

XxLarge

§

XxxLarge

Implementations§

Source§

impl SizeStep

Source

pub const ALL: [Self; 7]

Every step, smallest first. medium is absent because medium is absence — a menu draws it as the entry that calls crate::Doc::set_font_size with None.

Source

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

The size a run’s or block’s attributes name, if any — twig records it under data-size.

Source

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

Read a data-size value. None for a name outside the vocabulary — a data-size="14pt" from elsewhere is carried and drawn at the theme’s own size, which is the same answer the stylesheet gives it.

Source

pub const fn name(self) -> &'static str

The token twig spells it with, and what from_attr reads back — CSS’s own keyword, so a stylesheet rule is [data-size="large"] { font-size: large } and nothing is learned twice.

Source

pub const fn scale(self) -> f32

The multiple of the theme’s body size this step sets — the ratios CSS’s own user-agent stylesheet uses for the same seven words, so a browser given only leaf’s stylesheet and a native renderer given the theme agree about how big large is.

A default: a theme is free to scale its own ramp, the way a frontend is free to pick its own red for MarkColor::Red. What the document carries is the name.

Source

pub const fn index(self) -> usize

This step’s position in ALL — smallest first, so a frontend’s menu is ALL in order and a “larger” button is index() + 1.

Trait Implementations§

Source§

impl Clone for SizeStep

Source§

fn clone(&self) -> SizeStep

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 SizeStep

Source§

impl Debug for SizeStep

Source§

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

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

impl Eq for SizeStep

Source§

impl PartialEq for SizeStep

Source§

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

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.