Use the FeatureTest helper in the src/display/font_loader.js file
This commit is contained in:
parent
41a918b0fe
commit
33f3506842
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
assert,
|
assert,
|
||||||
|
FeatureTest,
|
||||||
isNodeJS,
|
isNodeJS,
|
||||||
shadow,
|
shadow,
|
||||||
string32,
|
string32,
|
||||||
@ -176,23 +177,14 @@ class FontLoader {
|
|||||||
return shadow(this, "isSyncFontLoadingSupported", true);
|
return shadow(this, "isSyncFontLoadingSupported", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
let supported = false;
|
// Node.js - we can pretend that sync font loading is supported.
|
||||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("CHROME")) {
|
// Firefox, from version 14, supports synchronous font loading.
|
||||||
if (isNodeJS) {
|
return shadow(
|
||||||
// Node.js - we can pretend that sync font loading is supported.
|
this,
|
||||||
supported = true;
|
"isSyncFontLoadingSupported",
|
||||||
} else if (
|
(typeof PDFJSDev === "undefined" || !PDFJSDev.test("CHROME")) &&
|
||||||
typeof navigator !== "undefined" &&
|
(isNodeJS || FeatureTest.platform.isFirefox)
|
||||||
typeof navigator?.userAgent === "string" &&
|
);
|
||||||
// User agent string sniffing is bad, but there is no reliable way to
|
|
||||||
// tell if the font is fully loaded and ready to be used with canvas.
|
|
||||||
/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent)
|
|
||||||
) {
|
|
||||||
// Firefox, from version 14, supports synchronous font loading.
|
|
||||||
supported = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return shadow(this, "isSyncFontLoadingSupported", supported);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_queueLoadingCallback(callback) {
|
_queueLoadingCallback(callback) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user