Skip to main content

FontFace

Struct FontFace 

Source
pub struct FontFace { /* 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. One @font-face an override brings with it.

A product overriding a slot usually has to ship the face too, and the two halves have to agree on a family name. Declaring them together is what makes that agreement structural rather than a string typed twice.

Implementations§

Source§

impl FontFace

Source

pub fn new<S>( family: impl Into<String>, sources: impl IntoIterator<Item = S>, ) -> FontFace
where S: Into<String>,

A face named family, fetched from sources.

Each source is either a bare filename, resolved against the Typography base URL, or an absolute one (/… or https://…) taken as written. The format() hint is inferred from the extension — woff2, woff, ttf, otf — and omitted for anything else rather than guessed, since a wrong hint is worse than none.

Source

pub fn with_weight(self, weight: impl Into<String>) -> FontFace

font-weight, as CSS writes it: "700", or "200 800" for a variable axis. Omitted when unset, which means normal.

A variable face MUST name its range here for the same reason the house faces do: a @font-face with no range makes the browser resolve every weight to the file’s default instance.

Source

pub fn with_style(self, style: impl Into<String>) -> FontFace

font-style. Omitted when unset, which means normal.

Source

pub fn weight(&self) -> Option<&str>

The declared font-weight, or None when the face never named one.

A renderer loading a variable face directly has to name a weight — the file’s own default instance is whatever the base shipped, which for the house faces is ExtraLight — so this is the half of the declaration that stops the load from being a guess.

Source

pub fn style(&self) -> Option<&str>

The declared font-style, or None, which means normal.

Source

pub fn family(&self) -> &str

The family name, as the stack has to spell it.

For a renderer that loads faces rather than emitting CSS this is the name it registers the file under, and reading it here is what keeps that name from being typed a second time.

Source

pub fn sources(&self) -> &[String]

The sources, unresolved — bare filenames as they were declared, not joined to any base URL. A renderer loading from disk or from an include_bytes! wants the filename; only the CSS wants the URL.

Trait Implementations§

Source§

impl Clone for FontFace

Source§

fn clone(&self) -> FontFace

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 FontFace

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.