From 1dba5fab626b2b441d069a668fd148232384da14 Mon Sep 17 00:00:00 2001 From: Kyle Kienapfel Date: Sat, 1 Oct 2022 15:27:23 -0700 Subject: Qt: work around Qt5's font choice for Chinese On Windows there are currently two fonts used. The first, does the Menu, QTreeView and Tooltips Second is Everything else which is a default font. From inspecting QApplication::font() at runtime Windows 10 English: QFont(MS Shell Dlg 2,8.25,-1,5,50,0,0,0,0,0) Windows 11 Japanese: MS UI Gothic,9 ,-1,5,50,0,0,0,0,0 Windows 11 Traditional Chinese: PMingLiU,9 ,-1,5,50,0,0,0,0,0 Windows 11 Simplified Chinese: SimSun,9 ,-1,5,50,0,0,0,0,0 Windows 11 Korean: Gulim,9 ,-1,5,50,0,0,0,0,0 I initially investigated dynamically changing the font when the UI language is English, but this was getting quite messy Qt6 makes changes to default font in some situations, so this PR is being narrowed in scope to only effect Chinese font choices. This change only effects rendering of Latin/Cyrillic characters. --- src/yuzu/main.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 612b8dbb8..fc094ea1d 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -261,6 +261,18 @@ static QString 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() { #ifdef __linux__ const QPalette test_palette(qApp->palette()); @@ -4134,6 +4146,10 @@ int main(int argc, char* argv[]) { QCoreApplication::setAttribute(Qt::AA_DontCheckOpenGLContextThreadAffinity); QApplication app(argc, argv); +#ifdef _WIN32 + OverrideWindowsFont(); +#endif + // Workaround for QTBUG-85409, for Suzhou numerals the number 1 is actually \u3021 // so we can see if we get \u3008 instead // TL;DR all other number formats are consecutive in unicode code points -- cgit v1.2.3