Jelajahi Sumber

don't test font-variant values

= 6 tahun lalu
induk
melakukan
d20cfb8823
1 mengubah file dengan 4 tambahan dan 9 penghapusan
  1. 4 9
      lib/single-file/modules/css-fonts-minifier.js

+ 4 - 9
lib/single-file/modules/css-fonts-minifier.js

@@ -163,12 +163,11 @@ this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMin
 		if (optionalUsedFonts && optionalUsedFonts.length) {
 			const fontStyle = getDeclarationValue(ruleData.block.children, "font-style") || "normal";
 			const fontWeight = getFontWeight(getDeclarationValue(ruleData.block.children, "font-weight") || "400");
-			const fontVariant = getDeclarationValue(ruleData.block.children, "font-variant") || "normal";
 			const declaredFontsWeights = declaredFonts
-				.filter(fontInfo => fontInfo.fontFamily == familyName && fontInfo.fontStyle == fontStyle && testFontVariant(fontInfo, fontVariant))
+				.filter(fontInfo => fontInfo.fontFamily == familyName && fontInfo.fontStyle == fontStyle)
 				.map(fontInfo => fontInfo.fontWeight)
 				.sort((weight1, weight2) => weight1 - weight2);
-			const usedFontWeights = optionalUsedFonts.map(fontInfo => getUsedFontWeight(fontInfo, fontStyle, fontVariant, declaredFontsWeights));
+			const usedFontWeights = optionalUsedFonts.map(fontInfo => getUsedFontWeight(fontInfo, fontStyle, declaredFontsWeights));
 			test = usedFontWeights.includes(fontWeight);
 		} else {
 			test = true;
@@ -224,9 +223,9 @@ this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMin
 		return fontFamilyNames;
 	}
 
-	function getUsedFontWeight(fontInfo, fontStyle, fontVariant, fontWeights) {
+	function getUsedFontWeight(fontInfo, fontStyle, fontWeights) {
 		let foundWeight;
-		if (fontInfo[2] == fontStyle && fontInfo[3] == fontVariant) {
+		if (fontInfo[2] == fontStyle) {
 			let fontWeight = Number(fontInfo[1]);
 			if (fontWeight >= 400 && fontWeight <= 500) {
 				foundWeight = fontWeights.find(weight => weight >= fontWeight && weight <= 500);
@@ -299,10 +298,6 @@ this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMin
 		return "";
 	}
 
-	function testFontVariant(fontInfo, fontVariant) {
-		return fontInfo.fontVariant == fontVariant || "normal" || fontInfo.fontVariant == fontVariant || "common-ligatures";
-	}
-
 	function testUnicodeRange(docContent, unicodeRange) {
 		if (unicodeRange) {
 			const unicodeRanges = unicodeRange.split(REGEXP_COMMA);