|
|
@@ -181,18 +181,32 @@ this.fontsMinifier = this.fontsMinifier || (() => {
|
|
|
return { src: fontSource.match(REGEXP_FONT_SRC)[1], format: fontFormat };
|
|
|
});
|
|
|
const fontTest = (fontSource, format) => fontSource.format == format;
|
|
|
- const woff2FontFound = fontSources.find(fontSource => fontTest(fontSource, "woff2"));
|
|
|
- const woffFontFound = fontSources.find(fontSource => fontTest(fontSource, "woff"));
|
|
|
+ let woffFontFound = fontSources.find(fontSource => fontTest(fontSource, "woff2-variations"));
|
|
|
+ if (!woffFontFound) {
|
|
|
+ woffFontFound = fontSources.find(fontSource => fontTest(fontSource, "woff2"));
|
|
|
+ }
|
|
|
+ if (!woffFontFound) {
|
|
|
+ woffFontFound = fontSources.find(fontSource => fontTest(fontSource, "woff"));
|
|
|
+ }
|
|
|
stats.fonts.processed += fontSources.length;
|
|
|
stats.fonts.discarded += fontSources.length;
|
|
|
- if (woffFontFound || woff2FontFound) {
|
|
|
- fontSources = fontSources.filter(fontSource => woff2FontFound ? fontTest(fontSource, "woff2") : fontTest(fontSource, "woff"));
|
|
|
+ if (woffFontFound) {
|
|
|
+ fontSources = fontSources.filter(fontSource => fontTest(fontSource, woffFontFound.format));
|
|
|
} else {
|
|
|
- const ttfFontFound = fontSources.find(fontSource => fontTest(fontSource, "truetype"));
|
|
|
- const otfFontFound = fontSources.find(fontSource => fontTest(fontSource, "opentype"));
|
|
|
- const otfAltFontFound = fontSources.find(fontSource => fontTest(fontSource, "embedded-opentype"));
|
|
|
- if (otfFontFound || otfAltFontFound || ttfFontFound) {
|
|
|
- fontSources = fontSources.filter(fontSource => ttfFontFound ? fontTest(fontSource, "truetype") : otfFontFound ? fontTest(fontSource, "opentype") : fontTest(fontSource, "embedded-opentype"));
|
|
|
+ let ttfFontFound = fontSources.find(fontSource => fontTest(fontSource, "truetype-variations"));
|
|
|
+ if (!ttfFontFound) {
|
|
|
+ ttfFontFound = fontSources.find(fontSource => fontTest(fontSource, "truetype"));
|
|
|
+ }
|
|
|
+ if (ttfFontFound) {
|
|
|
+ fontSources = fontSources.filter(fontSource => fontTest(fontSource, ttfFontFound.format));
|
|
|
+ } else {
|
|
|
+ let otfFontFound = fontSources.find(fontSource => fontTest(fontSource, "opentype"));
|
|
|
+ if (!otfFontFound) {
|
|
|
+ otfFontFound = fontSources.find(fontSource => fontTest(fontSource, "embedded-opentype"));
|
|
|
+ }
|
|
|
+ if (otfFontFound) {
|
|
|
+ fontSources = fontSources.filter(fontSource => fontTest(fontSource, otfFontFound.format));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
stats.fonts.discarded -= fontSources.length;
|