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
impl FontFace
Sourcepub fn new<S>(
family: impl Into<String>,
sources: impl IntoIterator<Item = S>,
) -> FontFace
pub fn new<S>( family: impl Into<String>, sources: impl IntoIterator<Item = S>, ) -> FontFace
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.
Sourcepub fn with_weight(self, weight: impl Into<String>) -> FontFace
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.
Sourcepub fn with_style(self, style: impl Into<String>) -> FontFace
pub fn with_style(self, style: impl Into<String>) -> FontFace
font-style. Omitted when unset, which means normal.
Sourcepub fn weight(&self) -> Option<&str>
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.