Browse Source

don't use an array to translate from a typed array to a string, and always store font data as typed array, never as a stream

Andreas Gal 14 years ago
parent
commit
5001ee7120
  1. 17
      fonts.js

17
fonts.js

@ -154,14 +154,13 @@ Font.prototype = { @@ -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) { @@ -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();
}
};

Loading…
Cancel
Save