27

No, like others, I don't want to use custom fonts. I am looking for list of WebView safe fonts that can be used without using CSS3's custom @font-face, which loads ttf/wof/eot font from web/local storage.

More refined question would be: What are the list font's that are included with Android Operating System which can be used inside WebView?

For example, Arial, Verdana, sans-serif, etc font can be used (not sure), so where exactly to look for to be 100% sure?

Thanks

Hossain Khan
  • 6,332
  • 7
  • 41
  • 55
  • I'm looking into Android 3.0 and above. Font should be globally available regardless of device OEM (Samsung/LG/Acer/Sony/etc). – Hossain Khan Nov 09 '11 at 20:28
  • [Is this helpful](http://stackoverflow.com/questions/3200069/css-fonts-on-android/6012324#6012324)? – Alex Nov 09 '11 at 20:31
  • @Alex not exactly, these fonts can not be used inside WebView without using CSS3 @font-face (unless I am missing something). So, you can not just say: `body { font-family: "Droid Sans"; }` or `body { font-family: "Droid Serif"; }` .... none of them work. But `body { font-family: Arial; }` probably works, but I want to know where to look for list of available fonts like arial. – Hossain Khan Nov 09 '11 at 20:51
  • Okay here are some question which are very close to what I am looking for: http://stackoverflow.com/questions/3532397/how-to-retrieve-a-list-of-available-installed-fonts-in-android - Says there is no way to retrive list of available fonts bundled for WebKit. And http://stackoverflow.com/questions/6809944/default-font-set-on-android - does not have the exact answer what I am also looking for. – Hossain Khan Nov 10 '11 at 15:14

1 Answers1

42

Webview: It uses the WebKit rendering engine to display web pages

According to the source code, android.webkit.WebSettings contains the following fields:

private String          mStandardFontFamily = "sans-serif";
private String          mFixedFontFamily = "monospace";
private String          mSansSerifFontFamily = "sans-serif";
private String          mSerifFontFamily = "serif";
private String          mCursiveFontFamily = "cursive";
private String          mFantasyFontFamily = "fantasy";

Accordingly, these are the fonts.

There is probably more fonts buried somewhere in the WebKit. However, they do not appear to be accessible.


This complies with the default fonts of Linux:

  • Sans-serif fonts: Arial Black, Arial, Comic Sans MS, Trebuchet MS, and Verdana
  • Serif fonts: Georgia and Times New Roman
  • Monospace fonts: Andale Mono and Courier New
  • Fantasy fonts: Impact and Webdings

Bottom line, there is no comprehensive list of fonts for the Android WebKit.

Sherif elKhatib
  • 45,786
  • 16
  • 89
  • 106
  • Understood! +1 for taking your time to clarify this. Thanks – Hossain Khan Nov 16 '11 at 02:53
  • Through my tests it seems that the Droid family is the only one included. Anything else should be free or will need to be licensed, and still included through CSS. – Sean Aitken Jul 09 '13 at 17:03
  • 1
    Are there in the meanwhile new fonts added on recent Android versions? – Roel May 31 '17 at 11:14
  • Can you help me how to solve my problem here is the link https://stackoverflow.com/questions/65108865/android-webview-custom-font-using-javascript – Karthikkumar Dec 03 '20 at 10:45