https://woorkup.com/system-font/
I’m a big fan of web performance. But I also don’t think that it should or have to compromise design. There is always a good balance in the middle. Back in 2017, I was on GitHub’s blog and was digging their font. It was super easy to read. So I dug into the properties with Chrome Devtools and saw that they were using a system font stack.
I’ve been using system fonts for years now and love them. So today I want to show you how to use a system font stack on your WordPress site.
What is a system font stack?
There are different types of fonts to choose from when it comes to a website. You pretty much have four different options:
- Web safe fonts: Free and no download time required by the browser, but typically look dated and therefore aren’t used a lot. See a list of web safe fonts.
- Web fonts: Look beautiful, but require download by the browser. Have both free and premium options available. Adds to the overall page weight of your website. However, they can be served from cached CDN. Providers include Google, Adobe Fonts (TypeKit), etc.
- Host web fonts locally: Both free and premium options available. Still requires download time, can take advantage of a single HTTP/2 connection on cached CDN.
- System fonts: Free, look pretty darn good as they match the OS, and no download time required! They are used by Weather.com, GitHub, Bootstrap, Medium, Ghost, Booking.com (read their system font story), and even your WordPress dashboard. In my personal opinion system fonts look slightly better on macOS versus Windows.
System fonts are nothing new. In fact, Medium has been using them since 2015. They feel just like your OS because they are using native fonts. Many of the modern operating systems choose fonts very wisely and all have a very sleek look and feel to them. It’s not like defaulting back to a web-safe font of Arial or Times New Roman. Trust me, nobody wants to see Times New Roman on a website.
And best of all, system fonts work just like web safe fonts, in that they don’t require any download time by the browser. This can help reduce the overall page weight on your website. As of April 2020, web fonts on average make up around 6.2% of a total website’s weight. While this is not huge, remember every little optimization you make adds up to a speedy website.
Are there any disadvantages to using system fonts? Well, one would be that they are dependent on browsers working correctly. Google actually broke bold weight system fonts in Chrome 81 on macOS. Thankfully they fixed this in Chrome 83. But there was a short period of time were any website using a system font looked a little weird.
System font stack CSS
With the font-family property with web fonts, you typically have your primary font and one or two fallback fonts. With system fonts, you have to include all of the different operating systems, and therefore you have to stack quite a few more fonts. This is why it is called a “system font stack.”
For example, here is how CSS might appear with a web font.
font-family: "Open Sans","Helvetica Neue",sans-serif;
And here is how a system font stack might look.
font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"
Did you know your WordPress dashboard uses a system font stack? Here is what they are using.
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif
CSS-Tricks also has an alternative method on how to apply system fonts using @font-face.
System font stack cheatsheet
So this is where you have to choose which setup you want. Here is a list of which fonts go with each operating system. Note: This changes over time, so you might need to revisit your fonts as new operating systems come out. I will make sure to keep this list updated.
System Font | OS |
---|---|
-apple-system (San Francisco) | iOS Safari, macOS Safari, macOS Firefox |
system-ui | macOS Chrome, Windows Chrome (new versions) |
BlinkMacSystemFont (San Francisco) | macOS Chrome |
Segoe UI | Windows Vista and newer |
Tahoma | Windows XP |
Roboto | Android, Chrome OS |
Oxygen / Oxygen-Sans | KDE |
Fira Sans | Firefox OS |
Droid Sans | Android (old versions) |
Ubuntu | Ubuntu |
Cantarell | GNOME |
Helvetica Neue | macOS versions < 10.11 |
Arial | All |
sans-serif | All |
How to implement a system font stack
I’m now using a system font stack here on woorkup.com. I feel like I have finally found the best of both worlds. I will walk you through how I did it.
Option 1: Use the GeneratePress WordPress theme
Want to make this super easy? Just move to the GeneratePress theme, which is what I use on all of my websites. In the customizer, under Typography, you can simply select “System Stack.” And that’s it!
Generate Press theme system stack
Option 2: Add system font stack with CSS
If you’re using another WordPress them, you can easily move to a system font stack with a little CSS.
Step 1
In WordPress, you’ll need to change the CSS on your font-family. You can use the WordPress customizer to add the code, under “Additional CSS.”
Add system font CSS in WordPress customizer
Step 2
Enter the following code. This might vary per theme, but for most this should override everything. I’m using the same system font stack as GithHub, except for I’m adding “system-ui” as newer versions of Chrome support that. Remember, they will be used in the order they appear in the stack.
body {font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";}
h1,h2,h3,h4,h5,h6 {font-family:-apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";}
Depending on your theme, you might need to add paragraph tags for the body content. So it would be this:
body, p {font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";}
Step 3
You will also want to disable any 3rd party fonts, such as Google Fonts, that you have loaded from your WordPress theme. This again can vary, as each developer includes fonts in a different way. But many themes now have an easy way to toggle Google Fonts on or off.
If you are using a default WordPress theme you can easily use the free Disable Google Fonts plugin. Or you can also disable Google fonts in our Perfmatters plugin.
Before and after speed tests
And of course, I couldn’t resist. Here are before and after speed tests. Each test was run 5 times and an average taken.
Speed test before
Here is the speed test before, when I had Google fonts loading.
Speed test after
Here is the speed test after, using my system font stack. As you can see, I dropped my entire page weight by about 60 KB, and got rid of three requests. One to fonts.googleapis.com and then 2 downloads for different font-weight versions of Roboto. The system font stack was about 6% faster than using Google fonts.
Speed test with system font stack
I know a lot of sites that use 4-5 different font weights or styles, and sometimes even 2-3 different Google fonts. So you could potentially see even greater improvements than even I did.
I also moved our wpcoupons.io WordPress site to system fonts and had great results, check out this speed test below.
Font smoothing#
Font smoothing really comes down to your own personal preference. When you apply antialiasing, your font will be a little thinner and lighter. I’m not using it on this site as I prefer the slightly thicker font, I think it feels a little warmer. But you can experiment with both to see which one you like.
You can add this to the body.
body {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
Summary
System fonts can be a great alternative to web fonts and web safe fonts. I still really like the look of my font, and now I know it’s not causing any load for users. Even though a lot of times Google fonts are cached locally, it’s still part of the overall page weight.