瀏覽代碼

set font as valid if the timeout expires

= 6 年之前
父節點
當前提交
2fe384d2f2
共有 1 個文件被更改,包括 5 次插入2 次删除
  1. 5 2
      lib/single-file/modules/css-fonts-alt-minifier.js

+ 5 - 2
lib/single-file/modules/css-fonts-alt-minifier.js

@@ -58,7 +58,7 @@ this.singlefile.lib.modules.fontsAltMinifier = this.singlefile.lib.modules.fonts
 		"extra-expanded": "150%",
 		"ultra-expanded": "200%"
 	};
-	const FONT_MAX_LOAD_DELAY = 15000;
+	const FONT_MAX_LOAD_DELAY = 5000;
 
 	return {
 		process: async (doc, stylesheets, fontURLs) => {
@@ -222,7 +222,10 @@ this.singlefile.lib.modules.fontsAltMinifier = this.singlefile.lib.modules.fonts
 					try {
 						await Promise.race(
 							[fontFace.load().then(() => fontFace.loaded).then(() => source.valid = true),
-							new Promise(resolve => setTimeout(resolve, FONT_MAX_LOAD_DELAY))]);
+							new Promise(resolve => setTimeout(() => {
+								source.valid = true;
+								resolve();
+							}, FONT_MAX_LOAD_DELAY))]);
 					} catch (error) {
 						// ignored
 					}