英文:
RichTextBox changes font when certain chars are typed in
问题
我正在制作一个用于控制我自己的Rust游戏服务器的程序,但我发现一个问题,不知道为什么会发生。
我有一个控制台窗口(RichTextBox),当输入特定字符时,它会更改字体。
像**¯\_(ツ**这样的字符会改变文本字体,就像下面的截图中所示:
正如您所看到的,就在包含这些奇怪字符的玩家名称之后,字体发生了变化,我不知道该如何修复它。
英文:
I'm making a program to control my own server of the game Rust, but I found a problem that I don't have a clue why it's happening.
I have a console window (RichTextBox) that when certain chars are typed, it changes the font.
Chars like ¯\_(ツ change the text font, like in the screenshot below:
As you can see, right after the player name that contains those weird chars, the font changes and I dont know how to fix it.
答案1
得分: 1
这个问题的解决方法在@Jimi指出后变得相当简单。
由于默认字体中不存在日文字符,它会回退到Arial字体(支持这些字符),之后不会再切回默认字体。
为了让仅不支持的字符以Arial字体显示,我使用了下面的代码:
richTextBox1.LanguageOption = RichTextBoxLanguageOptions.DualFont|RichTextBoxLanguageOptions.UIFonts;
在我的InitializeComponent();
调用之后。
英文:
The fix for this problem was quite simple to find after @Jimi pointed me out.
Since the japanese chars doesn't exist on the default font, it will fallback to the arial font (which supports the chars) and after that it will not go back to the default font.
To make only the unsupported chars appear in arial font, I've used the code below:
richTextBox1.LanguageOption = RichTextBoxLanguageOptions.DualFont|RichTextBoxLanguageOptions.UIFonts;
Right after my InitializeComponent();
call.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论