Reputation: 59
I'm having difficulty creating a form with Font Awesome text. Everything works fine when I'm doing it in .xaml file, like this:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage
x:Name="contentPage"
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="myappname.Main">
<Label Text=""
FontFamily="Font Awesome 5 Free-Solid-900.otf#Regular"
FontSize="40" />
</ContentPage>
The result is:
Assets catalog:
I'm not creating my app for iOS so I haven't added any additional configuration, i.e. configuring ResourceDictionary. This is what I've tried in Main.xaml.cs (I'll show three ways of doing it because I'm not sure how exactly it should work):
protected override async void OnAppearing()
{
Label newLabel = new Label()
{
Text = "",
FontFamily = "Font Awesome 5 Free-Solid-900.otf#Regular",
FontSize = 40
};
contentPage.Content = newLabel;
}
protected override async void OnAppearing()
{
Label newLabel = new Label()
{
Text = "",
FontFamily = "Font Awesome 5 Free-Solid-900.otf#Font Awesome 5 Free-Solid-900.otf",
FontSize = 40
};
contentPage.Content = newLabel;
}
protected override async void OnAppearing()
{
Label newLabel = new Label()
{
Text = "",
FontFamily = "Font Awesome 5 Free-Solid-900.otf#Font Awesome 5 Free-Solid-900",
FontSize = 40
};
contentPage.Content = newLabel;
}
The result in every of them is:
What am I doing wrong?
Upvotes: 0
Views: 389
Reputation: 178
Try using \u instead of &#x
so it should look like this:
Text = "\uf00c",
Upvotes: 1