I was testing some variable fonts and made this small website to show what I learned.
You can check out the source code for all of this on Github. This website was fully hand coded with no external tools used.
—Johan
Shows how we load a variable font in .TTF format + shows how we access custom properties. Simplified code: The cool thing here is that we have a lot of font variations in a single file, which is a peformance win. Shows how we load a variable font in the efficient WOFF2 format + shows how we access custom properties. Simplified code: I find that it takes a bit of looking around to figure out what you can exactly change in a variable font. Just for fun, you can animate the custom properties. Here's a small demo that does just that.Demo 1: League Mono
@font-face {
font-family: 'League Mono';
src: url('LeagueMonoVariable.ttf');
font-display: swap;
font-style: normal italic;
font-weight: 100 900;
}
body {
font-family: 'League Mono';
font-weight: 400;
}
h2, h3, h4 {
font-weight: 700; /* between 100 and 800 */
font-variation-settings: "wdth" 120; /* between 50 and 200 */
}
Demo 2: Meta
@font-face {
font-family: 'FF Meta VF';
src: url('MetaVariableDemo-Set.woff2') format('woff2');
font-display: swap;
font-style: normal italic;
font-weight: 100 900;
}
body {
font-family: 'FF Meta VF';
}
em {
font-style: italic;
font-variation-settings: "ital" 1;
}
Demo 3: Animation
Resources I used to learn about variable fonts.