mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Convert BaseFontLoader.bind
to be async, and only utilize BaseFontLoader._queueLoadingCallback
when actually necessary
Currently all fonts are using the `_queueLoadingCallback` method to determine when they have been loaded[1]. However in most cases this is just adding unnecessary overhead, especially with `BaseFontLoader.bind` now being asynchronous, given how fonts are loaded: - For fonts loaded using the Font Loading API, it's already possible to easily tell when a font has been loaded simply by checking the `loaded` promise on the FontFace object itself. - For browsers, e.g. Firefox, which support synchronous font loading it's already assumed that fonts are immediately available. Hence the `_queueLoadingCallback` method is moved into the `GenericFontLoader`, such that it's only utilized for fonts which are loaded using CSS. --- [1] In the "fonts loaded using CSS" case, this is already a hack anyway as outlined in the comments.
This commit is contained in:
parent
dfe7d9bc26
commit
af3fcca88d
2 changed files with 38 additions and 34 deletions
|
@ -1944,11 +1944,10 @@ class WorkerTransport {
|
|||
onUnsupportedFeature: this._onUnsupportedFeature.bind(this),
|
||||
fontRegistry,
|
||||
});
|
||||
const fontReady = (fontObjs) => {
|
||||
this.commonObjs.resolve(id, font);
|
||||
};
|
||||
|
||||
this.fontLoader.bind([font], fontReady);
|
||||
this.fontLoader.bind([font]).then(() => {
|
||||
this.commonObjs.resolve(id, font);
|
||||
});
|
||||
break;
|
||||
case 'FontPath':
|
||||
this.commonObjs.resolve(id, exportedData);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue