The relative font weight axis — how variable fonts ease font weight transitions (#tilPost)

I’m not a font person. I have neither the skills nor the patience to get into font fiddling. But I do notice and appreciate a site with beautiful font combinations.
Web fonts also come with challenges, such as layout shifts and the …


This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis

I'm not a font person. I have neither the skills nor the patience to get into font fiddling. But I do notice and appreciate a site with beautiful font combinations.

Web fonts also come with challenges, such as layout shifts and the typical performance hit to load and display them.

That's why this blog uses the most boring (but fastest) fonts possible.

html {
  /* Use whatever is available */
  font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Helvetica,
    Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol;
}

This font-family declaration tells the browser to use whatever font is available on a system so that it doesn't have to download anything and can display text immediately.

But that's just my tiny blog, if you're building something polished and designed, it has been common that you had to download multiple font files — one font for bold, one for italic, one for bold-italic, and so on.

But it's 2023 and variable fonts solve the multiple-download problem.

Today I learned about relative font weights, solving a problem I've had for almost a decade. Let's have a look!

The beauty of variable fonts

Variable fonts are configurable and the font-variation-settings CSS property give you font styling super powers.

MDN Compat Data (source)
Browser support info for font-varation-settings
chrome chrome_android edge firefox firefox_android safari safari_ios samsunginternet_android webview_android
62 62 17 62 62 11 11 8.0 62

Variable fonts provide parameters (called axes) to tweak their rendering. Instead of downloading multiple font files for bold and italic, you download one variable font with unlimited font rendering options.

font-variation-settings: "wdth" 57, "wght" 200, "slnt" -10, "opsz" 30, "ital" 1;

The CSS Fonts Module Level 4 spec defines five registered axes matching common font requirements.

Interestingly enough, the spec recommends not to use these font variations. 😅

If you want to set this variation axis Use CSS proproperties instead
Weight (wght) font-weight
Width (wdth) font-stretch
Slant (slnt) or Italic (ital) font-style
Optical size (opsz) font-optical-sizing

That's fair (I guess) because there are matching CSS properties for these axes.

But things get exciting when we look at unusual font variations.

Custom variable font axes

In addition to the registered axes, font creators can define custom variable font axes. But how do you know what axes are defined for a variable font?

To inspect a font and discover all the visual options, Wakamai Fondue is an exceptional tool. You can drop in a font and start playing with it. Here's the Roboto variable font if you want to try it.

Wakamai Fondue interface configuring Roboto with all its custom axes.

Look at this! There are 13(!) properties to tweak Roboto. 🤯

Just recently, I discovered the wonderful Shantell comic font.

[Interactive component: visit the article to see it...]

Look at this bouncy font! I love playing with the INFM and BNCE axis and am very tempted to add it to this blog.

But coming back to Roboto; you probably didn't notice it, but there's one custom axis in there that you might wanted to use since forever!

Relative font weight — the GRAD axis

You've probably encountered the following problem before: you want to change a link's font-weight on hover, and whoops... changing its font weight will also change every character's horizontal size. Bummer.

What if there were a way to make the text bolder without changing its horizontal size?

The custom GRAD axis is doing exactly this.

The term 'grade' refers to the relative weight or density of the typeface design, but differs from traditional 'weight' in that the physical space the text occupies does not change, so changing the text grade doesn't change the overall layout of the text or elements around it.

Let's see it in action.

[Interactive component: visit the article to see it...]

Conclusion

Now, who would have thought that custom variable font axes can ease font weight transitions?

But so cool that is — for me right now: loading an article on this blog without images usually needs less than 250KB (that's everything: HTML, CSS, JS). The Roboto variable font weighs 700KB alone. 😢 I guess, I'll pass on loading it for now.

I'd love to see the system fonts adopt the GRAD axis. Apple's San Francisco is a variable font, but it only includes the common axes.

Nevertheless, I'm very into transitioning font weights without causing layout shifts. If you're using variable fonts, it's worth checking if it supports GRAD to add some nice hover effects!


Reply to Stefan


This content originally appeared on Stefan Judis Web Development and was authored by Stefan Judis


Print Share Comment Cite Upload Translate Updates
APA

Stefan Judis | Sciencx (2023-04-08T22:00:00+00:00) The relative font weight axis — how variable fonts ease font weight transitions (#tilPost). Retrieved from https://www.scien.cx/2023/04/08/the-relative-font-weight-axis-how-variable-fonts-ease-font-weight-transitions-tilpost/

MLA
" » The relative font weight axis — how variable fonts ease font weight transitions (#tilPost)." Stefan Judis | Sciencx - Saturday April 8, 2023, https://www.scien.cx/2023/04/08/the-relative-font-weight-axis-how-variable-fonts-ease-font-weight-transitions-tilpost/
HARVARD
Stefan Judis | Sciencx Saturday April 8, 2023 » The relative font weight axis — how variable fonts ease font weight transitions (#tilPost)., viewed ,<https://www.scien.cx/2023/04/08/the-relative-font-weight-axis-how-variable-fonts-ease-font-weight-transitions-tilpost/>
VANCOUVER
Stefan Judis | Sciencx - » The relative font weight axis — how variable fonts ease font weight transitions (#tilPost). [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/04/08/the-relative-font-weight-axis-how-variable-fonts-ease-font-weight-transitions-tilpost/
CHICAGO
" » The relative font weight axis — how variable fonts ease font weight transitions (#tilPost)." Stefan Judis | Sciencx - Accessed . https://www.scien.cx/2023/04/08/the-relative-font-weight-axis-how-variable-fonts-ease-font-weight-transitions-tilpost/
IEEE
" » The relative font weight axis — how variable fonts ease font weight transitions (#tilPost)." Stefan Judis | Sciencx [Online]. Available: https://www.scien.cx/2023/04/08/the-relative-font-weight-axis-how-variable-fonts-ease-font-weight-transitions-tilpost/. [Accessed: ]
rf:citation
» The relative font weight axis — how variable fonts ease font weight transitions (#tilPost) | Stefan Judis | Sciencx | https://www.scien.cx/2023/04/08/the-relative-font-weight-axis-how-variable-fonts-ease-font-weight-transitions-tilpost/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.