c# – Embedded font with composite name is not displayed

Question:

I am embedding some fonts in my WPF app but some are not displayed.

Fonts are in the /Fonts folder at the root of the application and their properties are set to Resource.

I use it like this:

<TextBlock FontFamily="pack://application:,,,/Fonts/#Pericles"   />

<TextBlock FontFamily="pack://application:,,,/Fonts/#Pericles Light"   />

In this case, " #Pericles " whose name is simple, displays normally. " #Pericles Light " which has a composite name, does not display. Although several examples I've encountered suggest this way, I believe there must be some escape character for spaces in the font name. Will be?

Answer:

One solution is to add the font file name:

<TextBlock FontFamily="pack://application:,,,/Fonts/PERICL.TTF#Pericles Light"   />
Scroll to Top