|
|
@@ -64,7 +64,7 @@ this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMin
|
|
|
const matchedVar = familyName.match(/^var\((--.*)\)$/);
|
|
|
if (matchedVar && matchedVar[1]) {
|
|
|
const computedFamilyName = getComputedStyle.call(window, options.doc.body).getPropertyValue(matchedVar[1]);
|
|
|
- return (computedFamilyName && computedFamilyName.split(",").map(name => singlefile.lib.helper.getFontFamily(name))) || familyName;
|
|
|
+ return (computedFamilyName && computedFamilyName.split(",").map(name => singlefile.lib.helper.normalizeFontFamily(name))) || familyName;
|
|
|
}
|
|
|
return familyName;
|
|
|
}));
|
|
|
@@ -108,7 +108,7 @@ this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMin
|
|
|
}
|
|
|
} else {
|
|
|
if (ruleData.type == "Atrule" && ruleData.name == "font-face") {
|
|
|
- const fontFamily = singlefile.lib.helper.getFontFamily(getDeclarationValue(ruleData.block.children, "font-family"));
|
|
|
+ const fontFamily = singlefile.lib.helper.normalizeFontFamily(getDeclarationValue(ruleData.block.children, "font-family"));
|
|
|
if (fontFamily) {
|
|
|
const fontWeight = getDeclarationValue(ruleData.block.children, "font-weight") || "400";
|
|
|
const fontStyle = getDeclarationValue(ruleData.block.children, "font-style") || "normal";
|
|
|
@@ -128,7 +128,7 @@ this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMin
|
|
|
if (ruleData.type == "Atrule" && ruleData.name == "media" && ruleData.block && ruleData.block.children) {
|
|
|
filterUnusedFonts(ruleData.block.children, declaredFonts, unusedFonts, filteredUsedFonts, docContent);
|
|
|
} else if (ruleData.type == "Atrule" && ruleData.name == "font-face") {
|
|
|
- const fontFamily = singlefile.lib.helper.getFontFamily(getDeclarationValue(ruleData.block.children, "font-family"));
|
|
|
+ const fontFamily = singlefile.lib.helper.normalizeFontFamily(getDeclarationValue(ruleData.block.children, "font-family"));
|
|
|
if (fontFamily) {
|
|
|
const unicodeRange = getDeclarationValue(ruleData.block.children, "unicode-range");
|
|
|
if (unusedFonts.find(fontInfo => fontInfo.fontFamily == fontFamily) || !testUnicodeRange(docContent, unicodeRange) || !testUsedFont(ruleData, fontFamily, declaredFonts, filteredUsedFonts)) {
|
|
|
@@ -202,7 +202,7 @@ this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMin
|
|
|
if (fontFamilyName.data.value.children) {
|
|
|
fontFamilyName.data.value.children.forEach(node => {
|
|
|
if (node.type == "Operator" && node.value == "," && familyName) {
|
|
|
- fontFamilyNames.push(singlefile.lib.helper.getFontFamily(familyName));
|
|
|
+ fontFamilyNames.push(singlefile.lib.helper.normalizeFontFamily(familyName));
|
|
|
familyName = "";
|
|
|
} else {
|
|
|
familyName += cssTree.generate(node);
|
|
|
@@ -212,14 +212,14 @@ this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMin
|
|
|
fontFamilyName = cssTree.generate(fontFamilyName.data.value);
|
|
|
}
|
|
|
if (familyName) {
|
|
|
- fontFamilyNames.push(singlefile.lib.helper.getFontFamily(familyName));
|
|
|
+ fontFamilyNames.push(singlefile.lib.helper.normalizeFontFamily(familyName));
|
|
|
}
|
|
|
}
|
|
|
const font = declarations.children.filter(node => node.property == "font").tail;
|
|
|
if (font && font.data && font.data.value) {
|
|
|
try {
|
|
|
const parsedFont = singlefile.lib.vendor.fontPropertyParser.parse(cssTree.generate(font.data.value));
|
|
|
- parsedFont.family.forEach(familyName => fontFamilyNames.push(singlefile.lib.helper.getFontFamily(familyName)));
|
|
|
+ parsedFont.family.forEach(familyName => fontFamilyNames.push(singlefile.lib.helper.normalizeFontFamily(familyName)));
|
|
|
} catch (error) {
|
|
|
// ignored
|
|
|
}
|