Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip bogus d1 operators in Type3-glyphs (issue 14953) #14955

Merged
merged 1 commit into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4463,21 +4463,30 @@ class TranslatedFont {
"Type3 glyph shall start with the d1 operator."
);
}
if (isEmptyBBox) {
const charBBox = Util.normalizeRect(operatorList.argsArray[0].slice(2)),
width = charBBox[2] - charBBox[0],
height = charBBox[3] - charBBox[1];

if (width === 0 || height === 0) {
// Skip the d1 operator when its bounds are bogus (fixes issue14953.pdf).
operatorList.fnArray.splice(0, 1);
operatorList.argsArray.splice(0, 1);
} else if (isEmptyBBox) {
if (!this._bbox) {
this._bbox = [Infinity, Infinity, -Infinity, -Infinity];
}
const charBBox = Util.normalizeRect(operatorList.argsArray[0].slice(2));

this._bbox[0] = Math.min(this._bbox[0], charBBox[0]);
this._bbox[1] = Math.min(this._bbox[1], charBBox[1]);
this._bbox[2] = Math.max(this._bbox[2], charBBox[2]);
this._bbox[3] = Math.max(this._bbox[3], charBBox[3]);
}
let i = 1,

let i = 0,
ii = operatorList.length;
while (i < ii) {
switch (operatorList.fnArray[i]) {
case OPS.setCharWidthAndBounds:
break; // Handled above.
case OPS.setStrokeColorSpace:
case OPS.setFillColorSpace:
case OPS.setStrokeColor:
Expand Down
2 changes: 0 additions & 2 deletions src/display/canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -2652,8 +2652,6 @@ class CanvasGraphics {
}

setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
// TODO According to the spec we're also suppose to ignore any operators
// that set color or include images while processing this type3 font.
this.ctx.rect(llx, lly, urx - llx, ury - lly);
this.ctx.clip();
this.endPath();
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
!issue7426.pdf
!issue7439.pdf
!issue7847_radial.pdf
!issue14953.pdf
!issue7446.pdf
!issue7492.pdf
!issue7544.pdf
Expand Down
Binary file added test/pdfs/issue14953.pdf
Binary file not shown.
6 changes: 6 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2058,6 +2058,12 @@
"rounds": 1,
"type": "eq"
},
{ "id": "issue14953",
"file": "pdfs/issue14953.pdf",
"md5": "dd7d6cb92e58d75a0eb8c0476a3bc64a",
"rounds": 1,
"type": "eq"
},
{ "id": "extgstate-text",
"file": "pdfs/extgstate.pdf",
"md5": "001bb4ec04463a01d93aad748361f049",
Expand Down