mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Use the FeatureTest
helper in the src/display/font_loader.js
file
This commit is contained in:
parent
41a918b0fe
commit
33f3506842
1 changed files with 9 additions and 17 deletions
|
@ -15,6 +15,7 @@
|
|||
|
||||
import {
|
||||
assert,
|
||||
FeatureTest,
|
||||
isNodeJS,
|
||||
shadow,
|
||||
string32,
|
||||
|
@ -176,23 +177,14 @@ class FontLoader {
|
|||
return shadow(this, "isSyncFontLoadingSupported", true);
|
||||
}
|
||||
|
||||
let supported = false;
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("CHROME")) {
|
||||
if (isNodeJS) {
|
||||
// Node.js - we can pretend that sync font loading is supported.
|
||||
supported = true;
|
||||
} else if (
|
||||
typeof navigator !== "undefined" &&
|
||||
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);
|
||||
// Node.js - we can pretend that sync font loading is supported.
|
||||
// Firefox, from version 14, supports synchronous font loading.
|
||||
return shadow(
|
||||
this,
|
||||
"isSyncFontLoadingSupported",
|
||||
(typeof PDFJSDev === "undefined" || !PDFJSDev.test("CHROME")) &&
|
||||
(isNodeJS || FeatureTest.platform.isFirefox)
|
||||
);
|
||||
}
|
||||
|
||||
_queueLoadingCallback(callback) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue