Skip to main content

typography_css

Function typography_css 

Source
pub fn typography_css(path: impl AsRef<Path>, font_url: &str)
Expand description

Write the house typography layer to path: the two @font-face rules and the two tokens they back.

font_url is the directory the consumer serves its fonts from, without a trailing slash — /static/fonts on the MNW server, fonts for a Tauri frontend loading relative to its index.

Generated rather than hand-written for the same reason the spacing layer is: the facts are the crates’ and stating them per app is how three apps came to hold three different answers to --font-mono. It is a separate file from the layout stylesheet because @font-face rules take no part in the cascade and a consumer may need to load them ahead of a layer order it declares elsewhere.

§The consumer still has to put the faces there

This writes the CSS that fetches QuasiMono.woff2 and QuasiBody.woff2; it does not write the fonts. It cannot: they are cut by quasi-type, which is publish = false, and this crate is on crates.io. A consumer takes quasi-type as a git dependency in its own build.rs and calls quasi_type::cut, the way shop-font does, writing each slot’s woff2 under makeover::WEBFONT_MONO_FILE and makeover::WEBFONT_SANS_FILE.

§Panics

If the file cannot be written.