fontcustom.css,使用webfont.js加载自定义字体(Loading custom fonts with webfont.js)

I'm working on a project where I'm trying to use some 5 custom fonts.

I use webfont.js library so that I can time my initialisation the way I want to.

However, I notice that I have an intermittent issue, whereby webfont.js will fail loading all 5 fonts 75% of the time. If I ignore the error (inactive handler) and just resume loading my site I can see all custom fonts fine.

This is annoying because webfont.js takes around 4 seconds to raise the inactive event and so the user just sees the blank page while this is happening.

How do I fix (or at least debug) this?

This is my setup (util.js):

var mutexFontsLoaded = $.Callbacks("memory once");

WebFontConfig = {

custom: {

families: ['Chennai-Regular', 'Chennai-Light', 'Chennai-Bold', 'Quicksand-Bold', 'Segoe-Print'],

urls: ['css/fonts.css']

},

loading: function () { console.log("Loading fonts.."); },

active: function () { mutexFontsLoaded.fire(); },

fontinactive: function (font, fvd) { console.log("Could'nt load " + font + " font"); },

inactive: function () { console.log("All fonts failed loading..\n\rTrying to load site anyway.."); mutexFontsLoaded.fire(); }

};

Followed by the Web Font Loader library - 1.5.1

Then in my main script:

$(document).ready(function () {

mutexFontsLoaded.add(function()

{

application.init();

});

});

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值