Custom Font not working

jrahma 111 Reputation points
2021-03-04T21:05:06.6+00:00

Hi,

i am trying to use Font Awsome as the custom font in my app.

I added the icon and set it to EmbeddedResources and added:

[assembly: ExportFont("FontAwesomeRegular.otf", Alias = "FontRegular")]

but I am not getting the icon shown and it just shows the default question mark instead..

<Image>
<Image.Source>
    <FontImageSource Grid.Column="4" FontFamily="FontRegular" Color="Black" Glyph="&#xf004;"/>
</Image.Source>
</Image>

Kindly help..

Thanks,
Jassim

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,294 questions
0 comments No comments
{count} votes

7 answers

Sort by: Most helpful
  1. StephenH 86 Reputation points
    2021-03-08T23:53:12.917+00:00

    Iv'e had this problem for over a week and it got closed in my previous report with no solution other than to come here ......

    0 comments No comments

  2. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,751 Reputation points
    2021-03-09T03:13:59.037+00:00

    @StephenH

    Based on your sample , I made a simple test .

       <StackLayout>  
               <StackLayout BackgroundColor="Red" Orientation="Horizontal">  
         
                   <Image>  
                       <Image.Source>  
                           <FontImageSource FontFamily="FA5Solid900" Color="Black" Glyph="{x:Static FA:FontAwesomeIcons.Ankh}"/>  
                       </Image.Source>  
                   </Image>  
         
                   <Image>  
                       <Image.Source>  
                           <FontImageSource FontFamily="FA5Solid900" Color="Black" Glyph="{x:Static FA:FontAwesomeIcons.AppStore}"/>  
                       </Image.Source>  
                   </Image>  
         
                   <Image>  
                       <Image.Source>  
                           <FontImageSource FontFamily="FA5Solid900" Color="Black" Glyph="&#xf004;"/>  
                       </Image.Source>  
                   </Image>  
         
               </StackLayout>  
         
               <StackLayout  Orientation="Horizontal">  
         
                   <Label  FontFamily="FA5Solid900"  Text ="{x:Static FA:FontAwesomeIcons.Ankh}"  FontSize="30"/>  
         
                   <Label  FontFamily="FA5Solid900"   Text ="{x:Static FA:FontAwesomeIcons.AppStore}"  FontSize="30"/>  
         
                   <Label  FontFamily="FA5Solid900"   Text ="&#xf004;"  FontSize="30"/>  
         
               </StackLayout>  
           </StackLayout>  
    

    75510-capture.png

    I found

    • Not all the Unicode sting in FontAwesomeIcons works as expected. (Acorn ,AppStore not work but Ankh work)
    • The default color is light-gray not white, so we don't need to set color on it .
    • Unicode string or XML character escape does not work on ShellContent.Icon , it seems that it only supports existing image file .