Xamarin FontAwesome 图标被视为内部带有 x 的正方形

Xamarin FontAwesome icons seen as squares with an x inside

看完James Montemagno video guide on fonts in Xamarin, I'm having an issue with displaying the icons either in the tab view or in a button. The Intellisense works and it recognizes all the fonts within the FontAwesomeIcons.cs file downloaded from Mathew's github but displays them as an X withing a square。找不到任何有效的解决方案。一切都是最新的。

assemblyinfo.cs:

using Xamarin.Forms.Xaml;

[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
[assembly: ExportFont("Font Awesome 5 Brands-Regular-400", Alias = "FAB")]
[assembly: ExportFont("Font Awesome 5 Free-Regular-400", Alias = "FAR")]
[assembly: ExportFont("Font Awesome 5 Free-Solid-900", Alias = "FAS")]

AppShell:

<Shell.Resources>
   <ResourceDictionary>
      <Style TargetType="ShellContent" x:Key="PricingPage">
                <Setter Property="Icon">
                    <Setter.Value>
                        <FontImageSource FontFamily="FAS" Glyph="{x:Static fontAwesome:FontAwesomeIcons.BalanceScale}"/>
                    </Setter.Value>
                </Setter>
       </Style>
   </ResourceDictionary>
</Shell.Resources>
<TabBar>
        <Tab Title="PricingPage" Style="{StaticResource PricingPage}" >
            <ShellContent Title="PricingPage"   Route="PricingPage" ContentTemplate="{DataTemplate local:ProductPricing}" />
            <ShellContent Title="ExistingProductPricing" IsVisible="False" Route="ExistingProductPricing" Shell.FlyoutBehavior="Disabled" ContentTemplate="{DataTemplate local:ExistingProductPricing}" /> 
        </Tab>
 </TabBar>

名称空间有效的页面中的按钮:

<Button
    Text="{x:Static fontAwesome:FontAwesomeIcons.CheckCircle}"
    FontFamily="FAS"/>

在 android 模拟器中可以看到 X,在我的 phone 上它只是一个空白方块,如果重要的话。

如果还有什么需要我再补充。预先感谢所有帮助

我认为缺少的是您应该在 ExportFont:

中包含文件扩展名
using Xamarin.Forms.Xaml;

[assembly: XamlCompilation(XamlCompilationOptions.Compile)]
[assembly: ExportFont("Font Awesome 5 Brands-Regular-400.ttf", Alias = "FAB")]
[assembly: ExportFont("Font Awesome 5 Free-Regular-400.ttf", Alias = "FAR")]
[assembly: ExportFont("Font Awesome 5 Free-Solid-900.tff", Alias = "FAS")]

更多详情