Skip to content

Commit

Permalink
Merge pull request #14866 from Snuffleupagus/Type3-release-Uint8Arrays
Browse files Browse the repository at this point in the history
Immediately release the temporary `Uint8Array`s used during Type3-compilation
  • Loading branch information
Snuffleupagus authored May 2, 2022
2 parents db12492 + 67719af commit da4f7df
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/display/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -465,14 +465,14 @@ function compileType3Glyph(imgData) {
0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0,
]);

const width1 = width + 1,
points = new Uint8Array(width1 * (height + 1));
const width1 = width + 1;
let points = new Uint8Array(width1 * (height + 1));
let i, j, j0;

// decodes bit-packed mask data
const lineSize = (width + 7) & ~7,
data = new Uint8Array(lineSize * height);
let pos = 0;
const lineSize = (width + 7) & ~7;
let data = new Uint8Array(lineSize * height),
pos = 0;
for (const elem of imgData.data) {
let mask = 128;
while (mask > 0) {
Expand Down Expand Up @@ -624,6 +624,10 @@ function compileType3Glyph(imgData) {
--i;
}

// Immediately release the, potentially large, `Uint8Array`s after parsing.
data = null;
points = null;

const drawOutline = function (c) {
c.save();
// the path shall be painted in [0..1]x[0..1] space
Expand Down

0 comments on commit da4f7df

Please sign in to comment.