如何以正确的字体呈现unicode字符? (C#/的WinForms)

时间:2022-09-06 20:16:38

My application correctly handles different kind of character sets, but only internally - when it comes to displaying text in standard WinForms labels und textboxes, it seems to have problems with chinese characters.

我的应用程序正确处理不同类型的字符集,但只在内部 - 当在标准的WinForms标签和文本框中显示文本时,它似乎有中文字符的问题。

The problem seems to be the font used (Tahoma), because when I copy&paste the text, or view it in the debugger, it is displayed correctly. Also when I set MS Mincho as the font to be used, the characters on the screen look OK.

问题似乎是使用的字体(Tahoma),因为当我复制和粘贴文本,或在调试器中查看它时,它会正确显示。此外,当我将MS Mincho设置为要使用的字体时,屏幕上的字符看起来还可以。

Of course, I don't want to use MS Mincho in the entire application. Do I have to switch the font depending on the characters displayed, or is there a better way I have missed?

当然,我不想在整个应用程序中使用MS Mincho。我是否必须根据显示的字符切换字体,还是有更好的方法我错过了?

2 个解决方案

#1


4  

UniScribe, which was introduced in Windows 2000, is supposed to handle this transparently, meaning that it will automatically use a different font (such as Mincho) for characters that aren't present in the font you've selected. This is why it looks correct in the debugger, even though the font used in the debugger doesn't contain Chinese characters. Perhaps you are doing something that disables UniScribe, or is problematic in some other way. Perhaps if you could paste some code it would be easier to identify the problem.

在Windows 2000中引入的UniScribe应该透明地处理它,这意味着它将自动使用不同的字体(例如Mincho)用于您选择的字体中不存在的字符。这就是为什么它在调试器中看起来正确,即使调试器中使用的字体不包含中文字符。也许你正在做一些禁用UniScribe的东西,或者以某种其他方式存在问题。也许如果您可以粘贴一些代码,则更容易识别问题。

#2


0  

All fonts don't have data for all the glyphs that can be expressed in unicode. You´ll have to locate a suitable font which has the subset you want.

所有字体都没有可以用unicode表示的所有字形的数据。您必须找到具有所需子集的合适字体。

edit: Just to clarify, there are fonts which cover the full unicode range, but the one you´re using now isn´t one of them.

编辑:只是为了澄清,有些字体覆盖了整个unicode范围,但你现在使用的字体不是其中之一。

#1


4  

UniScribe, which was introduced in Windows 2000, is supposed to handle this transparently, meaning that it will automatically use a different font (such as Mincho) for characters that aren't present in the font you've selected. This is why it looks correct in the debugger, even though the font used in the debugger doesn't contain Chinese characters. Perhaps you are doing something that disables UniScribe, or is problematic in some other way. Perhaps if you could paste some code it would be easier to identify the problem.

在Windows 2000中引入的UniScribe应该透明地处理它,这意味着它将自动使用不同的字体(例如Mincho)用于您选择的字体中不存在的字符。这就是为什么它在调试器中看起来正确,即使调试器中使用的字体不包含中文字符。也许你正在做一些禁用UniScribe的东西,或者以某种其他方式存在问题。也许如果您可以粘贴一些代码,则更容易识别问题。

#2


0  

All fonts don't have data for all the glyphs that can be expressed in unicode. You´ll have to locate a suitable font which has the subset you want.

所有字体都没有可以用unicode表示的所有字形的数据。您必须找到具有所需子集的合适字体。

edit: Just to clarify, there are fonts which cover the full unicode range, but the one you´re using now isn´t one of them.

编辑:只是为了澄清,有些字体覆盖了整个unicode范围,但你现在使用的字体不是其中之一。