Merge pull request #182 from cgjones/issue-176
we don't cache built-in fonts
This commit is contained in:
commit
5f70605dd8
7
fonts.js
7
fonts.js
@ -70,11 +70,14 @@ var Fonts = (function Fonts() {
|
|||||||
return fonts[fontName];
|
return fonts[fontName];
|
||||||
},
|
},
|
||||||
setActive: function fonts_setActive(fontName, size) {
|
setActive: function fonts_setActive(fontName, size) {
|
||||||
current = fonts[fontName];
|
// |current| can be null is fontName is a built-in font
|
||||||
|
// (e.g. "sans-serif")
|
||||||
|
if ((current = fonts[fontName])) {
|
||||||
charsCache = current.charsCache;
|
charsCache = current.charsCache;
|
||||||
var sizes = current.sizes;
|
var sizes = current.sizes;
|
||||||
if (!(measureCache = sizes[size]))
|
if (!(measureCache = sizes[size]))
|
||||||
measureCache = sizes[size] = Object.create(null);
|
measureCache = sizes[size] = Object.create(null);
|
||||||
|
}
|
||||||
ctx.font = (size * kScalePrecision) + 'px "' + fontName + '"';
|
ctx.font = (size * kScalePrecision) + 'px "' + fontName + '"';
|
||||||
},
|
},
|
||||||
charsToUnicode: function fonts_chars2Unicode(chars) {
|
charsToUnicode: function fonts_chars2Unicode(chars) {
|
||||||
@ -87,7 +90,7 @@ var Fonts = (function Fonts() {
|
|||||||
return str;
|
return str;
|
||||||
|
|
||||||
// translate the string using the font's encoding
|
// translate the string using the font's encoding
|
||||||
var encoding = current.properties.encoding;
|
var encoding = current ? current.properties.encoding : null;
|
||||||
if (!encoding)
|
if (!encoding)
|
||||||
return chars;
|
return chars;
|
||||||
|
|
||||||
|
@ -91,7 +91,9 @@ function displayPage(num) {
|
|||||||
infoDisplay.innerHTML = "Time to load/compile/fonts/render: "+ (t1 - t0) + "/" + (t2 - t1) + "/" + (t3 - t2) + "/" + (t4 - t3) + " ms";
|
infoDisplay.innerHTML = "Time to load/compile/fonts/render: "+ (t1 - t0) + "/" + (t2 - t1) + "/" + (t3 - t2) + "/" + (t4 - t3) + " ms";
|
||||||
}
|
}
|
||||||
|
|
||||||
FontLoader.bind(fonts, displayPage);
|
// Always defer call to displayPage() to work around bug in
|
||||||
|
// Firefox error reporting from XHR callbacks.
|
||||||
|
FontLoader.bind(fonts, function () { setTimeout(displayPage, 0); });
|
||||||
}
|
}
|
||||||
|
|
||||||
function nextPage() {
|
function nextPage() {
|
||||||
|
Loading…
Reference in New Issue
Block a user