|
|
@@ -25,6 +25,7 @@ this.SingleFile = this.SingleFile || (() => {
|
|
|
const ONE_MB = 1024 * 1024;
|
|
|
const DEBUG = false;
|
|
|
const PREFIX_CONTENT_TYPE_TEXT = "text/";
|
|
|
+ const FONT_FACE_TEST_MAX_DELAY = 1000;
|
|
|
|
|
|
// --------
|
|
|
// Download
|
|
|
@@ -168,8 +169,6 @@ this.SingleFile = this.SingleFile || (() => {
|
|
|
return hexCodes.join("");
|
|
|
}
|
|
|
|
|
|
- let fontIndex = 0;
|
|
|
-
|
|
|
// ---
|
|
|
// DOM
|
|
|
// ---
|
|
|
@@ -212,11 +211,10 @@ this.SingleFile = this.SingleFile || (() => {
|
|
|
return new Blob([content]).size;
|
|
|
}
|
|
|
|
|
|
- static async validFont(url) {
|
|
|
+ static async validFont(urlFunction) {
|
|
|
try {
|
|
|
- const font = new FontFace("font-test-" + fontIndex, "url(\"" + url + "\")");
|
|
|
- fontIndex++;
|
|
|
- await font.load();
|
|
|
+ const font = new FontFace("font-test", urlFunction);
|
|
|
+ await Promise.race([font.load(), new Promise(resolve => setTimeout(() => resolve(true), FONT_FACE_TEST_MAX_DELAY))]);
|
|
|
return true;
|
|
|
} catch (error) {
|
|
|
return false;
|