WPF 中的嵌入字体不起作用 [英] Embedded Font in WPF not working

查看:36
本文介绍了WPF 中的嵌入字体不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a WPF application where I use icons from the font "Segoe UI Symbol". But when deploying to Windows 7 I realize the icons are missing because the font is updated in Windows 8.

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

I tried to embed font in WPF application as a resource following these instructions: http://msdn.microsoft.com/en-us/library/ms753303.aspx But it does not work.

最初我有:

<TextBlock FontFamily="Segoe UI Symbol">

在 Windows 8 计算机上运行良好.然后我将 seguisym.ttf 添加到目录_Resources"中,然后使用:

which works fine on Windows 8 computer. Then I added seguisym.ttf to directory "_Resources" and then use:

<TextBlock FontFamily="./_Resources/#Segoe UI Symbol">

这不适用于 Windows 8 或 Windows 7!我为 BuildAction 尝试了不同的设置:Resource、Embedded Resource 和 Content,但它们都不起作用.

This does not work on neither Windows 8 or Windows 7! I tried different settings for BuildAction: Resource, Embedded Resource and Content, but none of them work.

推荐答案

我终于找到了一种方法,即使安装了旧版本(即在 Windows 7 上)也可以使用新版本的Segoe UI Symbol".这种方法也适用于 ClickOnce 安装,不需要引导.

I finally found a way to use the newer version of "Segoe UI Symbol" even when older version is installed (i.e. on Windows 7). This approach works also in ClickOnce installation and requires no bootstrapping.

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

I guess the problem is caused by a name conflict with a font already loaded in Windows. So I renamed the newer version to avoid the conflict. It works.

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

 <TextBlock FontFamily="../_Resources/#SegoeDynamic">
 <TextBlock FontFamily="pack://application:,,,/_Resources/#SegoeDynamic">

请注意Segoe UI Symbol"发布了多个版本,每个版本都添加了更多符号.我至少发现了以下几点:

Please observe that "Segoe UI Symbol" is released in several versions where each version adds more symbols. I have discovered at least the following:

Windows 7:5.01(823kb)

Windows 7: 5.01 ( 823kb)

Windows 8:5.90 (1660kb)

Windows 8: 5.90 (1660kb)

Windows 8.1:6.09 (1740kb)

Windows 8.1: 6.09 (1740kb)

这篇关于WPF 中的嵌入字体不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