fixed font loading bug
This commit is contained in:
parent
619a521678
commit
4404871212
11
fonts.js
11
fonts.js
@ -61,16 +61,16 @@ var Fonts = (function Fonts() {
|
|||||||
lookupById: function fonts_lookupById(id) {
|
lookupById: function fonts_lookupById(id) {
|
||||||
return fonts[id];
|
return fonts[id];
|
||||||
},
|
},
|
||||||
setActive: function fonts_setActive(font, size) {
|
setActive: function fonts_setActive(fontName, fontObj, size) {
|
||||||
// |current| can be null is fontName is a built-in font
|
// |current| can be null is fontName is a built-in font
|
||||||
// (e.g. "sans-serif")
|
// (e.g. "sans-serif")
|
||||||
if ((current = fonts[font.id])) {
|
if (fontObj && (current = fonts[fontObj.id])) {
|
||||||
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 "' + font.loadedName + '"';
|
ctx.font = (size * kScalePrecision) + 'px "' + fontName + '"';
|
||||||
},
|
},
|
||||||
charsToUnicode: function fonts_chars2Unicode(chars) {
|
charsToUnicode: function fonts_chars2Unicode(chars) {
|
||||||
if (!charsCache)
|
if (!charsCache)
|
||||||
@ -161,6 +161,7 @@ var FontLoader = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.listeningForFontLoad = false;
|
||||||
if (!isWorker && rules.length) {
|
if (!isWorker && rules.length) {
|
||||||
FontLoader.prepareFontLoadEvent(rules, names, ids);
|
FontLoader.prepareFontLoadEvent(rules, names, ids);
|
||||||
}
|
}
|
||||||
@ -213,7 +214,7 @@ var FontLoader = {
|
|||||||
div.innerHTML = html;
|
div.innerHTML = html;
|
||||||
document.body.appendChild(div);
|
document.body.appendChild(div);
|
||||||
|
|
||||||
if (!this.listeneningForFontLoad) {
|
if (!this.listeningForFontLoad) {
|
||||||
window.addEventListener(
|
window.addEventListener(
|
||||||
'message',
|
'message',
|
||||||
function(e) {
|
function(e) {
|
||||||
@ -227,7 +228,7 @@ var FontLoader = {
|
|||||||
document.documentElement.dispatchEvent(evt);
|
document.documentElement.dispatchEvent(evt);
|
||||||
},
|
},
|
||||||
false);
|
false);
|
||||||
this.listeneningForFontLoad = true;
|
this.listeningForFontLoad = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX we should have a time-out here too, and maybe fire
|
// XXX we should have a time-out here too, and maybe fire
|
||||||
|
2
pdf.js
2
pdf.js
@ -3885,7 +3885,7 @@ var CanvasGraphics = (function() {
|
|||||||
this.ctx.$setFont(fontName, size);
|
this.ctx.$setFont(fontName, size);
|
||||||
} else {
|
} else {
|
||||||
this.ctx.font = size + 'px "' + fontName + '"';
|
this.ctx.font = size + 'px "' + fontName + '"';
|
||||||
Fonts.setActive(fontObj, size);
|
Fonts.setActive(fontName, fontObj, size);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setTextRenderingMode: function(mode) {
|
setTextRenderingMode: function(mode) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user