wpf embedded font not shown while running

1.6k Views Asked by At

I embedded Google's Material Design icon font into my WPF project by adding it into project resources.

The font displayed correctly in Visual Studio designer but showed only tofus (something like ) while running.

What am I doing wrong?

Here's what in App.xaml code:

<Application.Resources>
    <FontFamily x:Key="MaterialIcon">/ExampleProject;component/Resources/#Material Icons</FontFamily>
</Application.Resources>

And here's how I declared the button:

<Button x:Name="ExampleButton" Content="&#xE0C3;" FontFamily="{DynamicResource MaterialIcon}"/>

Screenshot:

Screentshot of designer and program

Thanks!

1

There are 1 best solutions below

0
Igor Damiani On

Mmmmmmmm, try to see this post: How to include external font in WPF application without installing it.

I think that the Uri used for specify the font path is not correct. In this case, you get a different behavior between design-time and runtime.