TypefaceSpan with custom font in Assets folder

gianis6gianis6 ITMember
edited November 2016 in Xamarin.Android

As the title states, I need to use a TypefaceSpan object with a custom font present inside the Assets but I can't find the correct way to achieve this.
The file of the font is "HelveticaNeueLTCom-BdCn.ttf"

These are my two attempt which did not work for me:

var textViewTitle = new TextView(Context); var span = new SpannableString("MyLongTitle"); span.SetSpan(new TypefaceSpan("HelveticaNeueLTCom-BdCn.ttf"), 0, 5, SpanTypes.ExclusiveExclusive); textViewTitle.TextFormatted = span;

var textViewTitle = new TextView(Context); var span = new SpannableString("MyLongTitle"); span.SetSpan(new Typeface(Typeface.CreateFromAsset(Context.Assets, "fonts/HelveticaNeueLTCom-BdCn.ttf")), 0, 5, SpanTypes.ExclusiveExclusive); textViewTitle.TextFormatted = span;

Anyone has some hints or advice?

Best Answer

Answers

Sign In or Register to comment.