Apply Patterns, if necessary, when rendering text

Currently we're not applying Patterns for text, but only for graphics.

This patch is unfortunately not a complete solution, but rather a step on the way, since there are still some PDF files where the Patterns look more like a solid colour, rather than the intended gradient.
I've been unable to fix these issues completely, and I've not managed to determine if the remaining issues are caused either by the pattern code, the canvas code, or perhaps both.

However, given that even this simple patch improves the current situation quite a bit, I figured that it couldn't hurt to submit it as-is.

 - Fixes 5804.
 - Fixes 6130.
 - Improves 3988 a lot, since the text is now visible. However, it looks like the text is *one* solid colour, instead of the correct gradient.
 - Improves 5432, since the text is no longer gray. (This file also suffers from the same problem as the previous one.)
This commit is contained in:
Jonas Jenwald 2015-12-29 17:57:10 +01:00
parent b32cdf5836
commit 1d1f175826
5 changed files with 23 additions and 0 deletions

View File

@ -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 {

View File

@ -25,6 +25,8 @@
!bug1200096.pdf
!issue5564_reduced.pdf
!canvas.pdf
!issue5804.pdf
!ShowText-ShadingPattern.pdf
!complex_ttf_font.pdf
!extgstate.pdf
!rotation.pdf

Binary file not shown.

BIN
test/pdfs/issue5804.pdf Normal file

Binary file not shown.

View File

@ -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",