]> git.parisson.com Git - pdf.js.git/commitdiff
Remove bad chars instead of replaces all.
authorBrendan Dahl <brendan.dahl@gmail.com>
Mon, 20 Feb 2012 23:49:45 +0000 (15:49 -0800)
committerBrendan Dahl <brendan.dahl@gmail.com>
Mon, 20 Feb 2012 23:49:45 +0000 (15:49 -0800)
src/fonts.js

index 7b09aa8ca4e35a18ed7f5ee87cb8efe275340a18..2884dcb2ea7da3a968a4dcef4b980482ac2c0f85 100644 (file)
@@ -3699,10 +3699,30 @@ var Type2CFF = (function Type2CFFClosure() {
         var length = data.length;
         if (length > 127)
           warn('Font had name longer than 127 chars, will be rejected.');
-        // Only certain chars are permitted in the font name.  Set them all to
-        // 'A' to avoid being rejected.
-        for (var j = 0; j < length; ++j)
-          data[j] = 65;
+        // Only certain chars are permitted in the font name.
+        for (var j = 0; j < length; ++j) {
+          var c = data[j];
+          if (j === 0 && c === 0)
+            continue;
+          if (c < 33 || c > 126) {
+            data[j] = 95;
+            continue;
+          }
+          switch (c) {
+            case 91:  // [
+            case 93:  // ]
+            case 40:  // (
+            case 41:  // )
+            case 123: // {
+            case 125: // }
+            case 60:  // <
+            case 62:  // >
+            case 47:  // /
+            case 37:  // %
+              data[j] = 95;
+              break;
+          }
+        }
       }
     },
     getStrings: function cff_getStrings(stringIndex) {