Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

windows下中文字体乱码 (Chinese font garbled under Windows) utf8 unicode #3862

Open
xueyeyu opened this issue May 1, 2024 · 5 comments

Comments

@xueyeyu
Copy link

xueyeyu commented May 1, 2024

字体,ubuntu mono 、fira code 等字体输入中文时会乱码。monospace mono 字体不会。

相关信息:

(machine translation)
Fonts such as Ubuntu Mono and Fira Code may cause garbled characters when entering Chinese. Monospace Mono font does not work.

Related information:

Geany: Geany 2.0, Chinese (Simplified)_China.936
Geany: GTK 3.24.39, GLib 2.78.0
Geany: OS: Windows 10 22H2

monospace font

monospace_font

fira_code font

fira_code_font

ubuntu mono font

ubuntu_mono_font

@xueyeyu
Copy link
Author

xueyeyu commented May 1, 2024

monospace can display normal and other font (eg Ubuntu Mono and Fira Code ) cant display normal with chinese charactors .

@nyamatongwe
Copy link
Contributor

I wouldn't refer to the boxed number glyphs as 'garbled' - they show the character values and allow editing when fonts do not contain particular characters.

Font mapping and combining seems to work poorly with GTK on Windows - its worse than native Win32 APIs or GTK on Linux. Restricting choice to just fonts observed to be safe would likely be counterproductive as a font that works well with one language (such as Chinese) may not contain the characters for other languages (such as Arabic). I don't think there is anything worth changing in the code and the user should choose a font that works for them.

@xueyeyu
Copy link
Author

xueyeyu commented May 4, 2024

我不这么认为,在windows平台上这些字体(如 Ubuntu Mono 和Fira Code )在其他编辑器(如 atom vscode 等)能够正常显示,这些字体也是支持多语言的。

(machine translation)
I don't think so. On the Windows platform, these fonts (such as Ubuntu Mono and Fira Code) can be displayed normally in other editors (such as atom vscode), and these fonts also support multiple languages.

@elextr
Copy link
Member

elextr commented May 4, 2024

There are unlikely to be many other editors that use the GTK toolkit on Windows (vscode definitely does not) so the fact that fonts work elsewhere does not help. GTK tends to do its own thing, so how it handles fallback fonts on Windows is unknown. Vscode uses electron which is a browser library and likely uses the browser fallback list.

@nyamatongwe
Copy link
Contributor

@xueyeyu these fonts (such as Ubuntu Mono and Fira Code) can be displayed normally in other editors (such as atom vscode), and these fonts also support multiple languages.

Fira Code does not contain Chinese characters.

This is quite clear even from just looking at the file sizes. There are many more Chinese characters than Roman characters and each takes up room in font files. A CJK font like Yu Gothic Regular YuGothR.ttc is 13 MB but Fira Code Regular FiraCode-Regular.otf is 120 KB.

Open the fonts up in a font editor like FontForge and Fira Code includes 1353 characters whereas Yu Gothic includes 15622 characters with 12469 in the CJK Unified Ideographs range.

When an application asks for Fira Code, a graphics stack component called a 'font mapper' determines how to implement that request. The requested font name is matched to a file. If there isn't a matching file then a default is used. That file is opened and its supported character ranges checked. Where there are gaps, other font files are used for characters in those gaps - maybe Yu Gothic is used for Chinese characters and EmojiOne Color Regular is used for emoji.

It is the font mapper component that seems to be behaving poorly or is misconfigured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants