You can create a new <style>
element with the @font-face
rule and append it to the document
's head
:
var newStyle = document.createElement('style');
newStyle.appendChild(document.createTextNode("
@font-face {
font-family: " + yourFontName + ";
src: url('" + yourFontURL + "') format('yourFontFormat');
}
"));
document.head.appendChild(newStyle);
Of course, you'll probably need to provide all the necessary font formats and URLs, too, unless you're only worried about support for modern desktop browsers (in which case you would just use WOFF – I assume that's reasonable, because of the other features you mentioned).
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…