0
votes

I'm working on a C# WPF project that has the Roboto and Roboto Thin fonts embedded. They font files are in /Resources/Fonts and their build actions are set to 'Resource'. In my App.xaml, I declare the resources:

<FontFamily x:Key="Roboto">/Resources/Fonts/#Roboto</FontFamily>
<FontFamily x:Key="RobotoThin">/Resources/Fonts/#Roboto Thin</FontFamily>

The Roboto font works properly (as do some other embedded fonts), but Roboto Thin doesn't work. I've tried '.../Roboto-Thin.ttf', 'Roboto-Thin', 'Roboto_Thin' and the FontWeight property on the label/textblock but nothing works. When I try to use Roboto Thin on a UIElement, it doesn't seem to recognize it and it falls back to the default font (probably Segoe UI).

What am I doing wrong?

-- edit --

I just tried Roboto Light, but that doesn't work either. It would seem that only the regular fonts work but variations don't.

1

1 Answers

2
votes

Not sure if its what you're looking for, but what works for me is the following:

    <FontFamily x:Key="robotoRegularFont">/resources/Roboto-Regular.ttf#Roboto</FontFamily>
    <FontFamily x:Key="robotoThinFont">/resources/Roboto-Thin.ttf#Roboto Thin</FontFamily>