从dll资源使用WPF自定义compositefont

时间:2010-08-26 18:16:19

标签: c# wpf fonts

我有一个自定义复合字体作为库dll中的资源,我想加载但是我无法获得确切的语法。我试过了:

FontFamily font = new FontFamily(
  new Uri("pack://application:,,,/MyLibraryDll"), 
  "./fonts/#My Font from composite font");

哪个没用,所以我尝试用以下字体枚举字体:

ICollection<FontFamily> fonts = Fonts.GetFontFamilies(
   new Uri("pack://application:,,,/MyLibraryDll"), 
   "./fonts/#My Font from composite font");

ICollection<FontFamily> fonts = Fonts.GetFontFamilies(
  new Uri("pack://application:,,,/MyLibraryDll"),
  "./fonts/mycompositefont.compositefont#My Font from composite font");

两者都返回0.我没有找到关于这些的文件 - 有没有人对此有任何好运?

1 个答案:

答案 0 :(得分:2)

根据Packaging Fonts with Applications,正确的语法是:

new FontFamily(new Uri("pack://application:,,,"),
    "MyLibraryDll;Component/Fonts/#My Font from composite font");