如何在附属程序集中引用字体资源?

发布于 2024-09-11 02:09:05 字数 515 浏览 5 评论 0原文

我有一个本地化的 WPF 应用程序,我需要为每个区域设置嵌入一种字体。我在项目中添加了一种字体,并将其“构建操作”设置为“资源”。如果我从 .csproj 中删除 en-US (这消除了卫星程序集的创建),则字体将作为资源编译到项目程序集中。然后我可以通过以下方式添加字体:

<Button Content="My Button" FontFamily="Fonts/#Frutiger LT 87 ExtraBlackCn" />

这非常有效。如果我将 en-US 添加回我的 .csproj 中,字体就会添加到本地化的卫星程序集中。但

<Button x:Uid="Button1" Content="My Button" FontFamily="Fonts/#Frutiger LT 87 ExtraBlackCn" />

不再有效。

我应该如何引用本地化字体?

I have a localised WPF application and I need to embed a font for each locale. I have a font added into my project and it's Build Action is set to Resource. If I remove the <UICulture>en-US</UICulture> from my .csproj (which eliminates the creation of the satellite assemblies) the font is compiled as a resource into the project assembly. I can then add the font by:

<Button Content="My Button" FontFamily="Fonts/#Frutiger LT 87 ExtraBlackCn" />

This works perfectly. If I add en-US back into my .csproj the font gets added to the localised satelite assembly. But

<Button x:Uid="Button1" Content="My Button" FontFamily="Fonts/#Frutiger LT 87 ExtraBlackCn" />

no longer works.

How should I be referencing the localised font?

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

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

发布评论

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

评论(1

调妓 2024-09-18 02:09:05

虽然这并不能直接回答您的问题,但 MSDN 页面上的 WPF 全球化和本地化概述< /a> 似乎建议您:

创建自定义复合字体,以便更好地控制用于不同语言的字体。

这个想法是您使用单一的“复合”字体,其中包含您可能想要使用的所有语言的字体。有关复合字体(包括示例)的详细信息,请参阅 MSDN 上的 FontFamily 文档

While this does not directly answer your question, the MSDN page on WPF Globalization and Localization Overview seems to recommends that you:

Create a customized composite font to obtain better control of fonts that are used for different languages.

The idea is that you use a single, "composite", font for that contains the fonts for all languages that you might want to use. For more information on Composite Fonts (including examples), see the FontFamily Documentation on MSDN.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文