[Pkg-javascript-commits] [pdf.js] 132/210: Build paths for glyph accents when drawing text as curves

David Prévot taffit at moszumanska.debian.org
Thu Jun 5 14:21:10 UTC 2014


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

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

commit b907e15a904de6989ab528bea9fb4a310f18a3a4
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Sat May 3 17:28:30 2014 +0200

    Build paths for glyph accents when drawing text as curves
---
 src/core/evaluator.js      |  21 ++++++++++++++++-----
 src/display/canvas.js      |   2 +-
 test/pdfs/.gitignore       |   1 +
 test/pdfs/glyph_accent.pdf | Bin 0 -> 5490 bytes
 test/test_manifest.json    |   8 ++++++++
 5 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index 5f9c303..70fcc6a 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -290,11 +290,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
       var isAddToPathSet = !!(state.textRenderingMode &
                               TextRenderingMode.ADD_TO_PATH_FLAG);
       if (font.data && (isAddToPathSet || PDFJS.disableFontFace)) {
-        for (var i = 0; i < glyphs.length; i++) {
-          if (glyphs[i] === null) {
-            continue;
-          }
-          var fontChar = glyphs[i].fontChar;
+        var buildPath = function (fontChar) {
           if (!font.renderer.hasBuiltPath(fontChar)) {
             var path = font.renderer.getPathJs(fontChar);
             this.handler.send('commonobj', [
@@ -303,6 +299,21 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
               path
             ]);
           }
+        }.bind(this);
+
+        for (var i = 0, ii = glyphs.length; i < ii; i++) {
+          var glyph = glyphs[i];
+          if (glyph === null) {
+            continue;
+          }
+          buildPath(glyph.fontChar);
+
+          // If the glyph has an accent we need to build a path for its
+          // fontChar too, otherwise CanvasGraphics_paintChar will fail.
+          var accent = glyph.accent;
+          if (accent && accent.fontChar) {
+            buildPath(accent.fontChar);
+          }
         }
       }
 
diff --git a/src/display/canvas.js b/src/display/canvas.js
index cb56803..646f8a3 100644
--- a/src/display/canvas.js
+++ b/src/display/canvas.js
@@ -1253,7 +1253,7 @@ var CanvasGraphics = (function CanvasGraphicsClosure() {
       }
     },
 
-    paintChar: function (character, x, y) {
+    paintChar: function CanvasGraphics_paintChar(character, x, y) {
       var ctx = this.ctx;
       var current = this.current;
       var font = current.font;
diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index 353e939..efd1825 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -43,6 +43,7 @@
 !type4psfunc.pdf
 !issue1350.pdf
 !S2.pdf
+!glyph_accent.pdf
 !personwithdog.pdf
 !helloworld-bad.pdf
 !zerowidthline.pdf
diff --git a/test/pdfs/glyph_accent.pdf b/test/pdfs/glyph_accent.pdf
new file mode 100644
index 0000000..23aa1d7
Binary files /dev/null and b/test/pdfs/glyph_accent.pdf differ
diff --git a/test/test_manifest.json b/test/test_manifest.json
index eefa9ec..0db9c34 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -520,6 +520,14 @@
        "rounds": 1,
        "type": "eq"
     },
+    {  "id": "glyph_accent",
+       "file": "pdfs/glyph_accent.pdf",
+       "md5": "1526e4edaa3ec439ebf156d0a0b385aa",
+       "link": false,
+       "rounds": 1,
+       "type": "eq",
+       "about": "Glyph accent drawn as curves."
+    },
     {  "id": "simpletype3font",
        "file": "pdfs/simpletype3font.pdf",
        "md5": "b374c7543920840c61999e9e86939f99",

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