[Pkg-javascript-commits] [pdf.js] 53/414: Apply Patterns, if necessary, when rendering text

David Prévot taffit at moszumanska.debian.org
Tue Jun 28 17:12:05 UTC 2016


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit 1d1f175826aae0e468d816944d1c44e06532e985
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Tue Dec 29 17:57:10 2015 +0100

    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.)
---
 src/display/canvas.js                 |   6 ++++++
 test/pdfs/.gitignore                  |   2 ++
 test/pdfs/ShowText-ShadingPattern.pdf | Bin 0 -> 4671 bytes
 test/pdfs/issue5804.pdf               | Bin 0 -> 8498 bytes
 test/test_manifest.json               |  15 +++++++++++++++
 5 files changed, 23 insertions(+)

diff --git a/src/display/canvas.js b/src/display/canvas.js
index 3cbf0c2..2e8c766 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 78943c4..e75151e 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 0000000..cc29f98
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 0000000..83d2dea
Binary files /dev/null and b/test/pdfs/issue5804.pdf differ
diff --git a/test/test_manifest.json b/test/test_manifest.json
index 244aeed..a0fdd64 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",

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list