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

[Feature request]: 建议xaml文件增加TextOptions.TextHintingMode="Fixed",禁用字体的hinting,使得低分屏的中文字体渲染更平滑 #5713

Closed
1 task done
Scott0902 opened this issue Sep 20, 2024 · 6 comments
Labels
enhancement New feature or request

Comments

@Scott0902
Copy link

相关问题

默认的微软雅黑字体在低分屏下总会使用臭名昭著的hinting显示,导致中文字体高低不平,只有在系统缩放比例在200%或以上,字体才不使用hinting。但并非所有人都有高分屏,我的系统缩放比例是125%,而且已通过TtfAutoHint工具去掉微软雅黑字体的所有hinting,使得大部分情况下微软雅黑字体都渲染得很平滑。由于v2rayN采用WPF字体渲染机制,即使我去掉微软雅黑的hinting,当前的v2rayN仍强制使用hinting算法渲染字体,字体显得怪异。

描述你希望的解决方案

我建议修改源代码的xaml文件,修改TextOptions,增加一行TextOptions.TextHintingMode="Fixed",还要把TextOptions.TextFormattingMode的值由"Display"改为"Ideal",以及 TextOptions.TextRenderingMode的值由"Auto改为"ClearType"

描述你所考虑的替代方案

No response

我确认已查询历史issues

@Scott0902 Scott0902 added the enhancement New feature or request label Sep 20, 2024
@Scott0902
Copy link
Author

我的系统是Windows 10,显示器分辨率1920*1200,系统的缩放比例是125%,v2rayN的字体大小设为14。
为详细说明我的问题,我附上图片说明。
首先默认的微软雅黑字体带hinting(这是长期诟病的字体高低不平现象):
v2ray msyh hinted

然后经过TtfAutoHint工具去掉微软雅黑的hinting后,v2rayN显示的微软雅黑虽然没有高低不平,但线条的粗细不一:
v2ray msyh removed hinting

最后我修改源代码的xaml文件,需要修改的xaml文件包括:
AddServer2Window.xaml
AddServerWindow.xaml
DNSSettingWindow.xaml
GlobalHotkeySettingWindow.xaml
MainWindow.xaml
OptionSettingWindow.xaml
RoutingRuleDetailsWindow.xaml
RoutingRuleSettingWindow.xaml
RoutingSettingWindow.xaml
SubEditWindow.xaml
SubSettingWindow.xaml

把以上xaml文件的下面两行:

TextOptions.TextFormattingMode="Display"
TextOptions.TextRenderingMode="Auto"

改为下面三行:

TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="ClearType"
TextOptions.TextHintingMode="Fixed"

运行build.ps1编译后,v2RayN显示的微软雅黑变得很圆滑,媲美macType渲染的效果:
v2ray recompile msyh removed hinting

@2dust
Copy link
Owner

2dust commented Sep 21, 2024

是否测试过其他字体也有此效果?
如果有时间可PR

@Scott0902
Copy link
Author

Scott0902 commented Sep 21, 2024

是否测试过其他字体也有此效果? 如果有时间可PR

已测试过。刚才已提交PR了。
只要是无 hinting 的字体都能渲染得很圆滑,比如更纱等距黑体(Sarasa Fixed SC),下载该字体时注意要认准“No-hinting”。

除了更纱字体,如果要去除系统其他中文字体 hinting,可以使用 TtfAutoHint 工具(下载页面)
以微软雅黑字体为例,使用命令:

ttfautohint -d c:\windows\fonts\msyh.ttc d:\msyh.ttc

然后把生成的字体文件在 Windows PE 环境里替换 Windows\fonts 目录下的同名字体文件。
如果没有Windows PE环境,只想看看新的字体效果,可以把生成的字体文件移动到 v2rayN 的 guiFonts 目录内,然后在 v2rayN 的设置里找到“当前字体(需重启)”选择字体名称。

系统老旧的宋体字、黑体字等,虽然没有hinting,但内含大量点阵字,在小字号情况下 WPF 的渲染机制只会优先使用点阵字,等于没效果。

2dust added a commit that referenced this issue Sep 23, 2024
@2dust
Copy link
Owner

2dust commented Sep 23, 2024

已处理,反馈下效果

@2dust 2dust closed this as completed Sep 23, 2024
lowercase78 added a commit to lowercase78/v2rayN that referenced this issue Sep 23, 2024
commit 60a75d9
Author: 2dust <[email protected]>
Date:   Mon Sep 23 17:23:23 2024 +0800

    up 6.60

commit 2456690
Author: 2dust <[email protected]>
Date:   Mon Sep 23 17:22:14 2024 +0800

    up PackageReference

commit cc42861
Author: 2dust <[email protected]>
Date:   Mon Sep 23 17:17:12 2024 +0800

    Adjusting the text display

commit 4d330ce
Author: 2dust <[email protected]>
Date:   Mon Sep 23 17:05:03 2024 +0800

    Disable auto update geo

commit 2503583
Author: 2dust <[email protected]>
Date:   Mon Sep 23 17:03:28 2024 +0800

    System proxy and tun mode

    2dust#5651

commit 1b11916
Author: 2dust <[email protected]>
Date:   Mon Sep 23 15:16:32 2024 +0800

    Preparing to remove part of the core

    2dust#5703

commit 3dfd557
Author: 2dust <[email protected]>
Date:   Mon Sep 23 15:00:25 2024 +0800

    Fix the problem of showing and hiding statistics columns

commit cd6bea2
Author: 2dust <[email protected]>
Date:   Mon Sep 23 14:10:58 2024 +0800

    Improved font display

    2dust#5713

commit 054f0f2
Author: 2dust <[email protected]>
Date:   Mon Sep 23 13:37:18 2024 +0800

    Bug fix

    2dust#5725

commit 9734767
Author: 2dust <[email protected]>
Date:   Mon Sep 23 12:09:17 2024 +0800

    Bug fix

    2dust#5724

commit 36d1585
Author: 2dust <[email protected]>
Date:   Mon Sep 23 11:04:37 2024 +0800

    Setting up not to automatically update the GEO file on first run

    2dust#5704

commit 4813610
Author: 2dust <[email protected]>
Date:   Mon Sep 23 11:01:03 2024 +0800

    When running for the first time, switch the interface language to English when judging that the system language is not Chinese.

    2dust#5670
@maidmeow4
Copy link

技术上可以的话希望可以加个开关,让用户自行决定此功能的状态。

@PandaFiredoge
Copy link

这样高分屏又模糊了……

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

No branches or pull requests

4 participants