JetBrains / jediterm

Pure Java Terminal Emulator. Works with SSH and PTY.
GNU Lesser General Public License v3.0
678 stars 168 forks source link

Chinese support bug #242

Open lvhill opened 2 years ago

lvhill commented 2 years ago

When a line of text contains chinese and it's width longer than terminal‘s width, some characters are missing.

e.g.

original line:

<embed 中文 classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" wmode="transparent" src="images/clock.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="100" height="120"></embed>

screenshots of cat command result: bug

cat command result:

<embed 中文 classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" wmode="transparent" src="imes/clock.swf" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="100" height="120"></embed>

screenshots of original line and cat command result differences: diff

So, the characters of ag has lost, I test on windows 10 and deepin linux 20 got the same result. Terminal's font use sarasa-mono-sc-regular.ttf

BeichenDream commented 2 years ago

You can try this pull pull

liunn123 commented 2 years ago

You are a good man.

Xiaobaishushu25 commented 7 months ago

You can try this pull pull

大佬,我照着你的版本修改了,中文会被渲染为只占一个宽度。 image

我觉得原来的bug的存在是否是没有及时添加换行符的原因呢?我将ptysize的col被设置为110,它会输出110个字符(不管中英文)再输出换行字符,但是由于中文字符是英文的两倍宽,导致含有中文的text会得不到及时的换行超出显示区域。

BeichenDream commented 7 months ago

你可以试试这个拉

大佬,我照着你的版本修改了,中文会被渲染为只占一个宽度。 图像

我觉得原来的bug的存在是否是没有及时添加换行符的原因呢?我将ptysize的col被设置为110,它会输出110个字符(不管中英文)再输出换行字符,但是由于中文字符是英文的两倍宽,导致含有中文的text会得不到及时的换行超出显示区域。

你应该补丁没打全,jediterm出现错误的根本原因是因为它只支持等宽字体渲染,它在初始化时会先获取一个字符的宽度与高度,后续所有的字符均按照这个宽度和高度渲染

你可以试试我修改后的版本https://github.com/BeichenDream/jediterm