Quantcast
Channel: JPHellemons
Viewing all articles
Browse latest Browse all 132

Use FontAwesome in Xamarin Forms

$
0
0

I followed this guide: https://medium.com/@tsjdevapps/use-fontawesome-in-a-xamarin-forms-app-2edf25311db4

Where you manually have to edit a XML file to get it to work in iOS and add the font for each platform you want to support. So for FontAwesome (regular, bold, brands) and UWP, Android, iOS. That gives 9 files!

which eventually works:

<Label Text="&#xf0f3;" FontFamily="{StaticResource FontAwesomeRegular}" FontSize="Large" TextColor="Red" />
         <Label Text="&#xf26e;" FontFamily="{StaticResource FontAwesomeSolid}" FontSize="Large" TextColor="Red" />
         <Label Text="&#xf26e;" FontFamily="{StaticResource FontAwesomeBrands}" FontSize="Large" TextColor="Red" />


BUT: If you would just update to Xamarin Forms 4.5.0.530 or higher

you can add a line for a font. (so 3 times something like this for FontAwesome)

[assembly: ExportFont("FontAwesome5Regular400.otf", Alias = "FontAwesome")]

to your app.xaml.cs

and use

<Label Text="&#xf0f3;" FontFamily="FontAwesome" FontSize="Large" TextColor="Green" />

in your mainpage.xaml


good luck!


Viewing all articles
Browse latest Browse all 132

Trending Articles