Skip to content

Commit

Permalink
Introduce some Uint8Array.fromBase64 and `Uint8Array.prototype.toBa…
Browse files Browse the repository at this point in the history
…se64` usage in the main code-base

See https://github.com/tc39/proposal-arraybuffer-base64
  • Loading branch information
Snuffleupagus committed May 5, 2024
1 parent e68155a commit 112fa73
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/core/xfa/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 1 addition & 3 deletions src/display/font_loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import {
assert,
bytesToString,
FontRenderOps,
isNodeJS,
shadow,
Expand Down Expand Up @@ -403,9 +402,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}}`;
Expand Down

0 comments on commit 112fa73

Please sign in to comment.