External font does not load in Android 2.1

I use the external TrueType font in the embedded HTML resource. The font is in assets at the same level as the HTML resource.

The font is loaded using CSS:

@font-face { 
    font-family: MyExternalFont; 
    src: url('MyExternalFont.ttf'); 
}
body {
    font-family:MyExternalFont;
}

And the HTML resource is loaded as follows:

WebView w = (WebView) findViewById(R.id.webview);
w.loadUrl("file:///android_asset/index.htm");

This works fine in Android 1.5 , Android 1.6 and Android 2.2 . It does not work in Android 2.1 .

However, when I download the font and use it in TextView, it works on all versions of Android. I do it like this:

final Typeface t = Typeface.createFromAsset(getContext().getAssets(), "MyExternalFont.ttf");
textView.setTypeface(t);

What could be the problem?

(Unfortunately, I cannot download the font because it is a paid font)

+3
1

Android 2.0 2.1. WebView , .

+5

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


All Articles