|
|
@@ -110,10 +110,11 @@ this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMin
|
|
|
if (ruleData.type == "Atrule" && ruleData.name == "font-face") {
|
|
|
const fontFamily = singlefile.lib.helper.getFontFamily(getDeclarationValue(ruleData.block.children, "font-family"));
|
|
|
if (fontFamily) {
|
|
|
- const fontWeight = singlefile.lib.helper.getFontWeight(getDeclarationValue(ruleData.block.children, "font-weight") || "400");
|
|
|
+ const fontWeight = getDeclarationValue(ruleData.block.children, "font-weight") || "400";
|
|
|
const fontStyle = getDeclarationValue(ruleData.block.children, "font-style") || "normal";
|
|
|
const fontVariant = getDeclarationValue(ruleData.block.children, "font-variant") || "normal";
|
|
|
- fontsInfo.declared.push({ fontFamily, fontWeight, fontStyle, fontVariant });
|
|
|
+ fontWeight.split(",").forEach(weightValue =>
|
|
|
+ fontsInfo.declared.push({ fontFamily, fontWeight: singlefile.lib.helper.getFontWeight(singlefile.lib.helper.removeQuotes(weightValue)), fontStyle, fontVariant }));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -159,20 +160,24 @@ this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMin
|
|
|
.map(fontInfo => fontInfo.fontWeight)
|
|
|
.sort((weight1, weight2) => weight1 - weight2);
|
|
|
let usedFontWeights = optionalUsedFonts.map(fontInfo => getUsedFontWeight(fontInfo, fontStyle, declaredFontsWeights));
|
|
|
- test = usedFontWeights.includes(fontWeight);
|
|
|
+ test = testFontweight(fontWeight, usedFontWeights);
|
|
|
if (!test) {
|
|
|
usedFontWeights = optionalUsedFonts.map(fontInfo => {
|
|
|
fontInfo[2] = "normal";
|
|
|
return getUsedFontWeight(fontInfo, fontStyle, declaredFontsWeights);
|
|
|
});
|
|
|
}
|
|
|
- test = usedFontWeights.includes(fontWeight);
|
|
|
+ test = testFontweight(fontWeight, usedFontWeights);
|
|
|
} else {
|
|
|
test = true;
|
|
|
}
|
|
|
return test;
|
|
|
}
|
|
|
|
|
|
+ function testFontweight(fontWeight, usedFontWeights) {
|
|
|
+ return fontWeight.split(",").find(weightValue => usedFontWeights.includes(singlefile.lib.helper.getFontWeight(singlefile.lib.helper.removeQuotes(weightValue))));
|
|
|
+ }
|
|
|
+
|
|
|
function getDeclarationValue(declarations, propertyName) {
|
|
|
let property;
|
|
|
if (declarations) {
|