Custom fonts formatting, the simple way
The problem: given HTML formatted input, display the normal text with a custom font and special tags with another custom font.
To apply custom fonts Calligraphy is my preferred helper library.
It works great to apply one font to one TextView. It has CalligraphyTypefaceSpan to apply fonts to a range of characters. It has all the tools you need, you just need to know how to use them.
If you happen to know the position of the text you want to highlight, just follow the example Calligraphy provides:
Having the input in HTML means you have to locate the formatting, get the position of the characters you need to highlight, remove the formatting, adjust the position, apply spans to the characters.
Doable, but terribly inefficient. Much better to do piggy back on the standard android HTML parsing and just adjust the parts you want.
StyleSpan formats the font, With a custom font it’s creating fake bold and fake italic characters from the regular characters. If kept, it would apply extra weight to your already bold font. It must go and be replaced by CalligraphyTypefaceSpan.