I am needing to embed a regular, but special font within normal fonts such as New Times Roman etc.
This needs to be done within a webview HTML.
On the PC, I can successfully embed these together and a browser show them correctly.
I've made this work well with the
I finally figured this out and for those of you who are struggling with this, as I have, I am posting this simple solution that explicitly shows how to do this.
B4X:
<!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>
<style type="text/css">
@font-face {
font-family: MyFont;
src: url("file:///android_asset/specialfont.ttf")
}
body {
font-family: MyFont;
font-size: medium;
text-align: justify;
}
</style>
</head>
<body>
This is the text in the special font.
</body>
</html>
The above HTML code works well. You can store the HTML as a file in the assets folder and load it like this:
Just a head's up for anyone else finding this thread:
If you're running this in the rapid debugger, you may not see the new font in the webview. I messed with this for quite a while until I accidentally found out I had to compile in release mode to get it to display right.