0

我有以下脚本,它为字体提供本地服务器后备:

<!-- 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) {

对于我的生活,我无法弄清楚出了什么问题对不起 - 我确信某处有一个愚蠢的错误。

任何指向正确方向的指针都将不胜感激。

干杯

4

1 回答 1

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>
于 2014-05-29T20:54:39.237 回答