rbtech / css-purge

A CSS tool written in Node JS as a command line app or library for the purging, burning, reducing, shortening, compressing, cleaning, trimming and formatting of duplicate, extra, excess or bloated CSS.
http://rbtech.github.io/css-purge
MIT License
125 stars 19 forks source link

@font-face not handled correctly #4

Closed thomas-rager closed 10 years ago

thomas-rager commented 10 years ago

Hi,

I found a bug:

All @font-face are joint together in one big @font-face. This is not correct, because only the last font-style survives.

Input-Example:

@font-face {
  font-family: "AppFontSerif";
  font-style: italic;
  font-weight: normal;
  src: url("../fonts/corporateACondensedRegularItalic/corporateacon-regita-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateACondensedRegularItalic/corporateacon-regita-webfont.ttf") format("truetype");
}

@font-face {
  font-family: "AppFontSerif";
  font-style: normal;
  font-weight: normal;
  src: url("../fonts/corporateACondensedRegular/corporateacon-reg-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateACondensedRegular/corporateacon-reg-webfont.ttf") format("truetype");
}

@font-face {
  font-family: "AppFontSerif";
  font-style: italic;
  font-weight: normal;
  src: url("../fonts/corporateARegularItalic/corporatea-regita-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateARegularItalic/corporatea-regita-webfont.ttf") format("truetype");
}

@font-face {
  font-family: "AppFontSerif";
  font-style: normal;
  font-weight: bold;
  src: url("../fonts/corporateABold/corporab-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateABold/corporab-webfont.ttf") format("truetype");
}

@font-face {
  font-family: "AppFontSerif";
  font-style: italic;
  font-weight: normal;
  src: url("../fonts/corporateADemiItalic/corpoademitalic-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateADemiItalic/corpoademitalic-webfont.ttf") format("truetype");
}

@font-face {
  font-family: "AppFontSerif";
  font-style: normal;
  font-weight: normal;
  src: url("../fonts/corporateADemi/corpoadem-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateADemi/corpoadem-webfont.ttf") format("truetype");
}

@font-face {
  font-family: "AppFontSansSerif";
  font-style: normal;
  font-weight: normal;
  src: url("../fonts/corporateSRegular/corporsr-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateSRegular/corporsr-webfont.ttf") format("truetype");
}

@font-face {
  font-family: "AppFontSansSerif";
  font-style: italic;
  font-weight: normal;
  src: url("../fonts/corporateSLightItalic/corposli-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateSLightItalic/corposli-webfont.ttf") format("truetype");
}

@font-face {
  font-family: "AppFontSansSerif";
  font-style: normal;
  font-weight: bold;
  src: url("../fonts/corporateSBold/corporatesbold-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateSBold/corporatesbold-webfont.ttf") format("truetype");
}

@font-face {
  font-family: "AppFontSansSerif";
  font-style: italic;
  font-weight: normal;
  src: url("../fonts/corporateSRegularItalic/corposregital-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateSRegularItalic/corposregital-webfont.ttf") format("truetype");
}

Output Example:


@font-face {
    font-family: "AppFontSerif";
    font-style: italic;
    font-weight: normal;
    src: url("../fonts/corporateACondensedRegularItalic/corporateacon-regita-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateACondensedRegularItalic/corporateacon-regita-webfont.ttf") format("truetype");
    font-family: "AppFontSerif";
    font-style: normal;
    font-weight: normal;
    src: url("../fonts/corporateACondensedRegular/corporateacon-reg-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateACondensedRegular/corporateacon-reg-webfont.ttf") format("truetype");
    font-family: "AppFontSerif";
    font-style: italic;
    font-weight: normal;
    src: url("../fonts/corporateARegularItalic/corporatea-regita-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateARegularItalic/corporatea-regita-webfont.ttf") format("truetype");
    font-family: "AppFontSerif";
    font-style: normal;
    font-weight: bold;
    src: url("../fonts/corporateABold/corporab-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateABold/corporab-webfont.ttf") format("truetype");
    font-family: "AppFontSerif";
    font-style: italic;
    font-weight: normal;
    src: url("../fonts/corporateADemiItalic/corpoademitalic-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateADemiItalic/corpoademitalic-webfont.ttf") format("truetype");
    font-family: "AppFontSerif";
    font-style: normal;
    font-weight: normal;
    src: url("../fonts/corporateADemi/corpoadem-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateADemi/corpoadem-webfont.ttf") format("truetype");
    font-family: "AppFontSansSerif";
    font-style: normal;
    font-weight: normal;
    src: url("../fonts/corporateSRegular/corporsr-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateSRegular/corporsr-webfont.ttf") format("truetype");
    font-family: "AppFontSansSerif";
    font-style: italic;
    font-weight: normal;
    src: url("../fonts/corporateSLightItalic/corposli-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateSLightItalic/corposli-webfont.ttf") format("truetype");
    font-family: "AppFontSansSerif";
    font-style: normal;
    font-weight: bold;
    src: url("../fonts/corporateSBold/corporatesbold-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateSBold/corporatesbold-webfont.ttf") format("truetype");
    font-family: "AppFontSansSerif";
    font-style: italic;
    font-weight: normal;
    src: url("../fonts/corporateSRegularItalic/corposregital-webfont.eot?#iefix") format("embedded-opentype"),
    url("../fonts/corporateSRegularItalic/corposregital-webfont.ttf") format("truetype");
}
AndrewEQ commented 10 years ago

Hi Thomas, sorry for the really late reply; I didn't get the mail from Github...

So it should probably ignore @font-face?

AndrewEQ commented 10 years ago

Sorted.