Simplify the compileType3Glyph function to just return the Path2D objects
Originally this function would "manually" invoke the rendering commands for Type3-glyphs, however that was changed some time ago: - Initial `Path2D` support was added in PR 14858, but the old code kept for Node.js compatibility. - Since PR 15951 we've been using a `Path2D` polyfill in Node.js environments. Hence, after the previous commit, we can further simplify this function by *directly* returning/using the `Path2D` object when rendering Type3-glyphs; see also https://github.com/mozilla/pdf.js/pull/19731#discussion_r2018712695 While this won't improve performance significantly, when compared to the introduction of `Path2D`, it definately cannot hurt.
This commit is contained in:
parent
852b7e407a
commit
f577271908
@ -308,13 +308,13 @@ function compileType3Glyph(imgData) {
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
const width1 = width + 1;
|
const width1 = width + 1;
|
||||||
let points = new Uint8Array(width1 * (height + 1));
|
const 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;
|
||||||
let data = new Uint8Array(lineSize * height),
|
const data = new Uint8Array(lineSize * height);
|
||||||
pos = 0;
|
let 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) {
|
||||||
@ -456,18 +456,7 @@ function compileType3Glyph(imgData) {
|
|||||||
--i;
|
--i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Immediately release the, potentially large, `Uint8Array`s after parsing.
|
return path;
|
||||||
data = null;
|
|
||||||
points = null;
|
|
||||||
|
|
||||||
const drawOutline = function (ctx) {
|
|
||||||
ctx.save();
|
|
||||||
ctx.fill(path);
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.restore();
|
|
||||||
};
|
|
||||||
|
|
||||||
return drawOutline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CanvasExtraState {
|
class CanvasExtraState {
|
||||||
@ -2726,7 +2715,7 @@ class CanvasGraphics {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (glyph.compiled) {
|
if (glyph.compiled) {
|
||||||
glyph.compiled(ctx);
|
ctx.fill(glyph.compiled);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
1
test/pdfs/bug810214.pdf.link
Normal file
1
test/pdfs/bug810214.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://bugzilla.mozilla.org/attachment.cgi?id=9254990
|
||||||
@ -2834,6 +2834,15 @@
|
|||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "bug810214",
|
||||||
|
"file": "pdfs/bug810214.pdf",
|
||||||
|
"md5": "2b7243178f5dd5fd3edc7b6649e4bdf3",
|
||||||
|
"link": true,
|
||||||
|
"rounds": 1,
|
||||||
|
"lastPage": 1,
|
||||||
|
"type": "eq"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "issue13372",
|
"id": "issue13372",
|
||||||
"file": "pdfs/issue13372.pdf",
|
"file": "pdfs/issue13372.pdf",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user