Ver Fonte

fixed font filtering

Gildas há 7 anos atrás
pai
commit
c587c3d61e

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

@@ -62,7 +62,7 @@ this.fontsMinifier = this.fontsMinifier || (() => {
 				filteredUsedFonts = new Map();
 				fontsInfo.used.forEach(fontNames => fontNames.forEach(familyName => {
 					if (fontsInfo.declared.find(fontInfo => fontInfo.fontFamily == familyName)) {
-						const optionalData = options.usedFonts && options.usedFonts.filter(fontInfo => fontInfo.fontFamily == familyName);
+						const optionalData = options.usedFonts && options.usedFonts.filter(fontInfo => fontInfo[0] == familyName);
 						filteredUsedFonts.set(familyName, optionalData);
 					}
 				}));
@@ -117,8 +117,8 @@ this.fontsMinifier = this.fontsMinifier || (() => {
 						removedRules.push(cssRule);
 					}
 				}
-			}
-		}
+					}
+				}
 		removedRules.forEach(cssRule => cssRules.remove(cssRule));
 	}
 
@@ -133,7 +133,7 @@ this.fontsMinifier = this.fontsMinifier || (() => {
 				.filter(fontInfo => fontInfo.fontFamily == familyName && fontInfo.fontStyle == fontStyle && testFontVariant(fontInfo, fontVariant))
 				.map(fontInfo => fontInfo.fontWeight)
 				.sort((weight1, weight2) => weight1 - weight2);
-			const usedFontWeights = optionalUsedFonts.map(fontInfo => findFontWeight(fontInfo.fontWeight, declaredFontsWeights));
+			const usedFontWeights = optionalUsedFonts.map(fontInfo => findFontWeight(fontInfo[1], declaredFontsWeights));
 			test = usedFontWeights.includes(fontWeight);
 		} else {
 			test = true;

+ 1 - 1
lib/single-file/util/doc-helper.js

@@ -127,7 +127,7 @@ this.docHelper = this.docHelper || (() => {
 			const fontFamilyNames = style.fontFamily.split(",");
 			fontFamilyNames.forEach(fontFamilyName => {
 				fontFamilyName = removeQuotes(fontFamilyName.trim()).toLowerCase();
-				if (!loadedFonts || loadedFonts.find(font => font.family.toLowerCase() == fontFamilyName && font.style == style.fontStyle && font.weight == style.fontWeight && font.weight == style.fontWeight && font.variant == style.fontVariant)) {
+				if (!loadedFonts || loadedFonts.find(font => font.family.toLowerCase() == fontFamilyName && font.style == style.fontStyle && font.variant == style.fontVariant)) {
 					const { fontWeight, fontStyle, fontVariant } = style;
 					usedFonts.add([fontFamilyName, fontWeight, fontStyle, fontVariant]);
 				}