1

我正在生成 HTML 页面运行时,我已将字体文件放在 assets 文件夹中。“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>";

并像这样加载。

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

HTML 不加载字体。

我也试过

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.

编辑:我认为上面的日志与问题无关,特别是“打开跟踪文件时出错:”每次运行任何应用程序时都会出现。

4

1 回答 1

0

你检查过这个字体是否有问题吗?MyriadPro-Regular.otf 我有类似的问题,其他字体在那里工作正常。

于 2013-01-08T10:49:24.823 回答