Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The @font-face src: ... format() attribute isn't quoted, resulting in a weird cross-browser bug #2329

Open
johncomposed opened this issue Sep 25, 2017 · 2 comments

Comments

@johncomposed
Copy link

A friend and I spent a good portion of the day puzzling over why a font declared via @font-face was not working on chrome or firefox (but worked fine on safari) and we just figured it out so I thought I'd make a note of it here.

When using the @font-face rule in stylus you can write out src url(/path/to/font.extension) without quotes, which turns into src: url("/path/to/font.extension");. So far so good. But when you manually specify the format of a font face like src url(path.ext) format(format), it turns into src: url("path.ext") format(format); Notice how src gets quoted but format doesn't.

Here's a screenshot of this from the try stylus page:
screen shot 2017-09-24 at 10 46 14 pm

Now here's where that inconsistency can really bite someone. format(woff) isn't valid css in firefox or chrome.... but apparently is in safari(!). And moreover, in firefox and chrome, it fails totally silently. No errors, nothing. It just doesn't try to get that font. Cue frustrated designers trying to figure out why their font only works in safari because secretly they have to write src url(path.woff) format("woff") (or quote both, or not use format() at all) to make it work. It's not the biggest bug in the world, but it definitely had us questioning our sanity, life choices, the web, the 21st century in general, etc for a bit there.

Anyway, just thought I'd bring that to the community's attention!

@badoubadou
Copy link

Damned ! I waisted my day on this ! Is it ok not to mention format ? Thanks !!!!

@robinmetral
Copy link

robinmetral commented Aug 10, 2018

Also if you want to specify several formats (say woff and woff2), you can NOT omit the comma.

So so far my stylus @font-face rules look like this:

@font-face
    font-family MyFont
    font-weight bold 
    font-style normal
    src url(fonts/myfont.woff) format("woff"),
        url(fonts/myfont.woff2) format("woff2")

It would be great to be able to omit quotes in format(), and the comma between formats!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants