[Pkg-javascript-commits] [pdf.js] 260/414: Fix for descent calculation while reading font hhea headers

David Prévot taffit at moszumanska.debian.org
Tue Jun 28 17:12:28 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 be1e12dbcb2cdb91f01090e35e050dc316300038
Author: Preetham Mysore <a0preetham at gmail.com>
Date:   Wed Mar 2 21:10:15 2016 -0500

    Fix for descent calculation while reading font hhea headers
---
 src/core/fonts.js          |   9 +++++++--
 test/pdfs/.gitignore       |   1 +
 test/pdfs/zero_descent.pdf | Bin 0 -> 66554 bytes
 test/test_manifest.json    |   8 ++++++++
 4 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/core/fonts.js b/src/core/fonts.js
index 3504ce5..78ff4b1 100644
--- a/src/core/fonts.js
+++ b/src/core/fonts.js
@@ -722,6 +722,11 @@ var Font = (function FontClosure() {
   function int16(b0, b1) {
     return (b0 << 8) + b1;
   }
+ 
+  function signedInt16(b0, b1) {
+    var value = (b0 << 8) + b1;
+    return value & (1 << 15) ? value - 0x10000 : value;
+  }
 
   function int32(b0, b1, b2, b3) {
     return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
@@ -2240,9 +2245,9 @@ var Font = (function FontClosure() {
       var metricsOverride = {
         unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
         yMax: int16(tables['head'].data[42], tables['head'].data[43]),
-        yMin: int16(tables['head'].data[38], tables['head'].data[39]) - 0x10000,
+        yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
         ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
-        descent: int16(tables['hhea'].data[6], tables['hhea'].data[7]) - 0x10000
+        descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
       };
 
       // PDF FontDescriptor metrics lie -- using data from actual font.
diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index ae3506f..5fad85a 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -222,3 +222,4 @@
 !annotation-squiggly.pdf
 !annotation-highlight.pdf
 !annotation-fileattachment.pdf
+!zero_descent.pdf
diff --git a/test/pdfs/zero_descent.pdf b/test/pdfs/zero_descent.pdf
new file mode 100644
index 0000000..df78e65
Binary files /dev/null and b/test/pdfs/zero_descent.pdf differ
diff --git a/test/test_manifest.json b/test/test_manifest.json
index 8d57d7e..51f03f3 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -2823,5 +2823,13 @@
        "rounds": 1,
        "lastPage": 1,
        "type": "load"
+    },
+    {  "id": "zero_descent",
+       "file": "pdfs/zero_descent.pdf",
+       "md5": "32805ab28be1d0e91d27d9742c66eccf",
+       "link": false,
+       "rounds": 1,
+       "lastPage": 1,
+       "type": "text"
     }
 ]

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