Skip to main content

FontSize

Enum FontSize 

Source
pub enum FontSize {
    Step(SizeStep),
    Points(Hundredths),
}
Expand description

How large a run is set: a SizeStep relative to the text around it, or the point size the author asked for.

The step is what a menu offers first, and is what a document should say where a name will do — it reads as a step up under every theme. The point size is what the author typed and is all it is: 14 points of the sheet on the paginated view, and 14 points before the zoom on screen, which is how every other point size on a page behaves. A heading set to an exact size is that size and not its ramp scaled — the name scales the ramp, the value replaces it.

Only pt is a unit. px is a screen’s unit and a document is not a screen; em, rem and % are relative, which is what the steps already are.

Variants§

Implementations§

Source§

impl FontSize

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: one of CSS’s seven keywords, or a <number>pt. The unit is matched without regard to case, because a hand-written document says 14PT as readily as 14pt and CSS reads both.

Source

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

A size in points, or None for a number this vocabulary cannot carry — the constructor an Other… field calls with what the author typed.

Source

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

The token twig spells it with, and what from_attr reads back: the step’s CSS keyword, or the shortest decimal with pt after it.

Source

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

The step, for a menu asking which of its seven rows to tick — None when the size is an exact one, which the menu shows as its own row.

Source

pub fn points_value(self) -> Option<f32>

The point size, or None when the size is a step — whose size in points is the theme’s business and not this type’s.

Trait Implementations§

Source§

impl Clone for FontSize

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

Source§

impl Debug for FontSize

Source§

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

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

impl Eq for FontSize

Source§

impl PartialEq for FontSize

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 StructuralPartialEq for FontSize

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.