|
@@ -21,10 +21,14 @@
|
|
|
* Source.
|
|
* Source.
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
|
|
+/* global window */
|
|
|
|
|
+
|
|
|
this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMinifier || (() => {
|
|
this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMinifier || (() => {
|
|
|
|
|
|
|
|
const singlefile = this.singlefile;
|
|
const singlefile = this.singlefile;
|
|
|
|
|
|
|
|
|
|
+ const getComputedStyle = window.getComputedStyle;
|
|
|
|
|
+
|
|
|
const REGEXP_COMMA = /\s*,\s*/;
|
|
const REGEXP_COMMA = /\s*,\s*/;
|
|
|
const REGEXP_DASH = /-/;
|
|
const REGEXP_DASH = /-/;
|
|
|
const REGEXP_QUESTION_MARK = /\?/g;
|
|
const REGEXP_QUESTION_MARK = /\?/g;
|
|
@@ -63,6 +67,16 @@ this.singlefile.lib.modules.fontsMinifier = this.singlefile.lib.modules.fontsMin
|
|
|
});
|
|
});
|
|
|
workStyleElement.remove();
|
|
workStyleElement.remove();
|
|
|
docContent += doc.body.innerText;
|
|
docContent += doc.body.innerText;
|
|
|
|
|
+ if (getComputedStyle) {
|
|
|
|
|
+ fontsInfo.used = fontsInfo.used.map(fontNames => fontNames.map(fontName => {
|
|
|
|
|
+ const matchedVar = fontName.match(/^var\((--.*)\)$/);
|
|
|
|
|
+ if (matchedVar && matchedVar[1]) {
|
|
|
|
|
+ const computedFontName = getComputedStyle.call(window, options.doc.body).getPropertyValue(matchedVar[1]);
|
|
|
|
|
+ return computedFontName || fontName;
|
|
|
|
|
+ }
|
|
|
|
|
+ return fontName;
|
|
|
|
|
+ }));
|
|
|
|
|
+ }
|
|
|
const variableFound = fontsInfo.used.find(fontNames => fontNames.find(fontName => fontName.startsWith("var(--")));
|
|
const variableFound = fontsInfo.used.find(fontNames => fontNames.find(fontName => fontName.startsWith("var(--")));
|
|
|
let unusedFonts, filteredUsedFonts;
|
|
let unusedFonts, filteredUsedFonts;
|
|
|
if (variableFound) {
|
|
if (variableFound) {
|