]> git.parisson.com Git - pdf.js.git/commitdiff
Fix a > 32000 conversion error in type1 to type2 charstring
authorVivien Nicolas <21@vingtetun.org>
Thu, 21 Jul 2011 09:01:38 +0000 (11:01 +0200)
committerVivien Nicolas <21@vingtetun.org>
Thu, 21 Jul 2011 09:01:38 +0000 (11:01 +0200)
fonts.js

index 8770c8d06e5eb3b6fe691f3a2bf0129b1e08f7ff..5a64a645ac7f41f24853fa4ab03ee993917c047a 100755 (executable)
--- a/fonts.js
+++ b/fonts.js
@@ -1786,8 +1786,10 @@ CFF.prototype = {
              String.fromCharCode((value >> 8) & 0xFF) +
              String.fromCharCode(value & 0xFF);
     } else if (value >= (-2147483648) && value <= 2147483647) {
+      value ^= 0xffffffff;
+      value += 1;
       return '\xff' +
-             String.fromCharCode((value >>> 24) & 0xFF) +
+             String.fromCharCode((value >> 24) & 0xFF) +
              String.fromCharCode((value >> 16) & 0xFF) +
              String.fromCharCode((value >> 8) & 0xFF) +
              String.fromCharCode(value & 0xFF);
@@ -1893,7 +1895,14 @@ CFF.prototype = {
           charstring[i] = cmd;
         }
       } else {
-        charstring.splice(i, 1, 28, command >> 8, command & 0xff);
+        // Type1 charstring use a division for number above 32000
+        if (command > 32000) {
+          var divisor = charstring[i + 1];
+          command /= divisor;
+          charstring.splice(i, 3, 28, command >> 8, command & 0xff);
+        } else {
+          charstring.splice(i, 1, 28, command >> 8, command & 0xff);
+        }
         i += 2;
       }
     }