一些 Alt 键改变了我的 RichTextBox 字体 [英] Some Alt keys changes my RichTextBox font
问题描述
我正在 Windows 窗体中创建一些印地语打字应用程序.
我使用了 KrutiDev010
字体,有些字符有一些 alt 键控制代码,但是如果我输入一些其他的 alt 键控制代码,例如 Alt+0261
,Alt+025896
然后它分别打印一个宪章 ą
, 攨
并将我的文本框字体更改为Arial".
如何只阻止那些改变我的 RichTextBox 字体的 alt 键控制代码?
这是默认行为.RichTextBox
会自动寻找一种后备字体来表示当前指定的 Font 无法处理的那些字符.
如果没有其他指示,它会使用回退字体更改 Font
选择.
阅读这篇关于 RichTextBox
祖先(RichEdit
控件,WinForms
控件派生自该控件)的相同默认行为的咆哮:不要改变字体,该死的!>
有办法改变这种行为.至少在 RichTextBox
控件报告当前字体和字体选择的方式上.上一篇博文中的 C++
代码就是一个.
关于该主题的 StackOverflow 问题/答案:
如何强制使用 Win32 RichEdit回退到带有东亚文本的 SimSun.
但是您不需要为此回退到C++
.
请参阅 RichTextBox.LanguageOption 和RichTextBoxLanguageOptions 标志.
您可以在 Form
构造函数中的 InitializeComponent()
过程之后立即插入这行代码:
richTextBox1.LanguageOption = RichTextBoxLanguageOptions.DualFont;
或
richTextBox1.LanguageOption = RichTextBoxLanguageOptions.DualFont |RichTextBoxLanguageOptions.UIFonts;
略有不同.请参阅参考文档并在您的特定上下文中测试此行为.
如果您插入当前字体未处理的 Unicode 符号,则始终可以进行回退,但是 RichTextBox
UI 不会更改 Font
,甚至不会更改 选择字体
.
和 Clipboard.SetText(), Clipboard.GetText()将照常工作.
I am creating some Hindi typing application in Windows Forms.
I have used KrutiDev010
Font, there are some alt key control codes for some characters but if I enter some other alt key control codes, like Alt+0261
, Alt+025896
then it prints a charters ą
, 攨
respectively and changes my textbox font to "Arial".
How to block only those alt key control codes which change my RichTextBox fonts?
This is the default behavior.
RichTextBox
automatically finds a fallback font to represent those characters that the currently specified Font can't handle.
If not otherwise instructed, it changes the Font
selection with the fallback Font.
Read this rant about the same default behavior of the RichTextBox
ancestor (the RichEdit
control, from which the WinForms
control derives): Don't change the font, dammit!
There are means to change this behavior. At least in the way the RichTextBox
control reports the current Font and Font selection. The C++
code in the previous blog post is one.
A StackOverflow Question/Answer on the subject:
How to force a Win32 RichEdit fallback to SimSun with East Asian text.
But you don't need to fallback to C++
for this.
See the RichTextBox.LanguageOption and the RichTextBoxLanguageOptions flags.
You can insert this line of code right after the InitializeComponent()
proc in your Form
constructor:
richTextBox1.LanguageOption = RichTextBoxLanguageOptions.DualFont;
or
richTextBox1.LanguageOption = RichTextBoxLanguageOptions.DualFont |
RichTextBoxLanguageOptions.UIFonts;
There's a slight difference. See the reference Docs and test this behaviour in your specific context.
If you insert an Unicode symbol that is not handled by the current Font, a fallback is always possible, but the RichTextBox
UI will not change the Font
, not even the SelectionFont
.
And Clipboard.SetText(), Clipboard.GetText() will work as usual.
这篇关于一些 Alt 键改变了我的 RichTextBox 字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!