- First of all , the font path should be relative to your HTML / CSS file.
So instead:
@font-face { font-family: 'Persian'; src: url('file:///android_asset/fonts/b_yekan.ttf'); }
Use something like this:
@font-face { font-family: 'Persian'; src: url('fonts/b_yekan.ttf'); }
.
/about_us.html:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<style type="text/css">
@font-face { font-family: 'B Homa'; src: url('fonts/BHOMA.TTF');}
@font-face { font-family: 'B Lotus'; src: url('fonts/BLOTUS.TTF');}
@font-face { font-family: 'B Lotus Bold'; src: url('fonts/BLOTUSBD.TTF');}
</style>
</head>
<body>
<p style="font-family:'B Homa';font-size:20px;">B Homa: مخصص</p>
<p style="font-family:'B Lotus';font-size:20px;">B Lotus: مخصص</p>
<p style="font-family:'B Lotus Bold';font-size:20px;">B Lotus Bold: مخصص</p>
</body>
</html>
BHOMA.TTF, BLOTUS.TTF BLOTUSBD.TTF bornaray.com assets/fonts/.
loadToWebView(), Fragment, getActivity().getAssets():
private void loadToWebView() {
AssetManager assetManager = getActivity().getAssets();
try {
InputStream input = assetManager.open("about_us.html");
byte[] buffer = new byte[input.available()];
input.read(buffer);
input.close();
mWebView.loadDataWithBaseURL("file:///android_asset/",
new String(buffer), "text/html", "UTF-8", null);
} catch (IOException e) {
e.printStackTrace();
}
}
:

, .