How to tell if your web font is loading?
How to ensure your fallback font is not replacing your primary typeface
Some engineers pride themselves on having a “designer’s eye.” They can spot if vertical alignment is off or if line-height isn’t set appropriately for the text size. Other times, we could use some help knowing for sure if a UI element is appearing as the designer call far.
One challenge is knowing if the web font you are calling with @font-face is indeed loading or not. Think you’ve got Helvetica displaying only to discover that the Arial fallback is showing up? Here’s how I ensure that the typeface I want is what is actually appearing.
Let’s say I want to use Open Sans from Google Fonts. The font stack Google suggests is:
font-family: 'Open Sans', sans-serif;
I put that in my styles, I hit save and looks pretty good. But if I take a closer look, it’s loading the sans-serif fallback and not Open Sans. How can I be sure of this when the generic family might be too close to the primary typeface for someone to easily identify? I plug in a more distinct generic family instead, preferably my favorite, fantasy.
font-family: 'Open Sans', fantasy;
Now on save, there’s definitely no mistaking that wonderful, magic that is definitely not Open Sans. It’s a quick way during development to identify our font-face is working as desired. You could also use a tool such as whatfont.
Be sure to set your font stack back to the desired fallback, unless some surprise Comic Sans or Papyrus is up your alley.