WPF中的嵌入字体不起作用

我有一个WPF应用程序,我使用字体“Segoe UI Symbol”中的图标。 但是当部署到Windows 7时,我意识到图标丢失了,因为在Windows 8中更新了字体。

我尝试按照这些说明将字体嵌入WPF应用程序作为资源: http : //msdn.microsoft.com/en-us/library/ms753303.aspx但它不起作用。

最初我有:

 

在Windows 8计算机上运行正常。 然后我将seguisym.ttf添加到目录“_Resources”,然后使用:

  

这不适用于Windows 8或Windows 7! 我为BuildAction尝试了不同的设置:资源,嵌入式资源和内容,但它们都不起作用。

我终于找到了一种方法来使用更新版本的“Segoe UI Symbol”,即使安装了旧版本(即在Windows 7上)。 此方法也适用于ClickOnce安装,不需要引导。

我猜这个问题是由与Windows中已经加载的字体的名称冲突引起的。 所以我重新命名了新版本以避免冲突。 有用。

 1) Download utility program Typograf from this link: http://www.neuber.com/typograph/ 2) Open directory where you have a copy of your font file 3) Click on font in list 4) Click Properties button in bar 5) Click Rename button, specify a new name (I chose "SegoeDynamic") and select where to save the new file 6) Add the new font file to your Visual Studio project directory (my directory is "/_Resources") 7) Use relative path or root path as you wish when referencing the font dynamically   

请注意,“Segoe UI Symbol”在多个版本中发布,每个版本添加更多符号。 我至少发现了以下内容:

Windows 7:5.01(823kb)

Windows 8:5.90(1660kb)

Windows 8.1:6.09(1740kb)

你给出的路径是对于你正在使用TextBlock的控件。如果你想引用项目根文件夹中的字体,你应该使用这个: