[Pkg-javascript-commits] [pdf.js] 284/414: Ensure that TrueType font tables have `uint32` checksums

David Prévot taffit at moszumanska.debian.org
Tue Jun 28 17:12:31 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 d78fae01812193aa80237fc2422345391da7337d
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Tue Mar 22 13:16:08 2016 +0100

    Ensure that TrueType font tables have `uint32` checksums
    
    According to "The table directory" under https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6.html#Directory, TrueType font tables should have `uint32` checksums.
    
    This is something that I noticed, and was initially confused about, while debugging a TrueType issue.
    As far as I can tell, the current (`int32`) checksums we use doesn't cause any issues in practice. However, I do think that this should be addressed to agree with the specification, and to reduce possible confusion when reading the font code.
---
 src/core/fonts.js | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/core/fonts.js b/src/core/fonts.js
index eb122c7..4e2d88c 100644
--- a/src/core/fonts.js
+++ b/src/core/fonts.js
@@ -403,9 +403,8 @@ var OpenTypeFileBuilder = (function OpenTypeFileBuilderClosure() {
         // checksum
         var checksum = 0;
         for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
-          var quad = (file[j] << 24) + (file[j + 1] << 16) +
-                     (file[j + 2] << 8) + file[j + 3];
-          checksum = (checksum + quad) | 0;
+          var quad = readUint32(file, j);
+          checksum = (checksum + quad) >>> 0;
         }
         writeInt32(file, offset + 4, checksum);
 
@@ -1246,7 +1245,7 @@ var Font = (function FontClosure() {
       function readTableEntry(file) {
         var tag = bytesToString(file.getBytes(4));
 
-        var checksum = file.getInt32();
+        var checksum = file.getInt32() >>> 0;
         var offset = file.getInt32() >>> 0;
         var length = file.getInt32() >>> 0;
 

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