Merge pull request #14866 from Snuffleupagus/Type3-release-Uint8Arrays

Immediately release the temporary `Uint8Array`s used during Type3-compilation
This commit is contained in:
Jonas Jenwald 2022-05-02 15:09:59 +02:00 committed by GitHub
commit da4f7dfcd0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -465,14 +465,14 @@ function compileType3Glyph(imgData) {
0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0, 0, 2, 4, 0, 1, 0, 5, 4, 8, 10, 0, 8, 0, 2, 1, 0,
]); ]);
const width1 = width + 1, const width1 = width + 1;
points = new Uint8Array(width1 * (height + 1)); let points = new Uint8Array(width1 * (height + 1));
let i, j, j0; let i, j, j0;
// decodes bit-packed mask data // decodes bit-packed mask data
const lineSize = (width + 7) & ~7, const lineSize = (width + 7) & ~7;
data = new Uint8Array(lineSize * height); let data = new Uint8Array(lineSize * height),
let pos = 0; pos = 0;
for (const elem of imgData.data) { for (const elem of imgData.data) {
let mask = 128; let mask = 128;
while (mask > 0) { while (mask > 0) {
@ -624,6 +624,10 @@ function compileType3Glyph(imgData) {
--i; --i;
} }
// Immediately release the, potentially large, `Uint8Array`s after parsing.
data = null;
points = null;
const drawOutline = function (c) { const drawOutline = function (c) {
c.save(); c.save();
// the path shall be painted in [0..1]x[0..1] space // the path shall be painted in [0..1]x[0..1] space