Skip to content

fix: font display is irregular for WeaselDeployer. #1454

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alpzmj9
Copy link

@alpzmj9 alpzmj9 commented Dec 18, 2024

The current font is set to “MS Shell Dlg”, which is mapped to “SimSun” on Chinese operating systems instead of the system default font, which throws to very terrible display results.

I just changed it to "Segoe UI" and the problem was solved.

Q: Why not set it to "Microsoft YaHei" or "Microsoft JhengHei" immediately?

A: Since many Chinese users have both fonts on their computers, doing so will most likely result in them being forced to be mapped to the wrong font.

Q: Why Segoe UI?

A: Because it's Windows's default font for the English version, than can be a fallback to correct fonts for other languages referenced by system fontlink.

The current font is set to “MS Shell Dlg”, which is mapped to “SimSun” on Chinese operating systems instead of the system default font, which throws to very terrible display results.

I just changed it to "Segoe UI" and the problem was solved.

Q: Why not set it to "Microsoft YaHei" or "Microsoft JhengHei" immediately?

A: Since many Chinese users have both fonts on their computers, doing so will most likely result in them being forced to be mapped to the wrong font.

Q: Why Segoe UI?

A: Because it's Windows's default font for the English version, than can be a fallback to correct fonts for other languages referenced by system fontlink.
@fxliang
Copy link
Contributor

fxliang commented Dec 18, 2024

it's not SimSun, but logic font MS Shell Dlg, this is the recommended approach from Microsoft.

in my windows 10 laptop in Chs, it's mapped to MS Sans Serif

you can check HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes for the font in your system.

for detail information, check this https://learn.microsoft.com/zh-cn/windows/win32/intl/using-ms-shell-dlg-and-ms-shell-dlg-2

@alpzmj9
Copy link
Author

alpzmj9 commented Dec 18, 2024

it's not SimSun, but logic font MS Shell Dlg, this is the recommended approach from Microsoft.

in my windows 10 laptop in Chs, it's mapped to MS Sans Serif

you can check HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontSubstitutes for the font in your system.

for detail information, check this https://learn.microsoft.com/zh-cn/windows/win32/intl/using-ms-shell-dlg-and-ms-shell-dlg-2

I think you're right, but it does end up being mapped to "SimSun" via Fontlink.

I have checked the Microsoft documentation and this may be a bug from Microsoft, but it is definitely not normal and has been there for a long time.

you can check "Microsoft Sans Serif" registry item in "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink"

This is a screenshot of my registry item, also Win10/Chs, OS should be the latest version, and I have not modified it.
image

@alpzmj9
Copy link
Author

alpzmj9 commented Dec 18, 2024

屏幕截图 2024-12-18 232747 屏幕截图 2024-12-18 232839 Attach a before and after comparison (the monitor is 2160P/150 scaling).

If the screen resolution is below 1080P and there is no scaling, "SimSun" will be dotted, maybe resulting in a relatively good display effect.

But as soon as the resolution is greater than 1080 and the scaling is non-integer ratio, it starts to get really bad.

@lotem
Copy link
Member

lotem commented Dec 19, 2024

有趣的研究。右邊看上去清楚一些。

@lotem
Copy link
Member

lotem commented Dec 19, 2024

我記得Windows以前用那種點陣宋體,默認字號還挺清楚的。微軟瞎改?

@fxliang
Copy link
Contributor

fxliang commented Dec 19, 2024

我記得Windows以前用那種點陣宋體,默認字號還挺清楚的。微軟瞎改?

好像是因为DPI修改之后的问题,150%比例似乎是会有点虚

@fxliang
Copy link
Contributor

fxliang commented Apr 14, 2025

未开启dpi aware的两个显示器上的截图
image
image

开启了dpi aware的两个显示器上的截图
image
image

提供一点思路,早前的一点对比,用lazarus做最近两个demo,一个是开了per monitor dpi aware的,一个是关了的,字体不是宋体了。如果开了dpi aware的话,在两个显示器之间切换始终是清晰的,如果没开就一个清一个糊。

所以我的判断是糊是因为对话框没有正确响应WM_DPICHANGE消息导致的而不是字体导致。目前未了解到怎么处理

@fxliang
Copy link
Contributor

fxliang commented Apr 15, 2025

我在fxliang/weasel 下的pb分支,基本可以不改字体也在不同DPI的显示器下清晰了,FontSettingDialog暂时还没有整合,虽然窗体大小在初始显示器DPI不是96的时候有一点不太正确(偏大),基本可用了

scale

@alpzmj9
Copy link
Author

alpzmj9 commented Apr 15, 2025

我在fxliang/weasel 下的pb分支,基本可以不改字体也在不同DPI的显示器下清晰了,FontSettingDialog暂时还没有整合,虽然窗体大小在初始显示器DPI不是96的时候有一点不太正确(偏大),基本可用了

scale scale

我在fxliang/weasel 下的pb分支,基本可以不改字体也在不同DPI的显示器下清晰了,FontSettingDialog暂时还没有整合,虽然窗体大小在初始显示器DPI不是96的时候有一点不太正确(偏大),基本可用了

scale scale

