如何用东亚文本将Win32 RichEdit强制回退到SimSun? [英] How to force a Win32 RichEdit fallback to SimSun with East Asian text?

查看:95
本文介绍了如何用东亚文本将Win32 RichEdit强制回退到SimSun?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Window注册表中设置了链接到SimSun的字体.
当我将该字体应用于Richedit控件时,它具有以下行为:

I set the font linking to SimSun for my fonts at Window registry.
When I apply that font to my richedit control, it have below behavior:

  • 首先,它显示SimSun-好的
  • 当我添加不是CKJ unicode的文本,然后在CKJ中添加更多文本时,所选的字体窗口是Microsoft Ya Hei而不是SimSun

这是屏幕截图:

字体是:

  • 阿哥":SimSun
  • ◎":Segoe UI符号
  • "[āgē]đạica" Arial
  • 对兄长的称呼." Microsft Ya Hei

在这种情况下,如何强制窗口选择SimSun而不是Microsft Ya Hei?

How I can force window to choose SimSun instead of Microsft Ya Hei in this case?

编辑
感谢@Cody Gray的完美答案.这是工作代码:

EDIT
Thank @Cody Gray for perfect answer. Here is worked code:

CHARFORMAT2 cf2;

memset(&cf2, 0, sizeof(CHARFORMAT2));
cf2.cbSize = sizeof(CHARFORMAT2);
cf2.dwMask = CFM_FACE | CFM_SIZE | CFM_CHARSET | CFM_LCID;
cf2.lcid = 0x0804;
cf2.yHeight = 280;
cf2.bCharSet = CHINESEBIG5_CHARSET;
wcscpy(cf2.szFaceName, L"SimSun");
SendMessage(rtbhWnd, EM_SETCHARFORMAT, SCF_SELECTION | SCF_ASSOCIATEFONT, (LPARAM)&cf2);

cf2.cbSize = sizeof(CHARFORMAT2);
cf2.dwMask = CFM_FACE | CFM_SIZE | CFM_CHARSET | CFM_LCID;
cf2.lcid = 0x0409;
cf2.yHeight = 220;
cf2.bCharSet = ANSI_CHARSET;
wcscpy(cf2.szFaceName, L"Segoe UI");
SendMessage(rtbhWnd, EM_SETCHARFORMAT, SCF_SELECTION | SCF_ASSOCIATEFONT2, (LPARAM)&cf2);

推荐答案

您可以通过向RichEdit控件发送

You can set the default font for character representations by sending the RichEdit control an EM_SETCHARFORMAT message with the SCF_ASSOCIATEFONT flag.

这涉及填写 CHARFORMAT2结构具有所需字体的特征以及与所需字符表示形式的语言环境相对应的LCID,如文档中所述.

This involves filling in a CHARFORMAT2 structure with the characteristics of the desired font as well as the LCID corresponding to the locale of the desired character representation, as outlined in the documentation.

另请参阅:如何在Rich Edit控件中使用字体绑定

在我看来 Windows 8引入了"Microsoft YaHei"字体作为简体中文脚本的默认UI字体.我认为(但我不确定)SimSun曾经是该脚本的默认字体,因此如果您在某些系统而不是其他系统上看到此行为,则可以对此进行解释.

It looks like to me that Windows 8 introduced the "Microsoft YaHei" font as the default UI font for the Simplified Chinese script. I think (but I'm not certain) that SimSun used to be the default font for this script, so that would explain it if you were seeing this behavior on some systems and not others.

这篇关于如何用东亚文本将Win32 RichEdit强制回退到SimSun?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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