ysc3839 / FontMod

Simple hook tool to change Win32 program font.
MIT License
1.29k stars 62 forks source link

最新版Telegram無法替換字型 #59

Closed HIRATEYURINA46 closed 3 years ago

HIRATEYURINA46 commented 4 years ago

Telegram Version 2.1下無法更改字型,先前版本都是正常的。

ilya-fedin commented 4 years ago

replace all fallback fonts

This is Sisyphean labor because fallbacks will be changed with update again

Raymonf commented 4 years ago

@ilya-fedin

This is Sisyphean labor because fallbacks will be changed with update again

Yes, but I don't think there's a "one size fits all" solution here. People using this extension to change their fonts are most likely changing the default font to something else. For example, I use Chiron Sans HK and Sarasa UI HC. A real solution would be to allow user-defined substitutions from Telegram's settings menu.

I would go about implementing this myself, but I don't have much knowledge about Telegram Desktop's inner workings or really Qt for that matter. And even if I did, I'm not sure it would even be merged.

ilya-fedin commented 4 years ago

Yes, but I don't think there's a "one size fits all" solution here.

I just want to say it's better to wait when the situation with fallback become stable and then trying to find a working config :(

I'm not sure it would even be merged

Here you right, preston doesn't like settings :( That's why I'm using a fork

ilya-fedin commented 4 years ago

I think you should forget CJK fonts fallback on non-CJK OS. If you resolved CJK issue, what about other writing systems?

Looks like you're right, Qt fallbacks completely broken https://github.com/telegramdesktop/tdesktop/issues/7823

roytam1 commented 4 years ago

A real solution would be to allow user-defined substitutions from Telegram's settings menu.

yeah I think this will be best solution for advanced users that has special needs. for example, I can fallback to bitmap font so I can have sharpest display on my low DPI screen.

SaltfishAmi commented 4 years ago

A real solution would be to allow user-defined substitutions from Telegram's settings menu.

Indeed, but sadly Telegram Desktop locked down the corresponding issue in 2016 without showing any interest in implementing this, and that's exactly why we need this FontMod...

pyzxwjj commented 4 years ago

我这里的2.1.2 版本telegram从log里看到的默认字体是DAOpenSansRegular。 替换需要用 DAOpenSansRegular: &zh-cn-font # Chinese (Simplified) fallback font replace: Microsoft YaHei <<: *style

Raymonf commented 4 years ago

@pyzxwjj DAOpenSansRegular應該沒有漢字字形。如果這樣做的話,拉丁字母也會變成微軟雅黑。

ilya-fedin commented 4 years ago

Now, when CJK fallbacks are estabilished, config should be like this for W10:

style: &style

fonts:
  Microsoft YaHei UI:
    replace: Your Simplified Chinese Font
    <<: *style
  Microsoft JhengHei UI:
    replace: Your Traditional Chinese Font
    <<: *style
  Yu Gothic UI:
    replace: Your Japanese Font
    <<: *style
  Malgun Gothic:
    replace: Your Korean Font
    <<: *style

fixGSOFont: true
debug: false

For W7:

style: &style

fonts:
  Microsoft YaHei:
    replace: Your Simplified Chinese Font
    <<: *style
  Microsoft JhengHei:
    replace: Your Traditional Chinese Font
    <<: *style
  Meiryo UI:
    replace: Your Japanese Font
    <<: *style
  Malgun Gothic:
    replace: Your Korean Font
    <<: *style

fixGSOFont: true
debug: false
RyanChng commented 4 years ago

I am now on 2.1.4, I notice that using the fontmod.yaml file, my non-bolded Chinese text is in Microsoft YaHei but the bolded text is in Yu Gothic UI Bold. Am I doing it wrongly? In 2.1.2 it was fine, I was seeing bolded text in MS YaHei Bold.

fonts:
  SimSun: &zh-cn-font # Chinese (Simplified) fallback font
    replace: Microsoft YaHei
    <<: *style
  PMingLiU: # Chinese (Traditional) fallback font
    replace: Microsoft JhengHei UI
    <<: *style
  MS UI Gothic: # Japanese fallback font
    replace: microsoft yahei
    <<: *style
  Batang: # Korean fallback font
    replace: 맑은 고딕
    <<: *style
  Yu Gothic UI:
    replace: microsoft yahei
    <<: *style
  Yu Gothic UI Bold:
    replace: microsoft yahei bold
    <<: *style

fixGSOFont: true # true is to use system UI font
#fixGSOFont: *zh-cn-font # Or replace with user defined font
Raymonf commented 4 years ago

@RyanChng Same here. Not sure how to fix it yet.

I'll ignore how Chinese looks like trash while bold after the recent updates, but the header font is really annoying.

pyzxwjj commented 4 years ago

感觉不是注入的问题,似乎是 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

image

开启 debug: true 之后的 Log 如下:https://paste.ubuntu.com/p/vfHXHNnhcW/

