Ignore empty paths when optimizing constructPath operations (issue 19971)

Note how we're handling empty paths in [src/display/canvas.js](a8e05d82e2/src/display/canvas.js (L1423-L1428)), hence we need add similar code in the `QueueOptimizer` as well.
This commit is contained in:
Jonas Jenwald 2025-05-23 13:53:44 +02:00
parent a8e05d82e2
commit c5449a98e0
4 changed files with 23 additions and 12 deletions

View File

@ -519,18 +519,20 @@ addState(
const transform = argsArray[iFirstTransform];
const [, [buffer], minMax] = args;
Util.scaleMinMax(transform, minMax);
for (let k = 0, kk = buffer.length; k < kk; ) {
switch (buffer[k++]) {
case DrawOPS.moveTo:
case DrawOPS.lineTo:
Util.applyTransform(buffer, transform, k);
k += 2;
break;
case DrawOPS.curveTo:
Util.applyTransformToBezier(buffer, transform, k);
k += 6;
break;
if (minMax) {
Util.scaleMinMax(transform, minMax);
for (let k = 0, kk = buffer.length; k < kk; ) {
switch (buffer[k++]) {
case DrawOPS.moveTo:
case DrawOPS.lineTo:
Util.applyTransform(buffer, transform, k);
k += 2;
break;
case DrawOPS.curveTo:
Util.applyTransformToBezier(buffer, transform, k);
k += 6;
break;
}
}
}
// Replace queue items.

View File

@ -622,6 +622,7 @@
!bug1815476.pdf
!issue16021.pdf
!bug1770750.pdf
!issue19971.pdf
!issue16063.pdf
!issue19389.pdf
!issue16067.pdf

BIN
test/pdfs/issue19971.pdf Normal file

Binary file not shown.

View File

@ -4142,6 +4142,14 @@
"lastPage": 1,
"type": "eq"
},
{
"id": "issue19971",
"file": "pdfs/issue19971.pdf",
"md5": "2eb897b3ef3342bfc5ad31886e7cd1fe",
"rounds": 1,
"lastPage": 1,
"type": "eq"
},
{
"id": "issue8702-text",
"file": "pdfs/issue8702.pdf",