java - Use custom (unicode) fonts in WebView for my Android app -


i wanted use custom fonts in android app, custom fonts in textview works fine couldn't find way add custom (unicode) fonts in webview, have tried every way possible failed, take @ code see whether missed something. thankyou.!

i've created css file custom font-family in asset folder , called loaddatawithbaseurl doesn't work.

        htmltextview = (webview) findviewbyid(r.id.htmltextview);          string text = "<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\" />";         htmltextview.loaddatawithbaseurl("file:///android_asset/", text, "text/html", "utf-8", null);          htmltextview.getsettings().setjavascriptenabled(true);         htmltextview.setbackgroundcolor(color.transparent);         htmltextview.getsettings().setdefaultfontsize(                 webhelper.getwebviewfontsize(this)); 

css file:

@font-face {   font-family: 'iskoola pota';   src: url('fonts/iskpota.ttf')  format('truetype'); } 

there way put html code in index.html file

webview.loadurl("file:///android_asset/html/index.html"); 

html this. call css file asset folder

<html> <head><link href="file:///android_asset/css/mystyle.css" type="text/css" rel="stylesheet"/></head> <body>     <img class="img" src="file:///android_asset/img/ok.png">     <p > above image  shown assets folder... </p>     <p>custom font <span style="color:red">'trado'</span> asset folder has been applied on text</p> </body> 

and css this, need put font file in asset folder ..

 @font-face {     font-family: trado;     src: url('file:///android_asset/fonts/trado.ttf'); } 

hope works .. complete example on github click


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -