|
|
@@ -35,13 +35,7 @@ this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMin
|
|
|
const REGEXP_STARTS_U_PLUS = /^U\+/i;
|
|
|
const REGEXP_SIMPLE_QUOTES_STRING = /^'(.*?)'$/;
|
|
|
const REGEXP_DOUBLE_QUOTES_STRING = /^"(.*?)"$/;
|
|
|
- const FONT_WEIGHTS = {
|
|
|
- regular: "400",
|
|
|
- normal: "400",
|
|
|
- bold: "700",
|
|
|
- bolder: "700",
|
|
|
- lighter: "100"
|
|
|
- };
|
|
|
+
|
|
|
|
|
|
return {
|
|
|
process: (doc, stylesheets, styles, options) => {
|
|
|
@@ -119,7 +113,7 @@ this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMin
|
|
|
if (ruleData.type == "Atrule" && ruleData.name == "font-face") {
|
|
|
const fontFamily = getFontFamily(getDeclarationValue(ruleData.block.children, "font-family"));
|
|
|
if (fontFamily) {
|
|
|
- const fontWeight = getFontWeight(getDeclarationValue(ruleData.block.children, "font-weight") || "400");
|
|
|
+ const fontWeight = singlefile.lib.helper.getFontWeight(getDeclarationValue(ruleData.block.children, "font-weight") || "400");
|
|
|
const fontStyle = getDeclarationValue(ruleData.block.children, "font-style") || "normal";
|
|
|
const fontVariant = getDeclarationValue(ruleData.block.children, "font-variant") || "normal";
|
|
|
fontsInfo.declared.push({ fontFamily, fontWeight, fontStyle, fontVariant });
|
|
|
@@ -162,7 +156,7 @@ this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMin
|
|
|
const optionalUsedFonts = filteredUsedFonts && filteredUsedFonts.get(familyName);
|
|
|
if (optionalUsedFonts && optionalUsedFonts.length) {
|
|
|
const fontStyle = getDeclarationValue(ruleData.block.children, "font-style") || "normal";
|
|
|
- const fontWeight = getFontWeight(getDeclarationValue(ruleData.block.children, "font-weight") || "400");
|
|
|
+ const fontWeight = singlefile.lib.helper.getFontWeight(getDeclarationValue(ruleData.block.children, "font-weight") || "400");
|
|
|
const declaredFontsWeights = declaredFonts
|
|
|
.filter(fontInfo => fontInfo.fontFamily == familyName && fontInfo.fontStyle == fontStyle)
|
|
|
.map(fontInfo => fontInfo.fontWeight)
|
|
|
@@ -351,8 +345,4 @@ this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMin
|
|
|
return string.trim().replace(/\\+ +/gi, " ");
|
|
|
}
|
|
|
|
|
|
- function getFontWeight(weight) {
|
|
|
- return FONT_WEIGHTS[weight.toLowerCase()] || weight;
|
|
|
- }
|
|
|
-
|
|
|
})();
|