Просмотр исходного кода

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

Former-commit-id: 239d6fbe1d3a567070404df422193233590235f9
Gildas 5 лет назад
Родитель
Сommit
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;