FontAwesome in MAUI

Jassim Al Rahma 1,616 Reputation points
2022-08-20T12:04:03.747+00:00

Hi,

I am trying to use FontAwesome in Maui but it's not working and just showing a question mark.

233131-123abc.png

I have added the files to my project and set the Build to MauiFont

233068-screen-shot-2022-08-20-at-40125-pm.png

and I configured the fonts:

.ConfigureFonts(fonts =>  
{  
	fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");  
	fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");  
    fonts.AddFont("FontAwesomeRegular.ttf", "FontRegular");  
    fonts.AddFont("FontAwesomeBrands.ttf", "FontBrands");  
    fonts.AddFont("FontAwesomeSolid.ttf", "FontSolid");  
});  

then in my XAML:

<Image Grid.Column="1" WidthRequest="40" HeightRequest="40" Margin="5,5,10,5" VerticalOptions="Center">  
<Image.Source>  
    <FontImageSource FontFamily="FontSolid" Glyph="&#xf1e1;" />  
</Image.Source>  
</Image>  
Developer technologies | .NET | .NET MAUI
0 comments No comments
{count} votes

Accepted answer
  1. Yonglun Liu (Shanghai Wicresoft Co,.Ltd.) 50,126 Reputation points Microsoft External Staff
    2022-08-22T03:03:19.657+00:00

    Hello,

    It's caused by you used the wrong suffix.

    You need to change the ttf to otf:

       fonts.AddFont("FontAwesomeRegular.otf", "FontRegular");  
       fonts.AddFont("FontAwesomeBrands.otf", "FontBrands");  
       fonts.AddFont("FontAwesomeSolid.otf", "FontSolid");  
    

    Best Regards,

    Alec Liu.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.