谷歌webfonts工作不使用的Andr​​oid 4.0和4.2.2 Web视图 [英] Google webfonts not working using Web View in Android 4.0 and 4.2.2

查看:119
本文介绍了谷歌webfonts工作不使用的Andr​​oid 4.0和4.2.2 Web视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Andr​​oid应用程序,使用他们的工作罚款的Andr​​oid 4.4版本的Web视图中使用谷歌的Web字体。与Android 4.2的一些设备显示的默认字体,最正常工作。在Android 4.0然而,所有的字体默认为相同的默认字体。

When using Google web fonts in my Android app that uses web view they work fine in version 4.4 of Android. Some devices with Android 4.2 show the default font, most work correctly. On Android 4.0 however all fonts default to the same default font.

由于我们要定位的Andr​​oid 4.0,并与我们的应用程序更高的我正在寻找一种方式来获得的谷歌Web字体可靠地工作。

Because we like to target Android 4.0 and higher with our app I am looking for a way to get the Google web fonts working reliably.

该应用程序确实有点多,从一台服务器在Web视图中打开HTML文件。

The app does little more than opening html files from a server in the web view.

更新: 事实证明,一些安卓4.2.2设备将无法正常显示谷歌的Web字体。目前尚不清楚是什么让这些设备从那些经我测试,其中Web字体正常工作中脱颖而出。

Update: It turns out that some Android 4.2.2 devices do not show Google web fonts correctly. It is not clear what makes these devices stand out from the ones that I tested and where web fonts work correctly.

我能做些什么来让网页字体可靠地工作在不同的Andr​​oid版本和设备?

What can I do to make web fonts work reliably over different Android versions and devices?

推荐答案

以上这些问题的答案是有效的,并深入了解这个问题,这要感谢的 moallemi Vaiden 的那些。在Android 4.0这是一个耻辱,我们不能使用网络字体。

The answers above are valid and give insight into the subject, thanks to moallemi and Vaiden for those. We cannot use web fonts on Android 4.0 that is a shame.

与在Android 4.2 webfonts要解决我们的问题是有关在,谷歌使用了包含实际的字体文件的CSS他们指定格式的事实。这意味着,在谷歌的CSS他们有code这样的:

The solution to our problem with webfonts on Android 4.2 was related to the fact that in the CSS that Google uses to include the actual font files they specify the format. This means that in Google's CSS they have code like:

src: url("http://some.google.server/some/path/FontName.ttf") format('ttf');

事实证明,字体不要在的WebView 在Android 4.2渲染,如果格式()条款在CSS present(或<风格> 的HTML节点)。解决的办法是简单因此; CSS的应该有这样一行:

It turns out that fonts don't render in the WebView on Android 4.2 if the format() clause is present in the CSS (or <style> node of the HTML). The solution is therefore simple; the CSS should have a line like this:

src: url("http://some.google.server/some/path/FontName.ttf");

这使字体的工作。然而,这并没有使一个简单的解决方案。由于谷歌提供了包含这个错误,你需要创建CSS,包括/使用,并提供你自己版本的CSS文件,如果你不想受到的谷歌更新了其字体文件的位置,你需要承载的字体文件你自己。

This makes the font work. This, however, does not make for a "simple" solution. Since Google provides the CSS containing this error you need to create, include/use and supply your own version of the CSS file and if you do not want to be subject of Google updating the location of its font files you need to host the font files yourself.

这篇关于谷歌webfonts工作不使用的Andr​​oid 4.0和4.2.2 Web视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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