I understand that to use custom fonts in a widget I need to render the font to a bitmap, but how do I set a system typeface programmatically?
android:typeface="serif"
in XML is successful, but I cannot find a way to do this at run time.
I currently have
int fn = fullDate.length();
SpannableString dt = new SpannableString(fullDate);
dt.setSpan(new StyleSpan(Typeface.BOLD), 0, fn, 0);
remoteView.setTextViewText(R.id.dateText, dt);
Which works, but using, for example, Typeface.SERIF, gives The constructor StyleSpan(Typeface) is undefined
The constructor for
StyleSpanthat you’re using takes in a constant defined in Typeface and not one of the fields. The constants available areIf you want to set the typeface to a specific font, you need to use
TextView.setTypeFace()EDIT
This cannot be done for widgets since you only have access to the remote view. Others have circumvented this by passing an image to the remote view. See this question for details:
How to use a custom typeface in a widget?