Custom font specified in CSS does not work on Android 4.4

I have an application that displays local html text in Webview. The html uses the styles.css file, which has its own font specified below:

@font-face {
font-family:myfontfamily;
src: url('file:///android_asset/fonts/MYFONT.TTF');
}

PROBLEM: Custom font does not appear in html on 4.4 devices. This problem is only in version 4.4, and before that it works fine. Strange, when I apply the same custom font to a TextView, it works. Therefore, the problem is only related to WebView. Another weird thing is that html also uses some other custom fonts (defined in the same way in css) and they render well in WebView! (Of course, a TTF file exists in the fonts folder under assets)

I checked other similar Qs, but this problem is different. I also looked at the 4.4 Webview Migration Guide , but there is nothing useful about this issue.

I am completely puzzled by this strange behavior.

Does anyone know what is going on?

+4
source share
1 answer

I managed to fix the problem by recoding the font!

+2
source

All Articles