我正在使用Web Font Loader从Google webfonts加载字体,但它似乎只加载400重量。我希望包括300,400,700但无法找到办法。
WebFontConfig = {
google: {
families: ['Open Sans']
}
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
'://ajax.googleapis.com/ajax/libs/webfont/1.4.7/webfont.js';
wf.type = 'text/javascript';
wf.async = 'true';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(wf, s);
})();
答案 0 :(得分:8)
我发现这个解决方案有效。
WebFontConfig = {
google: {
families: ['Open Sans:300,400,700']
},
答案 1 :(得分:2)
正如Keith Power所提到的,你必须添加类型。但是为了让它适用于所有提供商(最重要的是使用自定义字体),您必须使用Font Variation Description:
WebFontConfig = {
custom: {
families: ['My Font', 'My Other Font:n4,i4,n7'],
}
};