.width.super-floof {
font-stretch: 140%;
}
.width.petite-puffle {
font-stretch: 50%;
}
.weight.chonky-boi {
font-weight: 900;
}
.weight.skinny-minnie {
font-weight: 500;
}
.x-height.bubba-bear {
font-variation-settings: 'YTLC' 600;
}
.x-height.lil-bit {
font-variation-settings: 'YTLC' 450;
}
.slant.naptime {
font-style: oblique 12deg;
}
.example {
font-style: italic;
- or -
font-variation-settings: 'ital' 1;
}
.example {
font-optical-sizing: auto;
- or -
font-variation-settings: 'opsz' 72;
}
Call me Ishmael. Some years ago—never mind how long precisely—having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen and regulating the circulation. Whenever I find myself growing grim about the mouth; whenever it is a damp, drizzly November in my soul; whenever I find myself involuntarily pausing before coffin warehouses, and bringing up the rear of every funeral I meet; and especially whenever my hypos get such an upper hand of me, that it requires a strong moral principle to prevent me from deliberately stepping into the street, and methodically knocking people’s hats off—then, I account it high time to get to sea as soon as I can. This is my substitute for pistol and ball.
An optical size axis can enable a single font to look quite different and be appropriate for use and a much broader range of size and purpose
.example {
font-family: "Literata Static";
}
@supports (font-variation-settings: normal) {
.example {
font-family: "Literata Variable";
}
}
It’s often relatively straightforward to layer in support for variable fonts in existing projects
Variable fonts open the door to better, more interesting design on the web
.example {
font-family: "Literata Variable";
font-variation-settings: "GRAD" 0;
}
@media (prefers-color-scheme:dark) {
.example {
font-family: "Literata Variable";
font-variation-settings: "GRAD" -0.5;
}
}
}
Enabling different light modes is fairly well-supported, but often needs more than just color contrast inversion. Grade, weight, and letter-spacing can all play a part in fine-tuning the typographic experience
More and more variable fonts are becoming available every day. Many of the most interesting ones are from smaller foundries and individual designers, but the bigger companies are getting into it now as well
Once you have a variable font (or are reviewing one), it helps to have a tool or two to help understand that font’s capabilities.
Most sources of variable fonts are direct from vendors, so it’s worth getting to know how to set up your own @font-face rules
@font-face {
font-family: 'Plex Sans VF';
src: url("path/to/IBMPlexSansVar-Roman.woff2")
format("woff2-variations");
font-display: swap;
font-stretch: 85% 100%;
font-style: normal;
font-weight: 100 700;
}
Google launched support for variable fonts through their API, with a catalog that is growing regularly
@import url("https://fonts.googleapis.com/css2?
family=EB+Garamond:ital,wght@
0,400..800;1,400..800");
}
@import url("https://fonts.googleapis.com/css2?
family=Inter:slnt,wght@
-10,400..800;0,400..800");
}
While a variable font file is larger than a single static weight, they are often smaller than the 4 or 5 typically loaded
font-display: swap;
Variable fonts bring many benefits to the table. The key to executive and team buy-in depends on who’s on the other side of the table. Know their pain points!