Closed HIRATEYURINA46 closed 3 years ago
我这里 Telegram 2.1 是没有问题的,系统是 Windows 10 Pro x64 Version 1909。 建议检查一下是不是这个问题。
Telegram Version 2.1下無法更改字型,先前版本都是正常的。
同。
感觉不是注入的问题,似乎是 Telegram 修改了对字体的调用,我这里确认注入上了,但是替换无效。规则如下:
fonts:
SimSun:
replace: Source Han Sans SC Medium
Open Sans:
replace: Source Han Sans SC Medium
Open Sans Semibold:
replace: Source Han Sans SC Medium
Arial:
replace: Source Han Sans SC Medium
fixGSOFont: true
开启 debug: true
之后的 Log 如下:https://paste.ubuntu.com/p/vfHXHNnhcW/
It seems like Telegram changed some of its default fallback font.
For example, Korean fallback font changed to 맑은 고딕
(malgun) from Gulim
(굴림).
Windows 10 Pro x64 Version 1909 (Korean) Telegram desktop 2.1
我这里替换 "微软雅黑" 到任意其它字体会导致 Telegram 选择 fallback 列表中的下一个字体(雅黑 Light),继续替换 "微软雅黑 Light" 的话它会继续 fallback 到正黑
那我就坐等解决方案了。
@ysc3839 我这里 FontMod 本身也无法正常工作,见我上面贴的配置。如果加一条将「微软雅黑」替换掉的话,Telegram 会使用「微软雅黑 Light」而不是我替换为的字体。
On my system, I had to replace "microsoft yahei" (all lowercase). My current config:
style: &style
fonts:
microsoft yahei:
replace: Chiron Sans HK TT
<<: *style
fixGSOFont: true
debug: false
字体替换成功了,但是字体大小调整无效。
@ysc3839 那麼,現在已經有新的解決方案了嗎?
@HIRATEYURINA46 解决方案是 @Raymonf 所说的那样,在我这里可以正常工作
字体大小怎么修改?
@Menci 我這裏仍然無法正常工作。 btw ,我先前直接修改了登錄檔中微軟雅黑的字型的機碼值,強制替換微軟雅黑爲 Noto Sans CJK JP Light ,結果 Telegram 的默認字型倒是變成微軟正黑體了。
@HIRATEYURINA46 你那边替换「microsoft yahei」为「Noto Sans CJK JP Light」也不行吗。我这边替换「microsoft yahei」为「Source Han Sans SC Medium」是可以的。注意「microsoft yahei」是全小写。
@Menci 依舊是不行的
@Raymonf It's work !!!!!
我以為是因爲我手動修改了登錄檔的緣故,使得配置檔案變得無效了。結果我切換回默認機碼值以後,FontMod仍然沒有正常工作。
style: &style
fonts:
microsoft yahei:
replace: Sarasa Fixed Slab J Light
<<: *style
fixGSOFont: true
debug: false
這是我的FontMod配置檔案
我將winmm.dll
和FontMod.yaml
刪除後重新添加回去,發現即使啟動Telegram也不會自動生成winmm.dll
了
@ysc3839 automatically_disable_fullscreen_optimizations.bat
是個甚麼東西呢?要如何卸載呢?我剛剛看了你先前發的那個連結,還是不太明白
現在手動解除了禁用全屏优化
,但依然FontMod.yaml
無法正常工作
上面大佬的配置在更新前有效 今天tg又更新了 更新以后又失效了
@suheandzl 你知道TG在用什麼字體嗎?
我現在的TG在用 Yu Gothic UI
,所以就把配置檔案改為:
style: &style
fonts:
Yu Gothic UI:
replace: Chiron Sans HK TT
<<: *style
fixGSOFont: true
debug: false
Qt好似被補丁了,再次用系統默認語言來選擇字體,但是我真不明白為什麼繁體中文的系統會選日語字體... 又是另外一個bug吧
@suheandzl 你知道TG在用什麼字體嗎?
我現在的TG在用
Yu Gothic UI
,所以就把配置檔案改為:style: &style fonts: Yu Gothic UI: replace: Chiron Sans HK TT <<: *style fixGSOFont: true debug: false
Qt好似被補丁了,用系統默認語言來選擇字體,但是我真不明白為什麼繁體中文的系統會選日語字體... 又是另外一個bug吧
我系统安装时是简中 用语言包切换到了日语 现在默认字体是雅黑 反正之前按照楼上的大佬重新配置设定文件就能成功替换 今天更新到了2.1.1 又失效了
@suheandzl
现在默认字体是雅黑
那就可能要用Microsoft YaHei
(包括大字的名)。改成Microsoft YaHei
有效嗎?
Microsoft YaHei
我没改当时 按照你讲的改了以后 成功替换了 感谢
配置如下
style: &style
fonts: Microsoft YaHei: replace: Noto Sans CJK TC Medium <<: *style
fixGSOFont: true debug: false
我的Telegram更新以後,字型變成默認的Yu Gothic UI
,但是更換配置以後也還是無效。我的作業系統是日文系統
@HIRATEYURINA46 :thinking: 試試啟用除錯 (debug
從 false
改成 true
) 模式吧,還是在設定檔案裡。啟用後可以在FontMod.log
中看看Telegram載入什麼字體。
這裡是退回字體列表:https://github.com/desktop-app/patches/pull/1/commits/134ce22c2633d8698fa4084cac955e0dea17043e
根據以上的列表,Yu Gothic UI
應該沒錯,但是可能又是有那個小字問題。
@HIRATEYURINA46 你不妨試試 @suheandzl 那一招 fonts: Yu Gothic UI: replace: #你要的字體 <<: *style 總之Telegram在用甚麼字體你就replace甚麼。
我是新加坡人,系統語言是英語,今天更新到2.1.1後發現字體從雅黑變成了Yu Gothic於是就嘗試這一招。
style: &style
fonts:
SimSun: &zh-cn-font
replace: Microsoft YaHei
<<: *style
PMingLiU:
replace: Microsoft YaHei
<<: *style
MS UI Gothic:
replace: Microsoft YaHei
<<: *style
Gulim:
replace: Microsoft YaHei
<<: *style
fixGSOFont: *zh-cn-font
debug: false
This is my FontMod.yml file. It was still working on Telegram Desktop 2.1.0 and everything was in Microsoft YaHei. However it no longer works on 2.1.1, where it fallback'ed to either Yu Gothic UI or Microsoft Jhenghei UI, which I failed to distinguish.
My OS install language is ja-JP and interface language en-US.
開啟debug後,記錄值爲
[DllMain] SystemParametersInfo NONCLIENTMETRICS.lfMessageFont.lfFaceName="Yu Gothic UI"
開啟debug後,記錄值爲
[DllMain] SystemParametersInfo NONCLIENTMETRICS.lfMessageFont.lfFaceName="Yu Gothic UI"
經測試有效,我的debug日誌值為Microsoft JhengHei UI。我的作業系統語言是傳承字(繁體中文)。
@kanwakyuudai 經過我的測試,確認FontMod已經在正常工作了,但是Telegram依然沒有使用我replace的字型
这个 issue 发布的时候的“最新版”是 2.1,2.1.1 似乎又改了什么,非 zh_cn 的用户出现了千奇百怪的问题,zh_cn 则是雅黑,而且似乎 fontmod 在 2.1 写全小写的 microsoft yahei
有效而 2.1.1 无效,非常奇妙
@kanwakyuudai 經過我的測試,確認FontMod已經在正常工作了,但是Telegram依然沒有使用我replace的字型
我的目前確認有效的代碼如下,請參考:
Microsoft JhengHei UI: # Chinese (Traditional) fallback font replace: 源樣黑體 R <<: *style
@kanwakyuudai 經過我的測試,確認FontMod已經在正常工作了,但是Telegram依然沒有使用我replace的字型
我的目前確認有效的代碼如下,請參考:
Microsoft JhengHei UI: # Chinese (Traditional) fallback font replace: 源樣黑體 R <<: *style
我將Microsoft JhengHei UI
置換成Yu Gothic UI
後依舊無效。但Debug日誌裏卻是寫明了Telegram載入的是Yu Gothic UI
。
2.1.2 新版简体中文默认字体又变成了 Microsoft Yahei UI,字重非常大,非常丑,需要这样改:
style: &style
weight: 0
fonts:
Microsoft YaHei UI: &zh-cn-font # Chinese (Simplified) fallback font
replace: Microsoft YaHei
TG 官方的这个 Patch 真恶心人。https://github.com/desktop-app/patches/commit/7aed239952d2bf7e5d4843687f9b4fd291f8f467
Can anyone finally tell which fonts should be on different OS versions (Vista-10) and with different locales (traditional chinese, simplified chinese, japanese, korean)? Maybe there are a table?
@ilya-fedin None. You should never rely on a predefined font table. Instead, get current font from system.
I'm not familiar with Qt, but I think you should first patch QWindowsFontDatabase::systemDefaultFont()
to use SystemParametersInfo(SPI_GETNONCLIENTMETRICS).
https://github.com/qt/qtbase/blob/5.12.8/src/platformsupport/fontdatabases/windows/qwindowsfontdatabase.cpp#L2025-L2048
Then use QFont::insertSubstitution()
with systemDefaultFont
.
https://github.com/desktop-app/lib_ui/blob/8660904bc88ad86432521d434aae2d75658c6fb0/ui/style/style_core_font.cpp#L211
You should never rely on a predefined font table. Instead, get current font from system.
This only valid when this do you. When framework works that way, you can only edit this predefined table or add your own to workaround with this.
Then use
QFont::insertSubstitution()
withsystemDefaultFont
.
But this won't fix fallbacks on non-CJK OS. SystemParametersInfo will just return default english font and CJK fonts from Qt's predefined table will be used.
But this won't fix fallbacks on non-CJK OS.
Try append systemDefaultFont before this line.
Try append systemDefaultFont before this line.
But this wil prepend english font on english OS, just as previous suggestion, isn't it? :thinking:
@ilya-fedin I don't know how Qt works. But Windows GDI font has built-in fallback support. Try set Segoe UI
in Windows Notepad and type some CJK characters, you can still see them.
@ilya-fedin I don't know how Qt works. But Windows GDI font has built-in fallback support. Try set
Segoe UI
in Windows Notepad and type some CJK characters, you can still see them.
This builtin fallback mechanism works according to the registry key HKEY_LOCAL_MACHINE\SOFTWARE\
(WOW6432Node\
)Microsoft\Windows NT\CurrentVersion\FontLink\SystemLink
. This is user-modifiable.
Try set
Segoe UI
in Windows Notepad and type some CJK characters, you can still see them.
That predefined font table is the Qt's fallback support :) If the first font fail, it will just try the next from the code you linked. I.e. after failing systemDefaultFont, it will try extraTryFontsForFamily, what means, on english OS fallback will look like:
Open Sans -> Segoe UI -> that table with SimSun, Gulim, etc
@ilya-fedin I think you should forget CJK fonts fallback on non-CJK OS. If you resolved CJK issue, what about other writing systems?
replace all fallback fonts https://github.com/desktop-app/patches/blob/7aed239952d2bf7e5d4843687f9b4fd291f8f467/qtbase_5_12_8.diff#L494..L506
style: &style
# Remove '#' to override font style
size: 24
# width: 0
weight: 0
# italic: false
# underLine: false
# strikeOut: false
# charSet: 0
# outPrecision: 0
# clipPrecision: 0
# quality: 0
# pitchAndFamily: 0
fonts:
Microsoft YaHei UI: &zh-cn-font # Chinese (Simplified) fallback font
replace: Microsoft YaHei
<<: *style
Arial: &zh-cn-font # Chinese (Simplified) fallback font
replace: Microsoft YaHei
<<: *style
Microsoft JhengHei UI: &zh-cn-font # Chinese (Simplified) fallback font
replace: Microsoft YaHei
<<: *style
Malgun Gothic: &zh-cn-font # Chinese (Simplified) fallback font
replace: Microsoft YaHei
<<: *style
Yu Gothic UI: &zh-cn-font # Chinese (Simplified) fallback font
replace: Microsoft YaHei
<<: *style
Arial Unicode MS: &zh-cn-font # Chinese (Simplified) fallback font
replace: Microsoft YaHei
<<: *style
fixGSOFont: true # true is to use system UI font
#fixGSOFont: *zh-cn-font # Or replace with user defined font
debug: false
If you resolved CJK issue, what about other writing systems?
They, most likely, are taken from MS Shell Dlg 2 (the first fallback font, familyForStyleHint) or from Arial Unicode MS (the last font from the table)
If this is not so, then GDI manages this fallback. But for CJK fonts this is not right until this table exists. And, I think, if delete this table, there are will be issues that are even worse (if they added this table, then this was done for a reason, right?).
Telegram Version 2.1下無法更改字型,先前版本都是正常的。