4

I have a app which renders some local html text in a Webview. The html uses a styles.css file which has a custom font specified as follows:

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

PROBLEM: The custom font does not show up in the html on 4.4 devices. This problem is only on 4.4 and it works just fine on versions before that. Weirdly, when I apply the same custom font to a TextView, it works. So the problem is only related to the WebView. Another strange thing is that the html also uses some other custom fonts (defined in the same exact way in the css), and they show up just fine in the WebView! (Ofcourse the TTF file exists in the "fonts" folder under assets)

I have checked the other similar Qs, but this problem is different. I have also glanced at the 4.4 Webview migration guide, but there is nothing useful that could help with this problem.

I am completely puzzle by this strange behavior.

Does anybody know what's going on?

4
  • I have exactly the same problem, please let us know how you fixed it Commented Dec 2, 2013 at 13:21
  • 2
    Opened the Font in a Font editor, played around a bit and created a new TTF file. Apparently the font was first designed in 1994 and had some warnings (atleast per the font editor software). But still that does not explain why it worked flawlessly on earlier Android versions as well as works in a Text view on Android 4.4, but does not work in a Webview (it works on Chrome PC browser too!) Commented Dec 3, 2013 at 12:08
  • what font editor did you use? Commented Dec 10, 2013 at 9:41
  • Worked for me, using that same FontForge, on Windows. Commented Jan 21, 2014 at 15:50

1 Answer 1

2

I managed to fix the issue by re-encoding the font!

Sign up to request clarification or add additional context in comments.

4 Comments

Hi asim, can you give more detail as to the process you followed?
On Google plus Asim added the following comment: Opened the Font in a Font editor, played around a bit and created a new TTF file. Apparently the font was first designed in 1994 and had some warnings (atleast per the font editor software). But still that does not explain why it worked flawlessly on earlier Android versions as well as works in a Text view on Android 4.4, but does not work in a Webview (it works on Chrome PC browser too!)
Yes, the above comment sums it up.
@AAP Hi, I know it's been three years that you answered this question, But I have Symbol font which is not working Andriod 4..4 version. Could you please elaborate about re-encoding font. I have tried creating new ttf file with Generate fonts options and save as option, But no luck.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.