Search code examples
xamarinfontsxamarin.androidxamarin.iosfont-awesome

How to use Font Awesome in Xamarin.iOS?


I am trying to use Font Awesome Icons in my Xamarin.iOS project.

In my Xamarin.Android project it was pretty simple:

  1. I downloaded the Font Awesome WebKit from here
  2. I copied the .ttf-Files of the fonts I want to use in my Assets folder

enter image description here

  1. I create a new Typeface for my TextView with the font and use the unicode of the icon

Code:

var myIcon = new TextView(Context);
var regularFont = Typeface.CreateFromAsset(Context.Assets, "fonts/fa-regular-400.ttf");
myIcon.SetTypeface(regularFont, TypefaceStyle.Normal);
myIcon.Text = "\uf007";

enter image description here

I can change TextColor, BackgroundColor, etc. like a normal text.

My problem is, I can't figure out, how to use Font Awesome in my Xamarin.iOS project. Most tutorials and How-Tos are directed to Xamarin.Forms. I tried to merge many of these approaches, but it failed.

The only approach I found is to draw the .svg-Files with SkiaSharp, but that is no option for my use case.


Solution

  • SushiHangovers comment leads me to the solution for my problem.

    FontAwesome Pro and xamarin.ios only one font can be active

    It was not possible to use 3 Font Awesome fonts at the same time in the Designer, but it works when they are used during runtime via code.