Merge pull request #15751 from Snuffleupagus/modernize-isSyncFontLoadingSupported
Slightly modernize the `FontLoader.isSyncFontLoadingSupported` getter
This commit is contained in:
commit
8bac57172a
@ -22,6 +22,7 @@ import {
|
|||||||
UNSUPPORTED_FEATURES,
|
UNSUPPORTED_FEATURES,
|
||||||
warn,
|
warn,
|
||||||
} from "../shared/util.js";
|
} from "../shared/util.js";
|
||||||
|
import { isNodeJS } from "../shared/is_node.js";
|
||||||
|
|
||||||
class FontLoader {
|
class FontLoader {
|
||||||
constructor({
|
constructor({
|
||||||
@ -141,17 +142,17 @@ class FontLoader {
|
|||||||
|
|
||||||
let supported = false;
|
let supported = false;
|
||||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("CHROME")) {
|
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("CHROME")) {
|
||||||
if (typeof navigator === "undefined") {
|
if (isNodeJS) {
|
||||||
// Node.js - we can pretend that sync font loading is supported.
|
// Node.js - we can pretend that sync font loading is supported.
|
||||||
supported = true;
|
supported = true;
|
||||||
} else {
|
} else if (
|
||||||
|
typeof navigator !== "undefined" &&
|
||||||
// User agent string sniffing is bad, but there is no reliable way to
|
// 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.
|
// tell if the font is fully loaded and ready to be used with canvas.
|
||||||
const m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
|
/Mozilla\/5.0.*?rv:\d+.*? Gecko/.test(navigator.userAgent)
|
||||||
if (m?.[1] >= 14) {
|
) {
|
||||||
supported = true;
|
// Firefox, from version 14, supports synchronous font loading.
|
||||||
}
|
supported = true;
|
||||||
// TODO - other browsers...
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return shadow(this, "isSyncFontLoadingSupported", supported);
|
return shadow(this, "isSyncFontLoadingSupported", supported);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user