;
(function(window, document, undefined) {
    window.WebFont = {};
    window.WebFont.load = function (loadParams) {
        var link=document.createElement('link');
        link.rel = "stylesheet";
        link.href = ['/ui/pageweaver/css?', loadParams.google?'google&family='+loadParams.google.families:''].join('');
        link.onload = function() {

        };
        link.onerror = function() {
            //
        };
        var head=(document.head||document.documentElement);
        //2016 head && head.lastChild && head.insertBefore(link, head.lastChild);
        head.appendChild(link);
        // TODO:延时比较字体有没有载入，如果载入，但不管有没有载入都要发出font_load_finished事件
        setTimeout(function(){
            //2016 字体载入成功
            loadParams.active&&loadParams.active();
            //2016 字体载入失败
            //2016 loadParams.inactive&&loadParams.inactive();
        },25)

    }
    window.WebFontConfig && window.WebFont.load(window.WebFontConfig);
})(window, document);;
(function(window) {
    'use strict';
    var fonts = window.fonts;
    var WebFont = window.WebFont;
    window.googleFonts = [];
    window.typekitFonts = [];
    var googleFonts = window.googleFonts,
        typekitFonts = window.typekitFonts;
    var googleFontString = function(family, variants, subsets) {
        var result = family;
        if ( !! variants) {
            result += ':' + variants.join(',') + ':' + subsets.join(',');
        }
        return result;
    };
    $.each(fonts, function(family, font) {
        if (font.source === 'google') {
            googleFonts.push(googleFontString(family, font.variants, font.subsets));
        } else if (font.source === 'typekit') {
            typekitFonts.push({
                'id': font.id,
                'variations': font.variants,
                'css_name': font['css_name']
            });
        }
    });
    if (googleFonts.length) {
        //2016
        console.log('此处应该载入谷歌字体', googleFonts)
        WebFont.load({
            google: {
                families: googleFonts
            }
        });
    }
})(window);
