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

Better algorithm for font choosing #7

Merged
merged 1 commit into from
Apr 13, 2020

Conversation

ilya-fedin
Copy link
Contributor

No description provided.

@john-preston john-preston merged commit 74889b8 into desktop-app:master Apr 13, 2020

#ifdef Q_OS_WIN
auto list = QStringList();
list.append("Microsoft YaHei");
Copy link

@ghost ghost Apr 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why it's Microsoft Yahei instead of Microsoft Yahei UI just like other fonts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a list of fonts from FontMod readme

@Coxxs
Copy link

Coxxs commented Apr 24, 2020

AFAIK, every Windows system has Microsoft YaHei, Microsoft JhengHei UI, and Yu Gothic UI font. We should change the font priority based on the system region.

For example, for Traditional Chinese, Microsoft JhengHei UI should be prioritized, and for Japanese, Yu Gothic UI should be prioritized. Microsoft YaHei is designed just for Simplified Chinese.

@ilya-fedin
Copy link
Contributor Author

We should change the font priority based on the system region.

Qt doesn't prioritize them in any locale. I.e. if these substitutions will be only for japanese/chinese/korean locale, users with english locale will get the old fonts from winxp, as it was before substiutions.

@Coxxs
Copy link

Coxxs commented Apr 24, 2020

The issue here is system with Japanese / Tradition Chinese language will use Microsoft YaHei (not Yu Gothic UI or Microsoft JhengHei UI).

@ysc3839
Copy link

ysc3839 commented Apr 24, 2020

@ilya-fedin

Qt doesn't prioritize them in any locale.

No, Qt has 5 lists and it's selected based on GetUserDefaultLangID:
https://github.com/qt/qtbase/blob/44e8c90ad4ae5a3d08651a61ac9f0937fb49d26b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabasebase.cpp#L895-L986

The best solution is to use system "MessageFont", it's implemented but disabled for Qt 5:
https://github.com/qt/qtbase/blob/44e8c90ad4ae5a3d08651a61ac9f0937fb49d26b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabasebase.cpp#L761-L784

@ilya-fedin
Copy link
Contributor Author

No, Qt has 5 lists and it's selected based on GetUserDefaultLangID:

According to your list, it is old winxp fonts, as I said:

    "MS UI Gothic",
    "Gulim",
    "SimSun",
    "PMingLiU",

@ilya-fedin
Copy link
Contributor Author

btw @ysc3839 thank you for the link, now we can patch Qt instead of substituions, I sent it to @john-preston

@Coxxs
Copy link

Coxxs commented Apr 24, 2020

What Qt 5 does is not perfect, but it's right. Use Simplified Chinese font for Japanese is not right.

Telegram 2.0.1 (Japanese System):
image

Telegram 2.1 (Japanese System):
image

You can see the wrong glyph displayed in Telegram 2.1 (Japanese System).

I'm not familiar with Qt, but I guess @ysc3839 means you can use Qt 6's method (call WinApi SystemParametersInfo, https://github.com/qt/qtbase/blob/44e8c90ad4ae5a3d08651a61ac9f0937fb49d26b/src/platformsupport/fontdatabases/windows/qwindowsfontdatabasebase.cpp#L767) to get default GUI font, and set it as the fallback font.

@ilya-fedin
Copy link
Contributor Author

call WinApi SystemParametersInfo

based on GetUserDefaultLangID

🤔

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.

4 participants