Menu

#24 woff fonts not supported in @font-face

open
nobody
None
5
2010-05-07
2010-05-07
Anonymous
No

When using a @font-face declaration with a WOFF font, the quotes around the format('woff'') are removed.
Unfortunatly, those quotes are required (at least for) Firefox 3.6 to correctly display the font, otherwise the rule is skipped. Quotes can be safely removed for truetype fonts, only the woff fonts have issues afaik.

Example :
@font-face {
font-family: "Unibody8SmallCaps Regular";
src:url('fonts/unibody_8-smallcaps-webfont.woff') format('woff');
}
gets compressed to :
@font-face{font-family: "Unibody8SmallCaps Regular"; src:url(fonts/unibody_8-smallcaps-webfont.woff) format(woff)}

This second rule isn't parsed by the browser because of the missing quotes around the 'woff'.

I'll try to dig into the code and see if I can fix it, but I'm not very confortable with the whole class yet.

Discussion

  • Pixelastic

    Pixelastic - 2010-05-07

    My mistake, format(truetype) does not get paresd either. In fact, quotes should never be removed around the format() element.

     
  • Pixelastic

    Pixelastic - 2010-05-07

    Ok, so in fact nothing is wrong with woff or truetype. CSSTidy does indeed already force the wrapping in double quote.

    I got confused because when defining multiple fonts, only the last format() gets wrapped in quotes.

    I had to edit the csstidy.php file, around line 847 to change the if statement to look like this :
    if($this->sub_value != '') {
    $this->sub_value_arr[] = $this->sub_value;
    foreach($this->sub_value_arr as &$sub_value) {
    if (substr($sub_value, 0, 6) == 'format') {
    $sub_value = str_replace(array('format(', ')'), array('format("', '")'), $sub_value);
    }
    }
    $this->sub_value = '';
    }

    It now correctly wrap in double quotes multiples format() definitions

     

Log in to post a comment.

MongoDB Logo MongoDB