]> git.parisson.com Git - pdf.js.git/commitdiff
Get rid or IsNum/IsString/IsArray in flattenCharstring
authorVivien Nicolas <21@vingtetun.org>
Fri, 17 Jun 2011 04:44:16 +0000 (06:44 +0200)
committerVivien Nicolas <21@vingtetun.org>
Fri, 17 Jun 2011 04:44:16 +0000 (06:44 +0200)
PDFFont.js

index 4706121f2042ae4e11028ce65a063c77faa241db..00637f2cf540d56bf38251c8ee471cecdcbc126d 100644 (file)
@@ -188,7 +188,7 @@ Font.prototype = {
       ctx.fillText(testString, 20, 20);
 
     var start = Date.now();
-    var interval = window.setInterval(function(self) {
+    var interval = window.setInterval(function canvasInterval(self) {
       ctx.font = "bold italic 20px " + fontName + ", Symbol, Arial";
 
       // For some reasons the font has not loaded, so mark it loaded for the
@@ -1250,7 +1250,7 @@ CFF.prototype = {
     var i = 0;
     while (true) {
       var obj = aCharstring[i];
-      if (IsString(obj)) {
+      if (obj.charAt) {
         switch (obj) {
           case "callsubr":
             var subr = aSubrs[aCharstring[i- 1]].slice();
@@ -1309,13 +1309,13 @@ CFF.prototype = {
             // CharString is ready to be re-encode to commands number at this point
             for (var j = 0; j < aCharstring.length; j++) {
               var command = aCharstring[j];
-              if (IsNum(command)) {
+              if (parseFloat(command) == command) {
                 var number = this.encodeNumber(command, true);
                 aCharstring.splice(j, 1);
                 for (var k = 0; k < number.length; k++)
                   aCharstring.splice(j + k, 0, number[k]);
                 j+= number.length - 1;
-              } else if (IsString(command)) {
+              } else if (command.charAt) {
                 var command = this.commandsMap[command];
                 if (IsArray(command)) {
                   aCharstring.splice(j - 1, 1, command[0], command[1]);
@@ -1323,7 +1323,7 @@ CFF.prototype = {
                 } else {
                   aCharstring[j] = command;
                 }
-              } else if (IsArray(command)) {
+              } else {
                 aCharstring.splice(j, 1);
 
                 // command has already been translated, just add them to the
@@ -1331,8 +1331,6 @@ CFF.prototype = {
                 for (var k = 0; k < command.length; k++)
                   aCharstring.splice(j + k, 0, command[k]);
                 j+= command.length - 1;
-              } else { // what else?
-                error("Error while flattening the Type1 charstring: " + aCharstring);
               }
             }
             return aCharstring;