瀏覽代碼

test font-style "normal" if the font is not declared

Former-commit-id: 239d6fbe1d3a567070404df422193233590235f9
Gildas 5 年之前
父節點
當前提交
ab014d4b93
共有 1 個文件被更改,包括 8 次插入1 次删除
  1. 8 1
      lib/single-file/modules/css-fonts-minifier.js

+ 8 - 1
lib/single-file/modules/css-fonts-minifier.js

@@ -158,7 +158,14 @@ this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMin
 				.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, declaredFontsWeights));
+			let usedFontWeights = optionalUsedFonts.map(fontInfo => getUsedFontWeight(fontInfo, fontStyle, declaredFontsWeights));
+			test = usedFontWeights.includes(fontWeight);
+			if (!test) {
+				usedFontWeights = optionalUsedFonts.map(fontInfo => {
+					fontInfo[2] = "normal";
+					return getUsedFontWeight(fontInfo, fontStyle, declaredFontsWeights);
+				});
+			}
 			test = usedFontWeights.includes(fontWeight);
 		} else {
 			test = true;