Merge pull request #8807 from Docteh/default_fonts

Qt: work around Qt5's font choice for Chinese (in Windows)
This commit is contained in:
liamwhite 2022-10-07 17:39:39 -04:00 committed by GitHub
commit 972b93bf00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -262,6 +262,18 @@ static QString PrettyProductName() {
return QSysInfo::prettyProductName(); return QSysInfo::prettyProductName();
} }
#ifdef _WIN32
static void OverrideWindowsFont() {
// Qt5 chooses these fonts on Windows and they have fairly ugly alphanumeric/cyrllic characters
// Asking to use "MS Shell Dlg 2" gives better other chars while leaving the Chinese Characters.
const QString startup_font = QApplication::font().family();
const QStringList ugly_fonts = {QStringLiteral("SimSun"), QStringLiteral("PMingLiU")};
if (ugly_fonts.contains(startup_font)) {
QApplication::setFont(QFont(QStringLiteral("MS Shell Dlg 2"), 9, QFont::Normal));
}
}
#endif
bool GMainWindow::CheckDarkMode() { bool GMainWindow::CheckDarkMode() {
#ifdef __linux__ #ifdef __linux__
const QPalette test_palette(qApp->palette()); const QPalette test_palette(qApp->palette());
@ -4137,6 +4149,10 @@ int main(int argc, char* argv[]) {
QCoreApplication::setAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity); QCoreApplication::setAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity);
QApplication app(argc, argv); QApplication app(argc, argv);
#ifdef _WIN32
OverrideWindowsFont();
#endif
// Workaround for QTBUG-85409, for Suzhou numerals the number 1 is actually \u3021 // Workaround for QTBUG-85409, for Suzhou numerals the number 1 is actually \u3021
// so we can see if we get \u3008 instead // so we can see if we get \u3008 instead
// TL;DR all other number formats are consecutive in unicode code points // TL;DR all other number formats are consecutive in unicode code points