Web Font Loader是否不缓存字体? [英] Does Web Font Loader not cache the fonts?

查看:272
本文介绍了Web Font Loader是否不缓存字体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想测试Web Font Loader的能力,而我意外地发现,当我需要在另一个页面中加载相同的字体时,加载器执行新的下载,而不是使用缓存版本的字体。这是正常的吗?如果是这样,是否有一个简单的方法来检查浏览器是否可以使用该字体,换句话说,它是否被缓存?



以下是我如何加载字体:

 < script> 
WebFont.load({
custom:{
families:['Univers45custom','Univers45customIE']
}
});
< / script>

我使用 Web Font Loader v1.5.10

BramVanroy的附录:使用Google的网页字体时,缺少缓存也存在。即使重新加载页面多次,使用字体加载器的网站也会短暂出现FOUT(未格式化文本的Flash)。



编辑eldi:嗨BramVanroy - >现在我不太确定我是如何解决这个问题的,但可能我只是使用了 @字体面。我测试Web Font Loader的原因是首先是FOUT。 Loader将css类添加到html元素中,这为您提供了一种方法,可以在不使用正确字体的情况下对页面进行样式设置,当字体被加载时,类将消失,您的标准样式出现。这是按预期工作的,但是由于'缺少缓存'的例外,这在我的情况下是不可接受的。我相信,用修改HTTP头的staypuftman解决方法可以完成这项工作,我没有时间去测试它,特别是我需要做一些研究,以找到在asp.net主机提供商中设置它的方法,增加额外的处理时间。

解决方案

WebFont Loader会将字体缓存到Web浏览器中1年,这里是详细介绍如何加载webfont结束详细信息回家的时间它会在浏览器缓存。


http://peterwilson.cc/caching-google-webfont-loader/





Web Font Loader为您提供了通过 @ font-face 。它提供了一个加载字体的通用界面,无论来源如何,然后添加一组标准事件来控制加载体验。 Web Font Loader可以从 Google字体 Typekit ,以及 Fontdeck 以及自托管网页字体。它由 Google Typekit


Just wanted to test the ability of the Web Font Loader and surprisingly I have discovered that when I need to load the same font in another page then the loader performs new download instead of using a cached version of the font. Is this normal? If so, is there a simple way to check if the font is available for the browser, in other words whether it is cached?

Here's is how I load the font:

 <script>
    WebFont.load({
        custom: {
            families: ['Univers45custom', 'Univers45customIE']
        }
    });
</script>

I am using Web Font Loader v1.5.10.

Addendum by BramVanroy: this 'lack of caching' is also present when using Google's webfonts. FOUT (a Flash of Unstyled Text) briefly occurs on a website that uses the font loader even after reloading the page multiple times.

Edit by eldi: Hi BramVanroy -> Right now I am not really sure how I went around this issue, but probably I just used the @font-face. The reason why I tested the Web Font Loader was the FOUT in the first place. The Loader adds css class to html element which provide you a way to style your page without the right font, when the fonts are loaded then the class is gone and your "standard" styling is present. That was working as expected but with the 'lack of caching' exception, which in my situation was not acceptable. I believe that staypuftman workaround with modifying HTTP header would do the job, I do not have time to test it, especially I would need to do some research to find the way to set it in asp.net hosting provider as setting it from application will add additional processing time.

解决方案

WebFont Loader will cache the font into the web browser for the 1 year here is the detail how can you load webfont end detail home much time it will be in browser cache.

http://peterwilson.cc/caching-google-webfont-loader/

Web Font Loader

Web Font Loader gives you added control when using linked fonts via @font-face. It provides a common interface to loading fonts regardless of the source, then adds a standard set of events you may use to control the loading experience. The Web Font Loader is able to load fonts from Google Fonts, Typekit, Fonts.com, and Fontdeck, as well as self-hosted web fonts. It is co-developed by Google and Typekit.

这篇关于Web Font Loader是否不缓存字体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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