Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android TextView vs WebView Font Rendering

I have a TextView placed directly above a WebView. I am attempting to make the font style in the WebView match the font style in the TextView.

I was able to make the fonts the same size but there are still minor differences between the fonts' rendering (see screenshot comparison). Now I think this is very minor but our client was able to see the difference and was questioning it.

Is there any way to eliminate these rendering differences between TextView and WebView? If not can someone explain the reason for the differences? Are these differences caused simply because the WebView uses WebKit which has its own font rendering engine separate from the rest of the Android platform?

Screenshot comparison

like image 580
craigrs84 Avatar asked Nov 03 '22 01:11

craigrs84


1 Answers

I'm not sure about TextView, but I know WebView is capable of positioning text on non-pixel-aligned boundaries, and I think this is what you're seeing. The WebView and TextView output look different because their positions are off by smaller-than-a-pixel amounts.

I assume your client is either using a low-density device or has really sharp eyes = )

If you tweak the position of the text a little it should eventually look the same. Where the WebView is concerned, it may help to ensure that all the zooming and reformatting features are turned off.

like image 134
j__m Avatar answered Nov 11 '22 11:11

j__m