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: swap on both: the faces are 31KB and 50KB, they are cached hard after the first paint, and a flash of the fallback beats invisible text either way.