From bfc645bab17c0544aee1466513200dfd396f2579 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 10 Apr 2024 12:45:22 +0200 Subject: [PATCH] Introduce some `Uint8Array.fromBase64` and `Uint8Array.prototype.toBase64` usage in the main code-base See https://github.com/tc39/proposal-arraybuffer-base64 --- src/core/xfa/template.js | 4 ++-- src/display/font_loader.js | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/core/xfa/template.js b/src/core/xfa/template.js index 8ec158ff888fe..454ceb5f0fca2 100644 --- a/src/core/xfa/template.js +++ b/src/core/xfa/template.js @@ -102,7 +102,7 @@ import { getStringOption, HTMLResult, } from "./utils.js"; -import { stringToBytes, Util, warn } from "../../shared/util.js"; +import { Util, warn } from "../../shared/util.js"; import { getMetrics } from "./fonts.js"; import { recoverJsURL } from "../core_utils.js"; import { searchNode } from "./som.js"; @@ -3427,7 +3427,7 @@ class Image extends StringObject { } if (!buffer && this.transferEncoding === "base64") { - buffer = stringToBytes(atob(this[$content])); + buffer = Uint8Array.fromBase64(this[$content]); } if (!buffer) { diff --git a/src/display/font_loader.js b/src/display/font_loader.js index 1014c536b67e0..4115a71eb5d79 100644 --- a/src/display/font_loader.js +++ b/src/display/font_loader.js @@ -15,7 +15,6 @@ import { assert, - bytesToString, FontRenderOps, isNodeJS, shadow, @@ -399,9 +398,8 @@ class FontFaceObject { if (!this.data || this.disableFontFace) { return null; } - const data = bytesToString(this.data); // Add the @font-face rule to the document. - const url = `url(data:${this.mimetype};base64,${btoa(data)});`; + const url = `url(data:${this.mimetype};base64,${this.data.toBase64()});`; let rule; if (!this.cssFontInfo) { rule = `@font-face {font-family:"${this.loadedName}";src:${url}}`;