Google / Typekit Webfont-Loader不会检测非ASCII字体 [英] Google/Typekit Webfont-Loader does not detect non-ASCII fonts

查看:329
本文介绍了Google / Typekit Webfont-Loader不会检测非ASCII字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Google Webfont装载程序,但我可以不会得到 fontactive 回调工作。字体在页面上呈现,但由于某种原因,回调不会触发。 (而是等待5秒,然后 fontinactive 回调触发。)我怀疑问题是我如何声明函数的两个变量。



编辑:问题可能与字体有关,而不是我如何声明变量。



fontactive 的文档, / code>回调是此处。我没有找到任何使用 fontactive 回调的示例。



/ p>

  WebFont.load({
custom:{
families:['STIXSizeOneSym'],
urls:['resources / stix-fonts / STIX-fonts.css']
},
fontactive:function(stixsizeonesym,n4){alert(1)},
fontinactive :function(stixsizeonesym,n4){alert(2)},
inactive:function(){alert(10)}
}



从STIX-fonts.css: <$ p

  @ font-face {
font-family:'STIXSizeOneSym'
src:url('STIXSizOneSymBol-webfont.eot');
src:url('STIXSizOneSymBol-webfont.eot?#iefix')format('embedded-opentype'),
url('STIXSizOneSymBol.otf')format('opentype'),
url('STIXSizOneSymBol-webfont.ttf')format('truetype');
font-weight:bold;
font-style:normal;
}


解决方案

webfontloader的开发人员。我们当前使用ASCII字符串来检测字体是否已加载。因此,如果您的字体不包括字符BESbswy,webfontloader将无法检测它。我们正在努力添加对可配置测试字符串的支持(所以你可以包括你的字体支持的Unicode范围的一些字符。)我已经在webfontloader存储库上打开了一个问题( https://github.com/typekit/webfontloader/issues/104 )。



作为一个临时解决方案,您可以编译自己的webfontloader版本,将字体中的字符添加到测试字符串。如果您需要帮助,请告诉我们。


I'm using the Google webfont loader, but I can't get the fontactive callback to work. The font is rendering on the page, but for some reason the callback isn't firing. (Instead it waits for 5 seconds and then the fontinactive callback fires.) I suspect the problem is in how I'm declaring the two variables to the function.

Edit: The problem may have to do with the font, not how I'm declaring the variable. The font-loader sucessfully detects when the "STIXGeneral" font family loads, which contains regular letter characters.

Documentation of the fontactive callback is here. I haven't been able to find any examples of using the fontactive callback.

I've posted a copy of my code below.


From Javascript:

WebFont.load({
    custom: {
        families: [ 'STIXSizeOneSym' ],
        urls: ['resources/stix-fonts/STIX-fonts.css']
    },
    fontactive: function(stixsizeonesym, n4) { alert("1") },
    fontinactive: function(stixsizeonesym, n4) { alert("2") },
    inactive: function() { alert("10") }
});


From STIX-fonts.css:

@font-face {
    font-family: 'STIXSizeOneSym';
    src: url('STIXSizOneSymBol-webfont.eot');
    src: url('STIXSizOneSymBol-webfont.eot?#iefix') format('embedded-opentype'),
          url('STIXSizOneSymBol.otf') format('opentype'),
          url('STIXSizOneSymBol-webfont.ttf') format('truetype');
    font-weight: bold;
    font-style: normal;
    }

解决方案

I'm one of the developers of the webfontloader. We are currently using an ASCII string to detect whether or not a font has loaded. So if your font does not include the characters "BESbswy" the webfontloader won't be able to detect it. We're working on adding support for configurable test strings (so you can include some characters from the Unicode range your font supports.) I've opened an issue for this on the webfontloader repository (https://github.com/typekit/webfontloader/issues/104).

As a temporary solution you can compile your own version of the webfontloader that adds characters from your font to the test string. Let me know if you need help with that.

这篇关于Google / Typekit Webfont-Loader不会检测非ASCII字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