Home > Software design >  Why does the Glyph not working in `FontIcon`?
Why does the Glyph not working in `FontIcon`?

Time:11-18

I've added FontAwesome 6 to my app and want to use an icon. I have the OTF file in my assets folder here:

Assets/Fonts

I want to change the default symbols (icons) for NavigationViewItems. I added the FontIcon however instead of the icon, I'm seeing just empty box:

empty box

The icon I'm adding is this: https://fontawesome.com/icons/tower-control?s=solid&f=classic

and my code is

<NavigationViewItem Content="Home" Tag="homePageView" x:Name="homeViewItem">
    <NavigationViewItem.Icon>
        <FontIcon FontFamily="Assets/Fonts/Font Awesome 6 Pro-Solid-900.otf#Font Awesome 6 Pro Solid" Glyph="&#xe2a1;" />
    </NavigationViewItem.Icon>
</NavigationViewItem>

Why is the icon not showing up?

CodePudding user response:

I'm not sure but, have you tried fixing the file extension (.ttf to .otf)?

<FontIcon FontFamily="Assets/Fonts/Font Awesome 6 Pro-Solid-900.otf#Font Awesome 6 Pro Solid" Glyph="&#xe2a1;" />

UPDATE

I can confirm that this works:

  1. Download the free version.
  2. Create a "Fonts" folder inside the "Assets" folder.
  3. Copy the "Font Awesome 6 Free-Solid-900.otf" file in the "Fonts" folder.
  4. Use this code below.
<FontIcon FontFamily="Assets/Fonts/Font Awesome 6 Free-Solid-900.otf#Font Awesome 6 Free Solid" Glyph="&#xf015;" />

Note that I'm using Glyph="&#xf015;"(link) since I couldn't find &#xe2a1; in the free version.

CodePudding user response:

As the FA glyphs were very inconsistent, some glyphs working, some versions of some weights working etc. I've decided to leave Font Awesome and switch to PNG based icons using ImageIcon.

  • Related