Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Html.fromHtml to set custom Typeface

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?

like image 957
Philipp Redeker Avatar asked Nov 30 '10 13:11

Philipp Redeker


People also ask

How do you add a font family in HTML?

To change the text font family in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property font-family. HTML5 do not support the <font> tag, so the CSS style is used to add font size.

What is typeface in HTML?

The <font> tag in HTML plays an important role in the web page to create an attractive and readable web page. The font tag is used to change the color, size, and style of a text. The base font tag is used to set all the text to the same size, color and face. Syntax: <font attribute = "value"> Content </font>


1 Answers

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".

like image 195
quietmint Avatar answered Oct 02 '22 12:10

quietmint