Skip to content

Commit 4c6b188

Browse files
authored
fix(frontend): apply Geist to body text (#170)
Geist and Geist Mono are loaded in layout.tsx and their variables are mapped to Tailwind's font-sans and font-mono, but globals.css still carried the create-next-app default of `body { font-family: Arial, Helvetica, sans-serif; }`. That override won everywhere, so Geist Sans reached only elements that named `font-sans` explicitly, of which there is exactly one in the whole application. The result was that Geist Sans was downloaded on every page load and then applied to almost nothing, while the interface rendered in Arial. Geist Mono was unaffected, since its twenty call sites all use `font-mono`. Setting the body font to the variable makes the loaded font the inherited default, which is what the existing wiring already assumed. The variable resolves to `Geist, Geist Fallback`, and that fallback is Arial with size-adjust and metric overrides generated by Next, so the swap when the webfont lands does not reflow the page. The `var()` default and the trailing generics only apply if the font class is ever absent from body. docs/DESIGN.md is updated in the same commit, since it documented the previous behaviour.
1 parent 3e68002 commit 4c6b188

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

docs/DESIGN.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,18 @@ setting. Use or extend the tokens instead.
9090
and exposed as `--font-geist-sans` and `--font-geist-mono`, which `@theme inline` maps to Tailwind's
9191
`--font-sans` and `--font-mono`.
9292

93-
Body text does not currently use them. `globals.css` sets `body { font-family: Arial, Helvetica,
94-
sans-serif; }`, so Geist applies only where a `font-sans` or `font-mono` utility is used
95-
explicitly.
93+
Geist Sans is the body font, set once on `body` in `globals.css`, so it is inherited everywhere
94+
rather than applied per component. Geist Mono is applied where it is wanted, through the `font-mono`
95+
utility.
96+
97+
The `--font-geist-sans` variable already resolves to `Geist, Geist Fallback`, where the fallback is
98+
Arial carrying `size-adjust` and ascent/descent overrides that Next generates to match Geist's
99+
metrics. That is what covers the window before the webfont resolves, and it is why the swap does not
100+
visibly reflow the page. The generic families after the variable are a last resort for the case
101+
where the font class is absent entirely.
102+
103+
There is no need to add a `font-sans` class to reach the body font; an element only needs one when
104+
it is overriding something else back to the default.
96105

97106
## Accessibility
98107

frontend/src/app/globals.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ html[data-ui-density="compact"] {
104104
body {
105105
background: var(--background);
106106
color: var(--foreground);
107-
font-family: Arial, Helvetica, sans-serif;
107+
/* layout.tsx sets --font-geist-sans on this element, and it already resolves
108+
to "Geist, Geist Fallback" -- the fallback being Arial with size-adjust and
109+
metric overrides, so the swap when the webfont lands is near-invisible. The
110+
var() default and the generics only matter if that class is ever absent. */
111+
font-family: var(--font-geist-sans, Arial), Helvetica, sans-serif;
108112
}
109113

110114
body.resize-dragging,

0 commit comments

Comments
 (0)