感谢研究,但这似乎是另一个问题,也的确存在一个非整数倍缩放(如在我之前的16寸1080P笔记本上,默认缩放倍率为125%)的情况下,文字会发虚的情况,但是在现在的笔记本(2880*1800/200%)就不会。在150%缩放的屏幕上,开启兼容性模式也可以缓解(但我并没有研究过它的原理,似乎是让软件无视掉系统的缩放设置)。

这个PR目的就是替换掉宋体,原因是在Vista引入微软雅黑作为默认字体以后,宋体就不应该再作为GUI应用程序的屏显字体使用了。且目前版本已经放弃对Windows 8以前版本操作系统的兼容,所以我认为,替换为目前Windows的系统默认字体是合理的。

MS Shell Dlg这个逻辑字体是微软规范里的推荐做法,我目前测试,在英文版本操作系统中,它会在注册表HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink目录中的MS Shell Dlg中决定映射,默认值为Microsoft Sans Serif,对于安装了中文语言包的英文系统,中文字体部分会被Fontlink映射到Simsun(宋体)。而对于简体中文操作系统,会根据HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\GRE_Initialize中的一项(它的值会是Simsun)直接调用宋体。我并不清楚它的原理,但这个注册表项似乎与GDI相关。

微软大概是出于兼容性考虑,保留了这样的设计规范。因为这两个问题都可以算作GDI的历史遗留问题,而现在的软件通常会直接选择WPF等使用DirectX作为渲染引擎的技术,从一开始就不再兼容Windows XP等系统,自然也不用考虑兼容性问题。

@alpzmj9 alpzmj9 closed this Apr 15, 2025
@alpzmj9
Copy link
Author

alpzmj9 commented Apr 15, 2025

感谢研究,但这似乎是另一个问题,也的确存在一个非整数倍缩放(如在我之前的16寸1080P笔记本上,默认缩放倍率为125%)的情况下,文字会发虚的情况,但是在现在的笔记本(2880*1800/200%)就不会。在150%缩放的屏幕上,开启兼容性模式也可以缓解(但我并没有研究过它的原理,似乎是让软件无视掉系统的缩放设置)。

这个PR目的就是替换掉宋体,原因是在Vista引入微软雅黑作为默认字体以后,宋体就不应该再作为GUI应用程序的屏显字体使用了。且目前版本已经放弃对Windows 8以前版本操作系统的兼容,所以我认为,替换为目前Windows的系统默认字体是合理的。

MS Shell Dlg这个逻辑字体是微软规范里的推荐做法,我目前测试,在英文版本操作系统中,它会在注册表HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink目录中的MS Shell Dlg中决定映射,默认值为Microsoft Sans Serif,对于安装了中文语言包的英文系统,中文字体部分会被Fontlink映射到Simsun(宋体)。而对于简体中文操作系统,会根据HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\GRE_Initialize中的一项(它的值会是Simsun)直接调用宋体。我并不清楚它的原理,但这个注册表项似乎与GDI相关。

微软大概是出于兼容性考虑,保留了这样的设计规范。因为这两个问题都可以算作GDI的历史遗留问题,而现在的软件通常会直接选择WPF等使用DirectX作为渲染引擎的技术,从一开始就不再兼容Windows XP等系统,自然也不用考虑兼容性问题。

补充关于替换掉宋体的原因,之前我给出的150%缩放下的截图是已经开启兼容性设置的,宋体只有在Hint生效被点阵化的情况下,能得到较好的显示效果,而这个界限,通常是1080P/100%缩放。

以Segoe UI为代表(简体中文系统为微软雅黑,繁体中文为微软正黑)的非衬线屏显字体,则可以在1080P及以上分辨率的屏幕上,始终保持较好的显示效果(实际上微软雅黑在125%等非0.5倍数的缩放下,显示效果同样不太好,但宋体只会更糟)。

尽管微软雅黑在低分辨率屏幕上显示效果,可能不如宋体,但考虑到现在的硬件设备,1080P以上分辨率的显示设备已经足够普及,大概只有少数极端情况下受此影响。

刚刚关掉了PR是误操作,十分抱歉。

@alpzmj9 alpzmj9 reopened this Apr 15, 2025
@fxliang
Copy link
Contributor

fxliang commented Apr 15, 2025

你试试我那个分支的产出吧

@alpzmj9
Copy link
Author

alpzmj9 commented Apr 15, 2025

你试试我那个分支的产出吧
image

很抱歉,由于我现在正外出中,没办法使用相同测试环境。

这是在当前笔记本上的测试截图,分辨率为2880*1800,缩放比例为200%,系统环境为en-us,安装了简中及日语语言包,使用二进制文件为d7f25a6

就目前的测试,似乎这次修改反而导致了控件被放大到了异常大小。但由于在该设备上,原本就不会出现缩放导致的模糊问题,故有待研究。

@alpzmj9
Copy link
Author

alpzmj9 commented Apr 15, 2025

Screenshot 2025-04-15 230026
Screenshot 2025-04-15 230622
附上官方最新Release版本,及自构建版本a9m对比,该版本只是改了字体,并替换掉了部分图标。

@fxliang
Copy link
Contributor

fxliang commented Apr 16, 2025

image
125%

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

Successfully merging this pull request may close these issues.

3 participants