WPF 字体 : Why are some characters missing?

标签 wpf fonts textbox

我正在编写一个 WPF 应用程序,而我使用的字体仅在 WPF 中运行时出现问题 - 在其他任何东西(记事本、写字板等)中使用它都可以正常工作。 WPF 的问题在于它有时会回退到另一种字体。 “有时”我的意思是只有字符 [a-zA-Z] 似乎可以正确呈现 - 其他所有内容似乎都呈现为默认的 TextBox 字体。

有谁知道 WPF 对它支持的字体是否有某种限制?它几乎似乎是 WPF 中的错误 - 该字体在其他任何地方都可以正常工作。

我尝试使用的字体是“Scramble”TTF 字体( http://famousfonts.smackbomb.com/fonts/scrabble.php )。

数字和空格应该被视为一个空白的 Scrabble/Scramble 磁贴,但数字本身出现在我正在使用的文本框中。

我正在使用的代码:

<TextBox Text="Testing testing testing" FontFamily="Fonts/#Scramble" />

有没有其他人经历过类似的事情?

任何建议都会摇滚!

谢谢!

最佳答案

来自 MSDN :

Font Fallback

Font fallback refers to the automatic substitution of a font other than the font that is selected by the client application. There are two primary reasons why font fallback is invoked:

  • The font that is specified by the client application does not exist on the system.
  • The font that is specified by the client application does not contain the glyphs that are required to render text.

In WPF, the font fallback mechanism uses the default fallback font family, "Global User Interface", as the substitute font. This font is defined as a composite font, whose file name is "GlobalUserInterface.CompositeFont". For more information about composite fonts, see the Composite Fonts section in this topic.

The WPF font fallback mechanism replaces previous Win32 font substitution technologies.



我的猜测是该字体不支持 Unicode - 字体本身是在 1996 年创建的,并且由于它旨在模拟拼字游戏,我不确定字体作者是否考虑过本地化。

编辑
根据字体文档,字体支持字母,并且任何数字都应该呈现空白图块。空间不渲染瓷砖。

关于WPF 字体 : Why are some characters missing?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/832470/

相关文章:

WPF 网格数据绑定(bind)

wpf - 通过键盘 "Type-Ahead"搜索选择 WPF 列表框中的项目

wpf - 如何更改菜单栏中菜单项的方向/位置

pdf - 当我使用 itext 调用 BaseFont.createFont() 时,如何知道正确的编码?

css - 为什么我在CSS中指定了 'DejaVu Serif'却选择了 'Liberation Mono'?

wpf - TextBox 上的 MinLines 和 MaxLines 不起作用

wpf - WPF 数据绑定(bind)是否会将更改编码到 UI 线程?

css - Font-face 字体在 Firefox 中看起来更粗

jquery - 如何根据在 jquery 文本框中扫描的值在行列表中交换特定行

c# - 获取所选文本在文本框中字符串中的位置