]> git.parisson.com Git - pdf.js.git/commitdiff
Prevent missing charcode to block the rendering
authorVivien Nicolas <21@vingtetun.org>
Fri, 9 Sep 2011 11:32:54 +0000 (13:32 +0200)
committerVivien Nicolas <21@vingtetun.org>
Fri, 9 Sep 2011 11:32:54 +0000 (13:32 +0200)
fonts.js

index 3dc33db81a71567a5d75c6cf47da30ca0a4b7c7c..7d0062b6c7d834ba8ffc448496fdad11fe64e1ee 100755 (executable)
--- a/fonts.js
+++ b/fonts.js
@@ -1374,17 +1374,25 @@ var Font = (function Font() {
                                        // loop should never end on the last byte
         for (var i = 0; i < length; i++) {
           var charcode = int16([chars.charCodeAt(i++), chars.charCodeAt(i)]);
-          var unicode = encoding[charcode].unicode;
+          var unicode = encoding[charcode];
+          if ('undefined' == typeof(unicode)) {
+            warn('Unencoded charcode ' + charcode);
+            unicode = charcode;
+          } else {
+            unicode = unicode.unicode;
+          }
           str += String.fromCharCode(unicode);
         }
       }
       else {
         for (var i = 0; i < chars.length; ++i) {
           var charcode = chars.charCodeAt(i);
-          var unicode = encoding[charcode].unicode;
+          var unicode = encoding[charcode];
           if ('undefined' == typeof(unicode)) {
             warn('Unencoded charcode ' + charcode);
             unicode = charcode;
+          } else {
+            unicode = unicode.unicode;
           }
 
           // Handle surrogate pairs