[Pkg-javascript-commits] [pdf.js] 18/106: Apply char spacing only when there are chars.

David Prévot taffit at moszumanska.debian.org
Sat Jun 20 21:33:45 UTC 2015


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

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

commit c2013094e7b1dfd1cbeb18b487545e59255c506f
Author: Fabian Lange <lange.fabian at gmail.com>
Date:   Sun May 10 11:28:15 2015 +0200

    Apply char spacing only when there are chars.
---
 src/core/evaluator.js   | 11 +++++--
 test/pdfs/.gitignore    |  1 +
 test/pdfs/issue5972.pdf | 76 +++++++++++++++++++++++++++++++++++++++++++++++++
 test/test_manifest.json |  7 +++++
 4 files changed, 93 insertions(+), 2 deletions(-)

diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index 97958fa..45c6507 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -1009,16 +1009,23 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
           // var x = pt[0];
           // var y = pt[1];
 
+          var charSpacing = 0;
+          if (textChunk.str.length > 0) {
+            // Apply char spacing only when there are chars.
+            // As a result there is only spacing between glyphs.
+            charSpacing = textState.charSpacing;
+          }
+
           var tx = 0;
           var ty = 0;
           if (!font.vertical) {
             var w0 = glyphWidth * textState.fontMatrix[0];
-            tx = (w0 * textState.fontSize + textState.charSpacing) *
+            tx = (w0 * textState.fontSize + charSpacing) *
                  textState.textHScale;
             width += tx;
           } else {
             var w1 = glyphWidth * textState.fontMatrix[0];
-            ty = w1 * textState.fontSize + textState.charSpacing;
+            ty = w1 * textState.fontSize + charSpacing;
             height += ty;
           }
           textState.translateTextMatrix(tx, ty);
diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index 47285d1..eb1127a 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -6,6 +6,7 @@
 !issue2391-1.pdf
 !issue2391-2.pdf
 !issue5801.pdf
+!issue5972.pdf
 !filled-background.pdf
 !ArabicCIDTrueType.pdf
 !ThuluthFeatures.pdf
diff --git a/test/pdfs/issue5972.pdf b/test/pdfs/issue5972.pdf
new file mode 100644
index 0000000..cc00e11
--- /dev/null
+++ b/test/pdfs/issue5972.pdf
@@ -0,0 +1,76 @@
+%PDF-1.7
+%����
+1 0 obj 
+<<
+/Type /Encoding
+/BaseEncoding /WinAnsiEncoding
+>>
+endobj 
+2 0 obj 
+<<
+/Pages 3 0 R
+/Type /Catalog
+>>
+endobj 
+3 0 obj 
+<<
+/MediaBox [0 0 200 50]
+/Kids [4 0 R]
+/Count 1
+/Type /Pages
+>>
+endobj 
+4 0 obj 
+<<
+/Parent 3 0 R
+/MediaBox [0 0 200 50]
+/Resources 
+<<
+/Font 
+<<
+/F1 5 0 R
+>>
+>>
+/Contents 6 0 R
+/Type /Page
+>>
+endobj 
+5 0 obj 
+<<
+/BaseFont /Times-Italic
+/Subtype /Type1
+/Encoding 1 0 R
+/Type /Font
+>>
+endobj 
+6 0 obj 
+<<
+/Length 73
+>>
+stream
+BT
+10 15 TD
+/F1 40 Tf
+-8 Tc
+[ (f) 20 (ore) 15 (w) 20 (or) 20 (d) ] TJ
+ET
+
+endstream 
+endobj xref
+0 7
+0000000000 65535 f 
+0000000015 00000 n 
+0000000085 00000 n 
+0000000136 00000 n 
+0000000218 00000 n 
+0000000347 00000 n 
+0000000438 00000 n 
+trailer
+
+<<
+/Root 2 0 R
+/Size 7
+>>
+startxref
+563
+%%EOF
diff --git a/test/test_manifest.json b/test/test_manifest.json
index 2652595..9248f8d 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -1095,6 +1095,13 @@
        "link": false,
        "type": "eq"
     },
+    {  "id": "issue5972",
+       "file": "pdfs/issue5972.pdf",
+       "md5": "51f03e1d38410b04c9dda7e75fe8a0a3",
+       "rounds": 1,
+       "link": false,
+       "type": "text"
+    },
     {  "id": "pdfkit_compressed",
       "file": "pdfs/pdfkit_compressed.pdf",
       "md5": "ffe9c571d0a1572e234253e6c7cdee6c",

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