0

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: enter image description here

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.

Thiago Souza
  • 171
  • 3
  • 12
  • 1
    The RTF format encodes commands using specific character sequences. If you are inserting raw text you will need to escape those characters (eg https://stackoverflow.com/questions/36766994/escape-plain-text-of-different-charsets-to-rtf-formatting) – Jeremy Lakeman Jul 03 '23 at 02:05
  • 2
    General description in here: [How can a Label control display Japanese characters properly when the Font used doesn't support this language?](https://stackoverflow.com/a/51612395/7444103), then go to here: [Some Alt keys changes my RichTextBox font](https://stackoverflow.com/a/51451303/7444103) – Jimi Jul 03 '23 at 02:36
  • @Jimi thank you! Using one of those aproaches, only that unsupported characters will use the fallback font, and the rest of the console looks normal. – Thiago Souza Jul 03 '23 at 16:55

1 Answers1

1

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.

Ceyhun
  • 1,354
  • 2
  • 10
  • 10
Thiago Souza
  • 171
  • 3
  • 12