0 votes
ago by (120 points)

Chinese characters are not rendering correctly with TerminalControl in C# winForm

There is a problem with the display of Chinese characters. The words are all contracted together. It seems that each Chinese character only occupies half the width.

Rebex.Terminal.Control, Version=7.0.9048.0

mycode:

// create a new Ssh client object
var ssh = new Rebex.Net.Ssh();
_ssh.Encoding = Rebex.EncodingTools.UTF8;
// connect to the SSH server
_ssh.Connect(SqLiteUtil.LinuxSetting.Host, int.Parse(SqLiteUtil.LinuxSetting.Port));
// login to the SSH server
_ssh.Login(SqLiteUtil.LinuxSetting.Sa, SqLiteUtil.LinuxSetting.Passwd);
//
ssh.RunCommand("export TERM=xterm");

//set utf8
terminalControl.Options.Encoding = Rebex.EncodingTools.UTF8;
terminalControl.Options.FunctionKeysMode = FunctionKeysMode.Linux;

// 1.changes the default selection mode to block mode
// terminalControl.SelectionMode = TextSelectionMode.Block;
// 2.specifies whether the right mouse button pastes text from clipboard
// terminalControl.MousePasteEnabled = true;
// 3.specifies whether selection a text using a mouse automatically copies the selected text into clipboard
// terminalControl.MouseSelectionCopiesToClipboard = true;
//set font
terminalControl.AutoAdjustTerminalSize = true;
terminalControl.Palette = TerminalPalette.Dos;

//terminalControl.TerminalFont = TerminalFont.FromDosFont(fontByte);
terminalControl.TerminalFont = new Rebex.TerminalEmulation.TerminalFont(FontUtil.LoadFontFamily(), 12.00f);
terminalControl.Font= new Font(FontUtil.LoadFontFamily(), 12.00f);

//terminalControl.TerminalFont = new Rebex.TerminalEmulation.TerminalFont("Consolas", 12.00f);
Size cellSize = terminalControl.CellSize;
// bind the connected and authenticated Ssh instance to the terminal console

terminalControl.Bind(_ssh);
terminalControl.Screen.WriteLine($"{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} Session connected.");

Please log in or register to answer this question.

...