Skip to main content

font_face_css

Function font_face_css 

Source
pub fn font_face_css(base_url: &str) -> String
Expand description

The @font-face rules for both slots, fetching from base_url.

base_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.

§font-weight: 200 800, which is the part that bites

Both faces are variable over wght 200-800 in one file, and the mono face’s default instance is ExtraLight — that is upstream Atkinson’s default and the cut keeps the axis rather than pinning a master, so a consumer that loads the file and takes what it opens at draws its whole UI at 200. Declaring the range here is what makes the browser resolve normal to 400 and bold to 700 instead. shop hit the same trap from the other side and names wght 400 explicitly in its shaper; this is the web’s version of that fix, stated once for every consumer.

font-display: optional on every face, house and override alike. The browser draws in the fallback at once and uses the face only if it is already there within the first ~100 ms, which a cached or local file is; otherwise it keeps the fallback for that view and fetches the face for the next. The alternatives each cost something optional does not: swap reflows the page under the reader when the face lands (layout shift), and preloading to make swap land early spends the first paint’s bandwidth on 50 KB of font. A desktop app loads its faces from disk inside the block period, so it draws them from the first frame either way.