arbk / cssmin

CssMin - A (simple) css minifier with benefits. (exported from Google Code)
http://code.google.com/p/cssmin/
1 stars 1 forks source link

Incorrect minification of font-face if there is no space before the opening brace #52

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What version of CssMin are you using (source and/or build)?
3.0.1

What was the input stylesheet and/or configuration options?
@font-face{
    font-family: 'HelveticaNeueBoldCond';
    src: url('../css/fonts/helveticaneue-boldcond-webfont.eot');
    src: url('../css/fonts/helveticaneue-boldcond-webfont.eot?#iefix') format('embedded-opentype'),
        url('../css/fonts/helveticaneue-boldcond-webfont.woff') format('woff'),
        url('../css/fonts/helveticaneue-boldcond-webfont.ttf') format('truetype'),
        url('../css/fonts/helveticaneue-boldcond-webfont.svg#HelveticaNeueBoldCond') format('svg');
    font-weight: normal;
    font-style: normal;
}

#bg1{
    position:absolute;
    z-index:1;
}

What is the expected result?
@font-face{font-family:'HelveticaNeueBoldCond';src:url('../css/fonts/helveticane
ue-boldcond-webfont.eot');src:url('../css/fonts/helveticaneue-boldcond-webfont.e
ot?#iefix') format('embedded-opentype'), 
url('../css/fonts/helveticaneue-boldcond-webfont.woff') format('woff'), 
url('../css/fonts/helveticaneue-boldcond-webfont.ttf') format('truetype'), 
url('../css/fonts/helveticaneue-boldcond-webfont.svg#HelveticaNeueBoldCond') 
format('svg');font-weight:normal;font-style:normal}#bg1{position:absolute;z-inde
x:1}

And what is the actual result and/or error message?
@font-face{position:absolute;z-index:1}

Please provide any additional information below.

The code to test it : print_r(CssMin::minify($content));
The fix is to add a space after @font-face, like so :
@font-face {
    font-family: 'HelveticaNeueBoldCond';
...

Original issue reported on code.google.com by cont...@pierre-martin.fr on 2 Feb 2012 at 4:36

GoogleCodeExporter commented 8 years ago
I have same bug. My code

@font-face {
    font-family: 'Bebas';
    src: url('../fonts/BebasNeue-webfont.eot');
    src: url('../fonts/BebasNeue-webfont.woff') format('woff'), url('../fonts/BebasNeue-webfont.ttf') format('truetype'), url('../fonts/BebasNeue-webfont.svg#webfontAGQ6uv7S') format('svg');
    font-weight: normal;
    font-style: normal;
} .clear { clear: both; }

doesnt minify correctly

Original comment by laurence...@gmail.com on 18 Apr 2012 at 12:20

GoogleCodeExporter commented 8 years ago
p.s. and I have tried on the current latest version 3.0.1. But I cant fix mine 
with the "The fix is to add a space after @font-face" - that still doesnt solve 
my bug

Original comment by laurence...@gmail.com on 18 Apr 2012 at 12:26

GoogleCodeExporter commented 8 years ago
There appears to be a problem with multipe @font-face declaration (where you 
use different font-weight/font-style combinations for different sources to make 
the browser pick the proper source).
cssmin seems to compact these into a single @font-face group (instead of 
keeping them separate (normal, bold, italic, bold-italic).

Original comment by dhahler@gmail.com on 17 Feb 2013 at 12:31

GoogleCodeExporter commented 8 years ago
I'm having the same issue with multiple @font-face CSS declarations

Original comment by a...@goneglobal.com on 30 Apr 2013 at 5:56

GoogleCodeExporter commented 8 years ago
I'm having this bug with @font-face

@font-face{
    font-family: bebas;
    src: url(../fonts/BebasNeue.otf);
}
html,body{height:100%;}
body{background:black;}

result is
@font-face{height:100%}body{background:black}

Original comment by antik...@gmail.com on 28 Jun 2013 at 10:04

GoogleCodeExporter commented 8 years ago
This problem can be fixed by changing
https://code.google.com/p/cssmin/source/browse/trunk/source/parser/plugins/CssAt
FontFaceParserPlugin.php#50
From
return $index + 10;
to
return $index + 9;

Original comment by michele....@progesoft.com on 18 May 2015 at 10:04