Remove unnecessary TypedArray re-initialization in FontFaceObject.createFontFaceRule

The `this.data` property is, when defined, sent from the worker-thread as a `Uint8Array` and there's thus no reason to re-initialize the TypedArray here.
Note also the `FontFaceObject.createNativeFontFace` method just above, where we simply use `this.data` as-is.

The explanation for this code looking like it does is, as is often the case, for historical reasons. Originally we only supported `@font-face`, before the Font Loading API existed, and back then we also polyfilled TypedArrays (using regular Arrays) which should explain this particular line of code.
This commit is contained in:
Jonas Jenwald 2021-05-01 12:17:46 +02:00
parent 3624f9eac7
commit 90b5fcb8e0

View File

@ -397,7 +397,7 @@ class FontFaceObject {
if (!this.data || this.disableFontFace) {
return null;
}
const data = bytesToString(new Uint8Array(this.data));
const data = bytesToString(this.data);
// Add the @font-face rule to the document.
const url = `url(data:${this.mimetype};base64,${btoa(data)});`;
let rule;