一些Alt键更改了我的RichTextBox字体 [英] Some Alt keys changes my RichTextBox font
问题描述
我正在Windows窗体中创建一些印地语键入应用程序。
I am creating some Hindi typing application in Windows Forms.
我使用了 KrutiDev010
字体,一些字符的一些替代键控制代码,但是如果我输入其他替代键控制代码,例如 Alt + 0261
, Alt + 025896
然后分别打印一个宪章±
,攨
,然后将我的文本框字体更改为 Arial。
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".
如何仅阻止那些更改RichTextBox字体的替代键控制代码?
How to block only those alt key control codes which change my RichTextBox fonts?
推荐答案
这是默认行为。
RichTextBox
自动找到一个备用字体来表示当前指定的字体无法处理的那些字符。
如果没有其他指示,它将更改 Font
This is the default behaviour.
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.
请阅读此内容,以了解与 RichTextBox
祖先相同的默认行为( RichEdit
控件( WinForms
控件从中派生):不要更改字体,该死!
Read this rant about the same default behaviour of the RichTextBox
ancestor (the RichEdit
control, from which the WinForms
control derives): Don't change the font, dammit!
有方法可以更改此行为。至少以 RichTextBox
控件报告当前字体和字体选择的方式。上一篇博客文章中的 C ++
代码是一个。
There are means to change this behaviour. 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.
关于此主题的StackOverflow问题/答案:
如何使用东亚文本将Win32 RichEdit强制回退到SimSun 。
A StackOverflow Question/Answer on the subject:
How to force a Win32 RichEdit fallback to SimSun with East Asian text.
但是您不需要 fallback 到 C ++
。
请参阅 RichTextBox.LanguageOption 和< a href = https://docs.microsoft.com/zh-cn/dotnet/api/system.windows.forms.richtextboxlanguageoptions?view=netframework-4.7.2#System _Windows_Forms_RichTextBoxLanguageOptions_AutoFontSizeAdjust rel = nofollow noreferrer> RichTextBoxLanguageOptions 标志。
But you don't need to fallback to C++
for this.
See the RichTextBox.LanguageOption and the RichTextBoxLanguageOptions flags.
您可以在之后插入此代码行
进程: Form
构造函数中的InitializeComponent()
You can insert this line of code right after the InitializeComponent()
proc in your Form
constructor:
richTextBox1.LanguageOption = RichTextBoxLanguageOptions.DualFont;
或
richTextBox1.LanguageOption = RichTextBoxLanguageOptions.DualFont | RichTextBoxLanguageOptions.UIFonts;
有些许区别。请参阅参考文档,并在您的特定上下文中测试此行为。
如果插入当前字体无法处理的Unicode符号,则总是可以进行回退,但是 RichTextBox
UI不会更改 Font
,甚至不会更改 SelectionFont
。
和 Clipboard.SetText(), Clipboard.GetText()将照常工作。
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屋!