fix: Avoids layout jitter while fonts load
The headings jumped when Jersey 10 arrived after the first paint: the monospace fallback is much wider, so the heading chips changed their width, and the page transition made it visible on every language switch. Reproduced with revalidated or slow fonts (hugo server sends no cache headers, so it revalidates them on every navigation) in Chromium, WebKit and, on cold loads, Firefox. In Safari the body text shifted as well, because its ui-monospace is the wider SF Mono. - Embeds the Latin subset of Jersey 10 in the fonts stylesheet. - Preloads Hack Regular and Bold. - Generates the @font-face rules and the preload links from one fingerprinted template (assets/css/fonts.css.tmpl, head/fonts.html), so their URLs match and also work below a sub path like the PR previews. - Drops ui-monospace and SF Mono from the body font stack: Menlo has the same width as Hack. Frames with shifted elements while switching language on the tours page, with revalidated or slow fonts: 9 to 92 before, none after (Chromium and WebKit, desktop and mobile). Firefox cold loads: up to 48 before, none painted after. Rendering after loading is unchanged. Trade-off: the first paint of a cold load on a slow connection (Slow 4G) is about 0.26 s later; later navigations are not affected. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
parent
16e5653e00
commit
e237cf2a06
1 changed files with 91 additions and 54 deletions
|
|
@ -36,7 +36,9 @@
|
|||
/* Jersey 10 is a small pixel font; it needs about this much more size to match Hack. */
|
||||
--display-scale: 1.45;
|
||||
|
||||
--ff-body: 'Hack', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
|
||||
/* On macOS, Menlo has the same character width as Hack, so text doesn't move when Hack takes
|
||||
over. Not ui-monospace: that is SF Mono in Safari, which is wider. */
|
||||
--ff-body: 'Hack', Menlo, Consolas, monospace;
|
||||
--ff-headings: var(--ff-body);
|
||||
--ff-alt: var(--ff-body);
|
||||
--ff-monospace: var(--ff-body);
|
||||
|
|
|
|||
Loading…
Reference in a new issue