Visual design · Step 2 · 6 min read
Variable fonts and performance
A variable font is one file that covers many weights, widths and styles. This lesson shows how the two most useful axes — weight (wght) and optical size (opsz) — work, when a variable font saves more than it costs, and how to load Inter Variable from Google Fonts.
Variable fonts are the current version of the concept from Lesson 7 — fluid type. This lesson shows when they are worth the investment.
What you'll be able to do after reading:
- Explain what a variable font is and what axes it can expose
- Use
font-weightandfont-optical-sizingwith Inter Variable in CSS - Decide when a variable font saves file size (and when it doesn't)
- Load Inter Variable from Google Fonts correctly
1. What a variable font is
A variable font (fonte variável) is a single font file that contains multiple design variations along one or more continuous axes. Instead of loading Inter Regular, Inter Medium, Inter SemiBold and Inter Bold as four separate files, you load one Inter Variable file and set any weight between 100 and 900 as a CSS value.
The MDN variable fonts guide explains it this way: a variable font "incorporates many variations of a typeface into a single file, rather than requiring separate files for each weight, width, or style" (MDN, Variable fonts guide). The file is an OpenType variable font (format('woff2-variations') in a @font-face declaration).
For the product designer, the practical result: you are not limited to named weight stops (400, 500, 600, 700). You can set font-weight: 450 or font-weight: 575. This matters mostly for display typography; for UI body text, the named stops are usually enough.
2. The two axes that matter most
wght (weight, 100–900) and opsz (optical size, adjusted automatically by font-optical-sizing: auto). Gale uses four weight positions from the continuous axis. Optical size subtly thickens strokes at small sizes (12 px) and thins them at large sizes (40 px). Diagram: Marcus Andrey, CC BY 4.0.Axes in a variable font come in two kinds: registered axes (standardised, with a CSS property equivalent) and custom axes (font-specific, uppercase four-letter tags).
The two registered axes most useful for UI:
wght (weight) — controlled by font-weight. Inter Variable covers 100–900. This is the axis you use every day: set any weight value and the font renders at exactly that point on the axis. No loading a separate file per weight.
opsz (optical size) — controlled by font-optical-sizing: auto. Optical sizing is a design axis where the letterforms are adjusted for the size in use: at small sizes (11–14 px) the strokes are slightly thicker, the spacing more generous; at large sizes (32–40 px) the strokes are thinner and the spacing tighter. This is a small but real improvement in legibility at both extremes.
Inter Variable supports both wght and opsz. When font-optical-sizing: auto is set, the browser uses the font's opsz axis values automatically based on the computed font-size.
/* Load Inter Variable */
@font-face {
font-family: "Inter Variable";
src: url("https://fonts.gstatic.com/s/inter/v18/UcCO3FwrK3iLTeHuS_nVMrMxCp50SjIw2boKoduKmMEVuLyfAZ9hiJ-Ek-_EeA.woff2")
format("woff2-variations");
font-weight: 100 900;
font-style: normal;
font-display: swap;
}
/* Use it */
body {
font-family: "Inter Variable", "Inter", ui-sans-serif, system-ui, sans-serif;
font-optical-sizing: auto;
}
Google Fonts also provides a standard
<link>import that handles this automatically. See fonts.google.com/specimen/Inter for the current embed code.
3. Performance: when it helps
The performance argument for variable fonts is not always what it seems. It needs careful numbers.
When a variable font saves file size:
If your product loads 4 or more weights of the same typeface, a single variable font file is almost always smaller than 4 separate static files. The variable file contains the full axis range; each additional weight you use adds almost nothing to the download.
Inter's variable font file from Google Fonts is approximately 320–340 kb uncompressed. Four static Inter weights (400, 500, 600, 700) together are roughly 420–480 kb uncompressed. With WOFF2 compression, the advantage narrows but the variable version usually wins when you use 3+ weights.
When a variable font may not help:
If your product uses only one or two weights, a static font file for each weight can be smaller than a full variable file — static files ship only the weights they contain, variable files ship the full axis range. For a product that uses only Inter Regular (400) and Inter Bold (700), two static files may load faster.
Google Fonts handles this automatically when you specify weights in the URL:
https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap
Google Fonts serves the optimal subset — variable or static — for the requested weights. For 3 or more weights, it typically serves the variable font.
4. Loading Inter Variable from Google Fonts
Inter Variable is available free on Google Fonts. The simplest way to load it:
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap" rel="stylesheet">
This requests Inter across its full weight range (100–900) and optical-size range (14–32 pt). The display=swap parameter tells the browser to show fallback text while the font loads, then swap in Inter when it arrives.
After loading, declare it and enable optical sizing:
body {
font-family: "Inter", ui-sans-serif, system-ui, sans-serif;
font-optical-sizing: auto;
}
Google Fonts names the loaded family "Inter" (not "Inter Variable"), so the CSS family name is just "Inter".
5. When to use a static font instead
There are real cases where a static Inter file is the right call:
- A single weight (like a documentation site that only needs Regular): one static WOFF2 file, smaller download.
- Self-hosting with strict control over what ships: static files are easier to audit for file size.
- Legacy environments that have trouble with variable font
format('woff2-variations'): static WOFF2 is universally supported. - Performance-critical first paint: a static file can be preloaded to a byte-perfect size; a variable file ships more data than may be needed on first render.
For Gale, the variable font is the right choice: the product uses all four weights (400, 500, 600, 700), plus the intermediate optical-sizing improvements. The variable file covers all of that in one download.
Typography is complete. In Step 3 we move to colour — and we start by building a palette from scratch in OKLCH.
6. Common mistakes
- Citing "variable fonts are always faster" without counting how many weights you actually load — if only one weight is used, a static file is often smaller.
- Forgetting
font-optical-sizing: autoand losing the design advantage of theopszaxis. - Loading the full 100–900 weight range when only three weights are used — the Google Fonts URL lets you request a subset.
- Using
font-variation-settingsto controlwghtwhenfont-weightdoes the same thing with better cascade behaviour.font-variation-settingsoverridesfont-weight; prefer the high-level property.
7. Vocabulary
| Term | Meaning |
|---|---|
| Variable font | A single font file with one or more continuous design axes (wght, opsz…), covering many variations. |
8. Try it
- Open fonts.google.com/specimen/Inter and scroll to the type tester.
- Find the weight slider and drag it from 100 (Thin) to 900 (Black). Watch the letterforms change.
- Find the optical size slider (if shown) and move it between the min and max values. At small optical size, do the strokes look thicker?
- Now copy the embed code from the "Get font" button. Notice whether Google Fonts returns a variable or static CSS — it depends on how many weights you request.
9. If you already practise
- Run
font-variation-settingsin your dev tools on a page you work on. If the property exists, the font is variable. If not, it is using static files. - MDN's variable fonts guide has a live demo of each registered axis (MDN, Variable fonts guide). The
opszdemo shows the difference most clearly at large sizes.
Checklist
Learn more
- MDN, Variable fonts guide — the five registered axes and how to use them
- Google Fonts, Inter — live variable type tester
- MDN, font-optical-sizing — how the opsz axis works in CSS
Books, courses and videos to go deeper
- Web TypographyRichard RutterBook · Five Simple Steps, 2017 · — chapter on variable fonts
- How New Font Technologies Will Improve The WebFrançois PoizatSmashing Magazine, 2017 · — covers variable fonts and parametric fonts as tools for responsive typography (external site)
Related
Fluid type with clamp() · Building a colour palette in OKLCH