8

I found this list of HTML-Tags that are (supposedly) supported for HTML.fromHtml to create a Spanned-Text:

http://commonsware.com/blog/Android/2010/05/26/html-tags-supported-by-textview.html

Now is there ANY way to set a custom Typeface with the Font-Tag?

Cristian
  • 198,401
  • 62
  • 356
  • 264
Philipp Redeker
  • 3,848
  • 4
  • 26
  • 34
  • possible duplicate of [set font at runtime, Textview](http://stackoverflow.com/questions/3483110/set-font-at-runtime-textview) – Pentium10 Nov 30 '10 at 14:05
  • 1
    this is not a duplicate of set font at runtime. It's a more specific case. He want's to set the font for only *part* of the text. This is more challenging than simply supplying a typeface from a ttf assett. – mark gamache Oct 07 '15 at 22:29
  • did you get the solution for this problem? – iuq Feb 15 '22 at 16:49

2 Answers2

5

Simply use a <font> tag with a face attribute. This has been possible since at least Android 1.5 (see source code).

The value of the face attribute will be passed to the TypefaceSpan(String) constructor to create the Spannable. For example, use "monospace", "serif", or "sans-serif".

quietmint
  • 13,885
  • 6
  • 48
  • 73
-4

Outdated. See other answers.


No, there's no way to do so. You can take a look at the Html implementation. As you will see, the font tag supports size and color only.

Community
  • 1
  • 1
Cristian
  • 198,401
  • 62
  • 356
  • 264