我有以下脚本,它为字体提供本地服务器后备:
<!-- load fonts via webfont.js with local fallback: https://github.com/typekit/webfontloader -->
<script src="//ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js"></script>
<script>window.WebFont || document.write('<script src="../assets/js/webfont.js"><\/script>')</script>
<script>
WebFont.load({
// load fonts from CDN
google: {
families: ['Flamenco']
},
custom: {
families: ['FontAwesome'],
urls: [ '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css' ]
}
// load server fallback if CDN is unavailable
fontinactive: function (family, fvd) {
if (family === 'Flamenco' || 'FontAwesome') {
WebFont.load({
custom: {
families: ['Flamenco', 'FontAwesome'],
urls: [ '../assets/fonts/local-fonts.css' ]
}
})
}
},
});
</script>
但是firefox表示这一行缺少结束}
fontinactive: function (family, fvd) {
对于我的生活,我无法解决什么是错误的抱歉 - 我确定某处有一个愚蠢的错误。
非常感谢任何正确方向的指示。
干杯
答案 0 :(得分:0)
很抱歉,将功能复制到底部并忘记了逗号 - 加上我认为首先需要先使用fontinactive。
更正了我的参考脚本:
<!-- load fonts via webfont.js with local fallback: https://github.com/typekit/webfontloader -->
<script src="//ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js"></script>
<script>window.WebFont || document.write('<script src="../assets/js/webfont.js"><\/script>')</script>
<script>
WebFont.load({
// load server fallback if CDN is unavailable
fontinactive: function (family, fvd) {
if (family === 'Flamenco' || 'FontAwesome') {
WebFont.load({
custom: {
families: ['Flamenco', 'FontAwesome'],
urls: [ '../assets/fonts/local-fonts.css' ]
}
})
}
},
// load fonts from CDN
google: {
families: ['Flamenco']
},
custom: {
families: ['FontAwesome'],
urls: [ '//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css' ]
}
});
</script>