Fix a small issue in the waiting for font to load code

This commit is contained in:
Vivien Nicolas 2011-07-02 01:01:55 +02:00
parent d10cf7c929
commit 3dcf65d9df

View File

@ -77,9 +77,6 @@ var Fonts = (function Fonts() {
measureCache = sizes[size] = Object.create(null); measureCache = sizes[size] = Object.create(null);
ctx.font = (size * kScalePrecision) + 'px "' + fontName + '"'; ctx.font = (size * kScalePrecision) + 'px "' + fontName + '"';
}, },
getActive: function fonts_getActive() {
return current;
},
charsToUnicode: function fonts_chars2Unicode(chars) { charsToUnicode: function fonts_chars2Unicode(chars) {
if (!charsCache) if (!charsCache)
return chars; return chars;
@ -479,8 +476,9 @@ var Font = (function () {
idDeltas += string16(delta); idDeltas += string16(delta);
idRangeOffsets += string16(0); idRangeOffsets += string16(0);
for (var j = 0; j < range.length; j++) for (var j = start; j < end; j++) {
glyphsIds += String.fromCharCode(range[j]); glyphsIds += string16(j);
}
} }
startCount += "\xFF\xFF"; startCount += "\xFF\xFF";
@ -1034,8 +1032,9 @@ var Font = (function () {
// different once the real font has loaded // different once the real font has loaded
var textWidth = ctx.measureText(testString).width; var textWidth = ctx.measureText(testString).width;
var start = Date.now();
var interval = window.setInterval(function canvasInterval(self) { var interval = window.setInterval(function canvasInterval(self) {
this.start = this.start || Date.now(); this.start = start;
ctx.font = "bold italic 20px " + fontName + ", Symbol, Arial"; ctx.font = "bold italic 20px " + fontName + ", Symbol, Arial";
// For some reasons the font has not loaded, so mark it loaded for the // For some reasons the font has not loaded, so mark it loaded for the