diff --git a/fonts.js b/fonts.js index 4a09931e5..41f70f963 100644 --- a/fonts.js +++ b/fonts.js @@ -149,7 +149,11 @@ var FontLoader = { for (var j = 0; j < length; j++) str += String.fromCharCode(data[j]); - worker ? obj.bindWorker(str) : obj.bindDOM(str, rules, names); + var rule = worker ? obj.bindWorker(str) : obj.bindDOM(str); + if (rule) { + rules.push(rule); + names.push(font.name); + } } } @@ -182,14 +186,25 @@ var FontLoader = { // our @font-face rule was loaded. However, the subdocument and // outer document can't share CSS rules, so the inner document // is only part of the puzzle. The second piece is an invisible - // paragraph created in order to force loading of the @font-face - // in the *outer* document. (The font still needs to be loaded - // for its metrics, for reflow). We create the
first (in - // |bindDom()| function below), for the outer document, then - // create the iframe. Unless something goes really wonkily, we - // expect the @font-face for the outer document to be processed - // before the inner. That's still fragile, but seems to work in - // practice. + // div created in order to force loading of the @font-face in + // the *outer* document. (The font still needs to be loaded for + // its metrics, for reflow). We create the div first for the + // outer document, then create the iframe. Unless something + // goes really wonkily, we expect the @font-face for the outer + // document to be processed before the inner. That's still + // fragile, but seems to work in practice. + + var div = document.createElement("div"); + div.setAttribute("style", + 'visibility: hidden;'+ + 'width: 10px; height: 10px;'+ + 'position: absolute; top: 0px; left: 0px;'); + var html = ''; + for (var i = 0; i < names.length; ++i) { + html += 'Hi'; + } + div.innerHTML = html; + document.body.appendChild(div); // XXX we should have a time-out here too, and maybe fire // pdfjsFontLoadFailed? @@ -218,7 +233,7 @@ var FontLoader = { src += ' }'; src += '
'; for (var i = 0; i < names.length; ++i) { - src += 'Hello
'; + src += 'Hi
'; } src += '