且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

显示亚洲字符(使用Unicode):与使用ExtTextOut相比,在RichEdit控件中显示时,字符间距有所不同

更新时间:2023-11-15 17:05:58

我不知道答案,但有几件事情值得怀疑:

I don't know the answer, but there are several things to suspect:

  • 丰富的编辑控件有多种版本.也许您使用的是旧版,但没有所有最新的版式改进.
  • 有许多样式和标志会影响丰富的editcontrol的行为,因此您可能想研究设置了哪些样式和它们做了什么.例如,查看 EM_GETEDITSTYLE .
  • 许多亚洲字体在Windows上有两个版本.一种针对水平布局进行了优化,另一种针对垂直布局进行了优化.后者通常具有相同的名称,但在其前面加上@.也许您在Rich Edit控件中使用的是错误的.
  • There are several versions of the rich edit control. Perhaps you're using an older one that doesn't have all the latest typographic improvements.
  • There are many styles and flags that affect the behavior of a rich editcontrol, so you might want to explore which ones are set and what they do. For example, look at EM_GETEDITSTYLE.
  • Many Asian fonts come in two versions on Windows. One is optimized for horizontal layout, and the other for vertical layout. That latter usually has the same name, but has @ prepended to it. Perhaps you are using the wrong one in the rich edit control.

更新:通过弄乱写字板,我能够在丰富的编辑控件中重现文本拥挤的问题.

UPDATE: By messing around with Wordpad, I was able to reproduce the problem with the crowded text in the rich edit control.

  1. 在Windows 7的Wordpad中打开一个新文档.请注意,所选字体为Calibri.
  2. 将示例文本粘贴到文档中.
  3. 文本显示正确,但是Wordpad将字体更改为SimSun.
  4. 选择文本并将字体更改回Calibri或Arial.

现在,文本将变得人满为患,与您的示例非常相似.因此,看来根本的问题在于字体链接和回退. ExtTextOut可能正在为脚本自动选择适当的字体.您面临的挑战是弄清楚如何为脚本识别正确的字体并在丰富的编辑控件中设置该字体.

The text will now be overcrowded, very similar to your example. Thus it appears the fundamental problem is with font linking and fallback. ExtTextOut is probably selecting an appropriate font for the script automatically. Your challenge is to figure out how to identify the right font for the script and set that font in the rich edit control.