diff --git a/src/display/canvas.js b/src/display/canvas.js index 3cbf0c2c7..2e8c76607 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -1421,6 +1421,12 @@ var CanvasGraphics = (function CanvasGraphicsClosure() { ctx.transform.apply(ctx, current.textMatrix); ctx.translate(current.x, current.y + current.textRise); + if (current.patternFill) { + // TODO: Some shading patterns are not applied correctly to text, + // e.g. issues 3988 and 5432, and ShowText-ShadingPattern.pdf. + ctx.fillStyle = current.fillColor.getPattern(ctx, this); + } + if (fontDirection > 0) { ctx.scale(textHScale, -1); } else { diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 78943c4ae..e75151e55 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -25,6 +25,8 @@ !bug1200096.pdf !issue5564_reduced.pdf !canvas.pdf +!issue5804.pdf +!ShowText-ShadingPattern.pdf !complex_ttf_font.pdf !extgstate.pdf !rotation.pdf diff --git a/test/pdfs/ShowText-ShadingPattern.pdf b/test/pdfs/ShowText-ShadingPattern.pdf new file mode 100644 index 000000000..cc29f982e Binary files /dev/null and b/test/pdfs/ShowText-ShadingPattern.pdf differ diff --git a/test/pdfs/issue5804.pdf b/test/pdfs/issue5804.pdf new file mode 100644 index 000000000..83d2dea77 Binary files /dev/null and b/test/pdfs/issue5804.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 244aeedfd..a0fdd640e 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -1001,6 +1001,21 @@ "link": false, "type": "eq" }, + { "id": "issue5804", + "file": "pdfs/issue5804.pdf", + "md5": "442f27939edb6aaf173ceff38d69bb14", + "rounds": 1, + "link": false, + "type": "eq" + }, + { "id": "ShowText-ShadingPattern", + "file": "pdfs/ShowText-ShadingPattern.pdf", + "md5": "fe683725db037ffe19d390969610a652", + "rounds": 1, + "link": false, + "type": "eq", + "about": "Please note that this file currently renders incorrectly." + }, { "id": "issue5644", "file": "pdfs/issue5644.pdf", "md5": "6f9313c5043b3ecb0ab2df321d3e1847",