log

January 31, 2010

All you never wanted to know about browser generic font family fallbacks

I recently needed to know exactly what fonts desktop browsers use in the case of generic font families. Getting this info for multiple platforms and languages is actually pretty difficult unless you enjoy sifting through several different source trees in several different source viewers.

Locales are generally expressed as two-letter language codes (‘en’ for English, ‘ar’ for Arabic), sometimes with an additional two-letter code for region or derivative (‘en-GB’ for British English, ‘zh-CN’ for Simplified Chinese). A good reference is the the Plesk Locale Codes doc.

Skip to the matrix if you’re just after en-US defaults.

Mozilla

Probably the easiest to read is Mozilla’s prefs file, simply because it’s all in one place. It’s grouped into platform then locale. For example, pref("font.name.serif.ja", "?? ???") specifies the serif font for Japanese.

Note that these may not be the defaults in all Mozilla-derived browsers

Chrome

Chrome breaks down font defaults into a generic platform file then specific override files. They follow a naming convention using the locale codes above. Files are in XML, thus needlessly verbose and hard to skim. Look for <message name="IDS_SERIF_FONT_FAMILY" use_name_for_id="true">Times New Roman</message> at the bottom of generic files and <translation id="IDS_SERIF_FONT_FAMILY">Tahoma</translation> in the overrides.

Safari/Webkit

Unlike the browsers above, Safari itself isn’t open source and so it’s hard to get a definitive list outside of Western locales. Webkit (the underlying engine that is open source) has these en-US defaults hard coded:

Stating the obvious but relevant: Webkit has been ported to a legion of devices and platforms now, each with their own frontend capable of changing the default generic fonts (especially in the case of mobile where only one font may be available). Firefox for Windows Mobile and Opera Mini are in the same boat. Determining the default generic fonts for these platforms is arguably pointless.

Opera

This one’s purely from observation of a local install on an ‘en-AU’ Windows machine (likely identical to any other ‘en’ install). I’m unable to check the defaults for any other platform atm.

Note that the original 10.0 release had a bug that did funky stuff to cursive and fantasy. Fixed in 10.1.

Internet Explorer

The truly problematic one. I don’t have the first idea how to gather this information without access to the regional build and OS. Information is welcome! On my ‘en-AU’ WinXP machine IE6 through 8 default to:

A quick font matrix for en-US

Browsers across the top header row, and font families down the first column. Where a font differs from other browsers, it has been highlighted and bolded.

Windows

Mozilla Safari Chrome Opera IE
Serif times new roman times new roman times new roman times new roman times new roman
Sans-serif arial arial arial arial arial
Monospace courier new courier new courier new courier new courier new
Cursive comic sans ms comic sans ms comic sans ms comic sans ms comic sans ms
Fantasy microsoft sans serif impact comic sans ms arial algerian

Mac

Mozilla Safari Chrome
Serif times times times
Sans-serif helvetica helvetica helvetica
Monospace courier courier courier
Cursive apple chancery apple chancery apple chancery
Fantasy papyrus papyrus papyrus

No one uses Fantasy apparently, and I can’t help but think that Apple used Comic Sans MS twice as a statement about the Windows aesthetic.

If you’re a browser dev with more info or if your results conflict, please let me know.

posted by Andrew

2 Responses to “All you never wanted to know about browser generic font family fallbacks”

  1. Liz Castro wrote:

    Thanks so much for this. Funny though, if I style a paragraph with “monospace” and another with “Courier” they should look exactly the same, no? But they don’t. The Courier one is bigger.

  2. hh wrote:

    Liz: The browsers tend to assign a lower point size to CSS “monospace”, as it is more legible. For example, Mozilla uses 16 px for regular fonts, and 12-13 px for fixed-width.

    Mozilla probably doesn’t know that “Courier” is “monospace”, hence the problem.

Leave a Comment

To customize the avatar that appears by your comment, visit Gravatar.com. The trackback URL for this post is here.