Skip to main content

Typography

Struct Typography 

Source
pub struct Typography { /* private fields */ }
Expand description

Layer 0 of the font model, re-exported for the same one-dependency reason.

A build script composing an override needs all four names and has no other reason to depend on makeover directly. The whole typography layer for one product: the house defaults, plus whatever it overrides.

This is what a build script composes and what makeover_build::typography_css_from writes. typography_css_vars and font_face_css are the no-override case of it and stay for callers that have nothing to declare.

Implementations§

Source§

impl Typography

Source

pub fn house(base_url: impl Into<String>) -> Typography

The house layer alone, fetching faces from base_url — the directory the consumer serves fonts from, with or without a trailing slash.

Source

pub fn with_override(self, ov: FontOverride) -> Typography

Add one product override.

§Panics

If the slot is already overridden. One declaration per product per slot: a second is not a merge to resolve, it is two answers to a question that has one, and the vocabulary is what wants fixing.

Source

pub fn resolve(&self, slot: FontSlot) -> Option<&str>

What slot resolves to under this layer, or None for a brand slot nobody overrode.

The resolution, for a renderer that has a face to choose rather than a stylesheet to emit.

Source

pub fn faces(&self, slot: FontSlot) -> &[FontFace]

The faces a product ships for slot, in declaration order, or an empty slice for a slot it did not override.

The other half of resolve, for a renderer that has to load a file rather than name a stack: resolve says which family wins, this says where the bytes come from, what to call them, and at what weight. The house faces are not here — they belong to the slot rather than to any one product, and FontSlot::house_face is where they answer.

Source

pub fn font_face_css(&self) -> String

The @font-face rules: the two house faces, then each override’s.

Source

pub fn css_declarations(&self) -> String

The resolved tokens as CSS declarations, no selector.

Source

pub fn css_vars(&self) -> String

The resolved tokens as a :root { … } block.

Source

pub fn css(&self) -> String

Faces then tokens, in the order a stylesheet wants them.

Trait Implementations§

Source§

impl Clone for Typography

Source§

fn clone(&self) -> Typography

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 Debug for Typography

Source§

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

Formats the value using the given formatter. Read more

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

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.