你的系统是不是英文版的?我的英文版系统需要替换DAOpenSansRegular才能生效 DAOpenSansRegular: &zh-cn-font # Chinese (Simplified) fallback font replace: Microsoft YaHei <<: *style

Coxxs commented 4 years ago

最好的方法是修改系統的 Regional Format(不是顯示語言)到自己常用語言的區域,Telegram 會自動選擇合適的字型。

Windows 7 ~ 10: Control Panel -> Region -> Formats -> Format
Windows 10: Settings -> Time & Language -> Region -> Regional format

另一種方法是如這裡所述,直接替換 Qt 選擇的字型。例如:

# Windows 10 英文區域,想使用雅黑字型
  Yu Gothic UI:
    replace: Microsoft YaHei UI
  Yu Gothic UI Semibold:
    replace: Microsoft YaHei UI
# Windows 7 英文區域,想使用正黑體(未測試)
  Meiryo UI:
    replace: Microsoft JhengHei
  Meiryo UI Bold:
    replace: Microsoft JhengHei

另外如果是支援 200% 以上縮放的高分屏,可以試著替換成一款支援中粗體(Semi-Bold)的字型,這樣體驗或許會更好。

RyanChng commented 4 years ago

@Raymonf, the fix by @Coxxs worked for me. To change the bold text for us, the one to replace is Yu Gothic UI Semibold, not Yu Gothic UI Bold.

HIRATEYURINA46 commented 4 years ago

@Coxxs 不知何故,我的 FontMod 是正常運行的,但它仍然無法修改 Telegram 的字型

ghost commented 4 years ago

由于 tg 最近更新时一直在变动 UI 字体的引用,需要重新修改替换

先上效果:

image

一、先查看 tg 目录下的 log.txt 文件,找到 gui 加载的字体名称:

[2020.05.16 22:10:13] Font: from ':/gui/fonts/DAOpenSansRegular.ttf' loaded 'DAOpenSansRegular'
[2020.05.16 22:10:13] Font: from ':/gui/fonts/DAVazirRegular.ttf' loaded 'DAVazirRegular'
[2020.05.16 22:10:13] Font: from ':/gui/fonts/DAOpenSansRegularItalic.ttf' loaded 'DAOpenSansRegularItalic'
[2020.05.16 22:10:13] Font: from ':/gui/fonts/DAVazirRegular.ttf' loaded 'DAVazirRegular'
[2020.05.16 22:10:13] Font: from ':/gui/fonts/DAOpenSansSemiboldAsBold.ttf' loaded 'DAOpenSansSemibold'
[2020.05.16 22:10:13] Font: from ':/gui/fonts/DAVazirMediumAsBold.ttf' loaded 'DAVazirMedium'
[2020.05.16 22:10:13] Font: from ':/gui/fonts/DAOpenSansSemiboldItalicAsBold.ttf' loaded 'DAOpenSansSemiboldItalic'
[2020.05.16 22:10:13] Font: from ':/gui/fonts/DAVazirMediumAsBold.ttf' loaded 'DAVazirMedium'
[2020.05.16 22:10:13] Font: from ':/gui/fonts/DAOpenSansSemiboldAsBold.ttf' loaded 'DAOpenSansSemibold'
[2020.05.16 22:10:14] Font: from ':/gui/fonts/DAVazirMediumAsBold.ttf' loaded 'DAVazirMedium'
[2020.05.16 22:10:14] Font: from ':/gui/fonts/DAOpenSansSemiboldItalicAsBold.ttf' loaded 'DAOpenSansSemiboldItalic'
[2020.05.16 22:10:14] Font: from ':/gui/fonts/DAVazirMediumAsBold.ttf' loaded 'DAVazirMedium'

二、将第一步的字体替换成想要的字体,大小根据显示屏的大小及系统缩放进行微调即可

方法:每次用一个 style,和一个字体(用一个特殊字体加大字号代替),可以试出上面出现的字体是用于 UI 的哪些部位,以下是我个人的配置:

# tg 2.1.6
# FontMod 2.0.0.0
# 多 style 配置,增加灵活性

# 聊天、设置(未加粗)、对话的最后一条消息、任务栏未读消息计数
style1: &style1
  size: 37
  # weight: 400

# 输入时格式化成斜体
style2: &style2
  size: 37
  # weight: 400

# UI 中加粗显示的字体、如:列表中好友、群、频道名称;文件夹分类启用后的字体等
style3: &style3
  size: 35
  # weight: 600

fonts:

# style1
# 聊天、设置、最后一条消息、任务栏未读消息
  DAOpenSansRegular: &zh-cn-font # Chinese (Simplified) fallback font
    # replace: PingFangSC-Regular
    replace: Source Han Sans CN Normal
    <<: *style1

