使用 dll 资源中的 WPF 自定义复合字体

发布于 2024-09-16 07:25:46 字数 686 浏览 3 评论 0原文

我有一个自定义复合字体作为库 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。我找不到关于这些的文档 - 有人对此有任何运气吗?

I have a custom composite font as a resource in a library dll that I'd like to load but I'm unable to get the exact syntax. I tried:

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

Which didn't work so I tried enumerating the fonts with:

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

And

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

And both return a count of 0. There is no documentation on these that I can find -- has anyone had any luck with this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

冬天旳寂寞 2024-09-23 07:25:46

根据将字体与应用程序打包,正确的语法是:

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

According to Packaging Fonts with Applications, the correct syntax is:

new FontFamily(new Uri("pack://application:,,,"),
    "MyLibraryDll;Component/Fonts/#My Font from composite font");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文