alin
alin

Reputation: 115

Embedded fonts in c#

I've tried a lot with embedding a font in a wpf app in c#. The font's name is 'Roboto'. The filename is roboto.ttf if that's of use. I've made sure it's compiled in the assembly. So how to apply the font in a TextBlock for example?

Upvotes: 3

Views: 1464

Answers (1)

mrahhal
mrahhal

Reputation: 3497

You can apply your font in an element like this:

<TextBlock FontFamily="./#Roboto" ... />

Or you can specify the font's filename like this;

<TextBlock FontFamily="./roboto.ttf" ... />

You can also specify "./#Roboto Light" for example if you want the light font if it's embedded too.

Upvotes: 3

Related Questions