# style2
# 输入时格式化成斜体
  DAOpenSansRegularItalic: &zh-cn-font # Chinese (Simplified) fallback font
    # replace: PingFangSC-Regular
    replace: Source Han Sans CN Normal
    <<: *style2

# style3
#  UI 中加粗显示的字体、如:列表中好友、群、频道名称;文件夹分类启用后的字体等
  DAOpenSansSemibold: &zh-cn-font # Chinese (Simplified) fallback font
    # replace: PingFangSC-Regular
    replace: Source Han Sans CN Normal
    <<: *style3

# 不知道是 UI 哪些部位的字体
  # DAVazirRegular: &zh-cn-font # Chinese (Simplified) fallback font
  #   replace: Sarasa Mono SC
  #   # replace: Source Han Sans CN
  #   <<: *style

# 不知道是 UI 哪些部位的字体
  # DAVazirMedium: &zh-cn-font # Chinese (Simplified) fallback font
  #   replace: STCaiyun
  #   # replace: Source Han Sans CN
  #   <<: *style

# 不知道是 UI 哪些部位的字体
  # DAOpenSansSemiboldItalic: &zh-cn-font # Chinese (Simplified) fallback font
  #   replace: Sarasa Mono SC
  #   # replace: Source Han Sans CN
  #   <<: *style

fixGSOFont: false # true is to use system UI font
#fixGSOFont: *zh-cn-font # Or replace with user defined font
debug: false
roytam1 commented 4 years ago

# 不知道是 UI 哪些部位的字体 # DAVazirRegular: &zh-cn-font # Chinese (Simplified) fallback font # replace: Sarasa Mono SC # # replace: Source Han Sans CN # <<: *style

# 不知道是 UI 哪些部位的字体 # DAVazirMedium: &zh-cn-font # Chinese (Simplified) fallback font # replace: STCaiyun # # replace: Source Han Sans CN # <<: *style

these fonts are for farsi

Coxxs commented 4 years ago

不太推荐直接替换 DAOpenSans,这样会把英文也替换成中文字体里的,用起来可能有些怪。

ghost commented 4 years ago

# 不知道是 UI 哪些部位的字体 # DAVazirRegular: &zh-cn-font # Chinese (Simplified) fallback font # replace: Sarasa Mono SC # # replace: Source Han Sans CN # <<: style # 不知道是 UI 哪些部位的字体 # DAVazirMedium: &zh-cn-font # Chinese (Simplified) fallback font # replace: STCaiyun # # replace: Source Han Sans CN # <<: style

these fonts are for farsi

thank you :)

ghost commented 4 years ago

不太推荐直接替换 DAOpenSans,这样会把英文也替换成中文字体里的,用起来可能有些怪。

英文替换倒不影响使用,就是字体大小设置会导致部分 UI 的字体比较挤或者超出范围,精确调整比较困难,不过此类情况比较少,且不影响使用,个人还是可以接受。

image

telanxrays commented 4 years ago

破案了,要把字體的英文名變成中文名.至少我用的簡體WIN7這麽改有效.

fonts:
  微软雅黑: &zh-cn-font # Chinese (Simplified) fallback font
    replace: Microsoft Jhenghei
    <<: *style
  PMingLiU: # Chinese (Traditional) fallback font
    replace: Microsoft JhengHei UI
    <<: *style

Telegram版本是:2.1.6 雅黑顯示繁體真的是丑破天際,簡體也沒正黑好看.不知道為嘛簡體要推這麽爛的一套字型.

另外希望能進化下,把英文和中文都弄成能夠單獨設置字體,那就爽了.英文不是等寬看起來不和諧.

SaltfishAmi commented 4 years ago

雅黑顯示繁體真的是丑破天際,簡體也沒正黑好看.不知道為嘛簡體要推這麽爛的一套字型.

雅黑繁体丑破天际我同意,但对于常年生活在中国的简体字用户来说,正黑的字形非常怪异,至少肯定不是平时习惯的字形

laike9m commented 4 years ago

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

Works for me

20171213 commented 4 years ago

现在,当确定了CJK后备时,对于W10,配置应如下所示:

style: &style

fonts:
  Microsoft YaHei UI:
    replace: Your Simplified Chinese Font
    <<: *style
  Microsoft JhengHei UI:
    replace: Your Traditional Chinese Font
    <<: *style
  Yu Gothic UI:
    replace: Your Japanese Font
    <<: *style
  Malgun Gothic:
    replace: Your Korean Font
    <<: *style

fixGSOFont: true
debug: false

对于W7:

style: &style

fonts:
  Microsoft YaHei:
    replace: Your Simplified Chinese Font
    <<: *style
  Microsoft JhengHei:
    replace: Your Traditional Chinese Font
    <<: *style
  Meiryo UI:
    replace: Your Japanese Font
    <<: *style
  Malgun Gothic:
    replace: Your Korean Font
    <<: *style

fixGSOFont: true
debug: false

GOOD!!!!