Zach’s ugly mug (his face)

Zach Leatherman

font-display is Incompatible with Icon Fonts

May 22, 2019

There are myriad problems with icon fonts. I won’t rehash those again here but I did a section on this specific topic in The Scoville Scale of Web Font Loading Opinions. A bunch of people have written about this before:

The main point that I think hasn’t really been communicated enough is that icon fonts exist in a place that would seem to be outside of the web standards mainstream. Specifically, the font loading poster child—the font-display descriptor—has no valid value that is compatible with icon fonts.

When you load an icon font, you often never want the fallback text to render. It isn’t a typical Flash of Unstyled Text (FOUT) scenario. If the fallback text for an icon font renders, who knows what you might see.

If the icon font uses glyphs mapped to the Private Use Area, you may see emoji characters (this is a common failure scenario).

Screenshot of the Private Use Area (with emoji) on iOS

If the icon font uses ligatures, you could see the ligature text (which is better, but often also not handled very well).

Screenshot of the Ligature icon fallback of Google News (showing overlapping text with content)

Some browsers (Firefox) show a TOFU character as fallback.

Twitter Icon Font Fallback Screenshot

An astute web font loading reader might reach for the easiest tool in the toolbox to solve font loading issues: the font-display descriptor. However there are no good values for font-display that will offer invisible text. In fact, a few of the values will be quite bad.

  • Using font-display: optional on your icon font means that it will only render on repeat views and renders fallback text on empty cache views: Very Bad 🚫
  • Using font-display: swap on your icon font means that it will render fallback text immediately while waiting for the web font to finish loading: Bad 🚫
  • Using font-display: fallback will only render the icon font if it loads within a short (usually 3 second) time period: Not great 🚫
  • Using font-display: block is the default behavior and will use invisible text for up to 3 seconds and show fallback text until the web font load completes: The best option but still not good 🚫

To workaround these issues, you could use the CSS Font Loading API to force invisible text until the icon font has successfully loaded. Or, perhaps more in line with the web standards mainstream, you could make a better investment and convert your icons to use SVG instead.

Zach’s ugly mug (his face)

Zach is a builder for the web with Netlify. He’s currently fixated on web fonts and static site generators. His public speaking résumé includes talks in eight different countries at events like Beyond Tellerrand, Smashing Conference, CSSConf, and The White House. He is an emeritus of Filament Group, NEJS CONF, and still helps out with NebraskaJS. Read more about Zach »

Previous
The Co-opetition of Team Web
Next
Web Engineering Düsseldorf

17 Retweets

Todd Parker_fazRomaric Pascal@thomas@social.tzi.frKevin GarciaNicolas HoizeyEevert NoviusAmandeep singhComandeerFresh Frontend LinksAnthony BarréJens TangermannCristiano RastelliAndy DaviesDimitris GrammatikostrongestHrvoje Blažeković
43 Likes
Jean-Pierre VincentDaniel SchildtAaron PetersSamar PandaErik VorhesC KhalifaThomas DikSam SnellingAmandeep singhJalal AzimiJSamuel HauserŠime VidasPaul MeleroVeniamin KrolMattia AstorinoEl niño del pixelDaniel KosterMarco useCauseAndEffect()Coco MarzJens TangermannOtodayoTaty GrassiniCristiano RastelliShahriar MayeenAllison SigristOsman YazıcıAndrewIngo Steinke 🇪🇺PaulDannie VintherJohn PalaganasThanh TrầnPatrick Johnson (pbj)Riccardo ErraJuha Liikala 👾Daniel CanetVuildNicolas FerrandUnusable PodcastMark Hähnelnils binder 🏳️‍🌈Hrvoje Blažeković
23 Mentions
  1. Веб-стандарты

    Веб-стандарты @webstandards_ru #

    Свойство font-display не совместимо с иконочными шрифтами. Зак Лезерман объясняет, почему стандартные стратегии загрузки не подходят для иконочных шрифтов — zachleat.com/web/font-displ…

  2. sportmedblog.wordpress.com #

  3. statisticssources.wordpress.com #

  4. socialworkandsocialissues.wordpress.com #

  5. findinggrantsandlearninggrantadministrationskills994981200.wordpress.com #

  6. jwneastro https://recreationandleisure983702521.wordpress.com/author/jwneastro/ #

    lcarlson May 29 +++ WEB DESIGN UPDATE. – Volume 17, Issue 49, May 29, 2019. An email newsletter to distribute news and information about web design and development. ++ISSUE 49 CONTENTS. SECTION ONE: New references. What’s new at the Web Design Reference site? http://www.d.u… Truncated

  7. prismo.xyz #

  8. stephaniewalter.design #

  9. Friday Front-End

    Friday Front-End @fridayfrontend #

    font-display is Incompatible with Icon Fonts, by @zachleat zachleat.com/web/font-displ…

  10. Adrian Roselli 🗯

    Adrian Roselli 🗯 @aardrian #

    “font-display Is Incompatible with Icon Fonts” zachleat.com/web/font-displ… As if you needed more reasons to avoid icon fonts.

  11. Stéphanie Walter

    Stéphanie Walter @WalterStephanie #

    #CSS #Font #Performance font-display is Incompatible with Icon Fonts, meeeh this is not cool zachleat.com/web/font-displ…

  12. dailydevlinks.

    dailydevlinks. @dailydevlinks #

    font-display is Incompatible with Icon Fonts: zachleat.com/web/font-displ… #html #css #javascript #webdev #dailydevlinks

  13. mailsgun.ru #

  14. www.dubado.com #

  15. wpdesignherald.wordpress.com #

  16. Jason Grigsby, ☁4

    Jason Grigsby, ☁4 @grigs #

    Love this article. Icon fonts on the web have always been a hack. A clever hack mind you, but a hack nonetheless. The font-display property is designed to speed up fonts and offer fallbacks. The fact it doesn’t work for icon fonts highlights that they are a hack we should avoi… Truncated

  17. find-right-software.com #

  18. unsorted.co #

  19. www.alvinashcraft.com #

  20. Kelly

    Kelly @kellytle #

    Team SVG

  21. Vincent De Oliveira

    Vincent De Oliveira @iamvdo #

    Another great point on using SVG for icons 👍

  22. nils binder 🏳️‍🌈

    nils binder 🏳️‍🌈 @supremebeing09 #

    So please stop using Icon Fonts ... SVG is awesome. Working with SVG can be hard at first, but in the end, it is so much fun!

  23. Sara Soueidan

    Sara Soueidan @SaraSoueidan #

    One more reason you shouldn’t be using icon fonts. 👏🏻 It’s 2019. Use #SVG.