@font-face gotchas – Paul Irish

Over the past few months, I’ve collected a few worthwhile notes on @font-face that are worth reading over if you geek out about this stuff…

  • in Webkit (Chrome/Safari), applying font-weight:bold to faux-bold some @font-face’d text will not succeed. Same applies for font-style:italic. You can fix by adding the following to your @font-face declaration: (via doctype, crbug/31883, crbug/35739, webk.it/34147)

1

2

3

4

font-weight

:normal

;

font-style

:normal

;

font-variant

:normal

;

/* these values are defaults in FF/Opera/IE but not webkit */

@font-face links that might have sneaked past you

And.. regarding @font-face syntax

I now recommend the bulletproof smiley variation over the original bulletproof syntax.

1

2

3

4

5

6

@font-face

{

font-family

:

'Graublau Web'

;

src

:

url

(

'GraublauWeb.eot'

);

src

:

local

(

'?'

),

url

(

'GraublauWeb.woff'

)

format

(

'woff'

),

url

(

'GraublauWeb.ttf'

)

format

(

'truetype'

);

}

From the bulletproof post:

Yes, it’s a smiley face. The OpenType spec indicates any two-byte unicode characters won’t work in a font name on Mac at all, so that lessens the likelihood that someone actually released a font with such a name.

There are a few reasons why smiley is a better solution:

  • Webkit+Font Management software can mess up local references, like turning glyphs into A blocks.  (crbug.com/33173)
  • On OS X, Font Management software may alter system settings to show a dialog when trying to access a local() font that’s accessible outside of Library/Fonts. More detail on my bulletproof post. (crbug.com/29729) Font Explorer X is also known to mess up other stuff in Firefox: bugzil.la/531771
  • Although it’s unlikely, you could reference a local() font which is completely different than what you think it is. (Typophile post on different fonts, same name) At the very least its a risk, and you’re ceding control of the type to both the browser and host machine. This risk may not be worth the benefit of avoiding the font download.

These are all pretty edge case issues, but it’s worth considering. FontSquirrel has already made the smiley syntax the new default in the Generator, and you should use it going forward as well.