1
我正在生成HTML頁面運行時,我已將我的字體文件放在資產文件夾中。 「MyriadProRegular.otf」如何在HTML中使用自定義字體?
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>";
並加載像這樣。
WebView mWebview = new WebView(this);
mWebview.loadDataWithBaseURL(null, mHTML, "text/html","utf-8", null);
HTML not loding fonts。
我也試圖與
body { font-size: 100%; font-family: 'MyriadProRegular'; src:url('MyriadProRegular.otf'); }
而且
mWebview.loadDataWithBaseURL("file:///android_asset/", mHTML, "text/html","utf-8", null);
但它仍然不加載,沒有得到什麼,我缺少什麼?
編輯:
我得到以下日誌,只有這五行。
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.
編輯:我覺得上面的日誌是不相關的問題,特別是「錯誤打開跟蹤文件:」當我運行任何應用程序在每年的時間。