Question

I am generating HTML page runtime, I have put my font file in assets folder. "MyriadProRegular.otf"

String mStyle = "<style type=\"text/css\"> body { font-size: 100%; font-family: 'MyriadProRegular'; src: url('file:///android_asset/MyriadProRegular.otf'); }  </style>";


String mHTML = "<html><head> " + mStyle + " </head><body>"
    + " Hello World " + "</body></html>";

And loading like this.

WebView mWebview = new WebView(this);
mWebview.loadDataWithBaseURL(null, mHTML, "text/html","utf-8", null);

HTML not loding fonts.

I have also tried with

body { font-size: 100%; font-family: 'MyriadProRegular'; src:url('MyriadProRegular.otf'); } 

And

mWebview.loadDataWithBaseURL("file:///android_asset/", mHTML, "text/html","utf-8", null);

But still its not loading, not getting what I am missing?

Edit:

I am getting following log, only these five lines.

01-06 11:39:34.724: E/Trace(2090): error opening trace file: No such file or directory (2)
01-06 11:39:35.923: D/dalvikvm(2090): GC_CONCURRENT freed 53K, 3% free 8410K/8583K, paused 40ms+28ms, total 216ms
01-06 11:39:36.253: I/Choreographer(2090): Skipped 56 frames!  The application may be doing too much work on its main thread.
01-06 11:39:36.293: D/gralloc_goldfish(2090): Emulator without GPU emulation detected.
01-06 11:39:36.794: I/Choreographer(2090): Skipped 80 frames!  The application may be doing too much work on its main thread.

Edit : I think above log is not related to problem specially " error opening trace file:" it comes every time when I run any application.

Était-ce utile?

La solution

Have you checked if this font's fault? I have similar issue with MyriadPro-Regular.otf and other fonts were working there fine.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top