Merge pull request #21483 from calixteman/issue21430

Reset alpha before drawing a colored glyph in type 3 font
This commit is contained in:
Tim van der Meij 2026-06-22 20:40:55 +02:00 committed by GitHub
commit 7ac6dff4b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 0 deletions

View File

@ -2965,6 +2965,14 @@ class CanvasGraphics {
warn(`Type3 character "${glyph.operatorListId}" is not available.`); warn(`Type3 character "${glyph.operatorListId}" is not available.`);
} else if (this.contentVisible) { } else if (this.contentVisible) {
this.save(); this.save();
// A d0 (setCharWidth) glyph is colored (see Table 113 in pdf 1.7 specs)
// unlike a d1 glyph painted as a stencil mask with the current fill
// color. The constant alphas (ca/CA) are the opacity of that current
// color, so they must not attenuate a d0 glyph.
if (operatorList.fnArray[0] === OPS.setCharWidth) {
current.fillAlpha = current.strokeAlpha = 1;
ctx.globalAlpha = 1;
}
ctx.scale(fontSize, fontSize); ctx.scale(fontSize, fontSize);
ctx.transform(...fontMatrix); ctx.transform(...fontMatrix);
this.executeOperatorList(operatorList); this.executeOperatorList(operatorList);

View File

@ -0,0 +1 @@
https://github.com/user-attachments/files/28821514/xxx.pdf

View File

@ -14429,5 +14429,15 @@
"type": "eq", "type": "eq",
"annotations": true, "annotations": true,
"forms": true "forms": true
},
{
"id": "issue21430",
"file": "pdfs/issue21430.pdf",
"md5": "e317f63bdfd6f3d1939a52c983379454",
"rounds": 1,
"link": true,
"firstPage": 1,
"lastPage": 1,
"type": "eq"
} }
] ]