Check for stylesheet presence (font.js)

If doc doesn't have a stylesheet, create one.
This commit is contained in:
Artur Adib 2011-09-14 16:26:36 -07:00
parent 4dd79a51c1
commit de253dcbe3

View File

@ -1291,6 +1291,10 @@ var Font = (function Font() {
window.btoa(data) + ');');
var rule = "@font-face { font-family:'" + fontName + "';src:" + url + '}';
var styleSheet = document.styleSheets[0];
if (!styleSheet) {
document.documentElement.firstChild.appendChild( document.createElement('style') );
styleSheet = document.styleSheets[0];
}
styleSheet.insertRule(rule, styleSheet.cssRules.length);
return rule;