]> git.parisson.com Git - pdf.js.git/commitdiff
don't use an array to translate from a typed array to a string, and always store...
authorAndreas Gal <andreas.gal@gmail.com>
Sun, 19 Jun 2011 22:30:55 +0000 (15:30 -0700)
committerAndreas Gal <andreas.gal@gmail.com>
Sun, 19 Jun 2011 22:30:55 +0000 (15:30 -0700)
fonts.js

index 6cf9d6c1dc5e9b79cc48e82dd6336001ecbd929e..e018061e9d9bb76cdc0c5ba9244977374a2f50e9 100644 (file)
--- a/fonts.js
+++ b/fonts.js
@@ -154,14 +154,13 @@ Font.prototype = {
   bind: function font_bind() {
     var data = this.font;
 
-    // Compute the binary data to base 64
-    var str = [];
-    var count = data.length;
-    for (var i = 0; i < count; i++)
-      str.push(data.getChar ? data.getChar()
-                            : String.fromCharCode(data[i]));
-
-    var dataBase64 = window.btoa(str.join(""));
+    // Get the base64 encoding of the binary font data
+    var str = "";
+    var length = data.length;
+    for (var i = 0; i < length; ++i)
+      str += String.fromCharCode(data[i]);
+
+    var dataBase64 = window.btoa(str);
     var fontName = this.name;
 
     /** Hack begin */
@@ -752,7 +751,7 @@ var TrueType = function(aFile) {
   } else if (requiredTables.lenght) {
     error("Table " + requiredTables[0] + " is missing from the TruType font");
   } else {
-    this.data = aFile;
+    this.data = aFile.getBytes();
   }
 };