Recently I have a problem when using custom font in my WPF application. I added a custom font in my project using methods described in Packaging Fonts with Applications. It works fine in design mode but when I run the application, it doesn't work and seems to use default font instead. To find the reason:
I downloaded a free font from internet, and used same way to refer it. It worked very well in both situations.
I created a new WPF project, and added the custom font in this new project. It unexpectedly worked. I compared the new project and my problem project, the difference is that I use .Net 3.5 in my old project, and .Net 4.0 in the new project. After I changed the old project to use .Net 4.0, the problem is resolved. However, .Net 4.0 is not allowed in my old project, so that I want to find a solution based on .Net 3.5.
by the way. I tried to build the font file as both content and resource. Also, I tried to use absolute and relevant path. It didn't work.
Looking forward to your help. Thanks very much.
Regards, Yupeng