Google websites not working using web view in Android 4.0 and 4.2.2

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

Since we like to target Android 4.0 and higher with our application, I’m looking for a way to get Google Web Fonts to work reliably.

The application does nothing more than open html files from the server in a web view.

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

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

+6
source share
3 answers

The answers above are reliable and give an idea of ​​the subject, thanks to moallemi and Vaiden for those. We cannot use web fonts on Android 4.0, which is a shame.

The solution to our problem with webfonts on Android 4.2 is because in the CSS that Google uses to include the actual font files, they define the format. This means that in Google CSS they have code like:

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

It turns out that fonts do not appear in WebView on Android 4.2 if the format() clause is present in CSS (or <style> node HTML). Therefore, the solution is simple; CSS should have a line like this:

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

This makes the font work. This, however, does not mean a β€œsimple” solution. Since Google provides CSS containing this error, you need to create, enable / use and provide your own version of the CSS file, and if you do not want the Google object to update the location of its font files, you need to place the font files yourself.

+3
source

WebView in Android 4.0.X does not support web fonts

+1
source

In KitKat (4.4.x), Google changed the WebView engine from WebKit to Chromium .

To improve the predictability of the results you actually get, here is a list of WebKit versions for the Android version . Keep in mind that this is not an official list. It was compiled from specific collected developer statistics.

I have yet to find an official document on this subject, which may suggest that manufacturers were free to choose their own WebKit assembly for their devices. This may explain the inconsistencies between the various devices.

So what to do?

+1
source

Source: https://habr.com/ru/post/970699/


All Articles