I have a TextView and I need to display the following string on it: "Some text". And I want the TextView to use a custom font for this. So I need to get the following output:
I tried the following code:
textView.setText("some <i>text</i>");
final Typeface typeface = Typeface.createFromAsset(getActivity().getAssets(), "customfont-regular.otf");
if (typeface != null)
textView.setTypeface(typeface);
But the result was: , so the Italic is actually fake, generated by the system. Then I tried the following:
textView.setText("some <i>text</i>");
final Typeface typeface = Typeface.createFromAsset(getActivity().getAssets(), "customfont-regular.otf");
if (typeface != null)
textView.setTypeface(typeface, Typeface.NORMAL);
final Typeface typefaceItalic = Typeface.createFromAsset(getActivity().getAssets(), "customfont-italic.otf");
if (typefaceItalic != null)
textView.setTypeface(typefaceItalic, Typeface.ITALIC);
But the output was all-italic!
So how can I combine custom typefaces for regular and italic in a single TextView?