Skip to content

Commit

Permalink
Windows GUI: Use QMenu font (Segoe UI) for entire application
Browse files Browse the repository at this point in the history
On Windows, Qt's default system font (MS Shell Dlg 2) is outdated.

Dolphin previously used over 15 lines of code to compute a font
closer to the proper font, but with an approximately correct font size.
Using the QMenu font directly is both more concise and more elegant
(in my opinion).
  • Loading branch information
nyanpasu64 committed Feb 17, 2020
1 parent 62046d9 commit 44f602f
Showing 1 changed file with 6 additions and 21 deletions.
27 changes: 6 additions & 21 deletions Source/Core/DolphinQt/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,27 +101,12 @@ int main(int argc, char* argv[])
QApplication app(argc, argv);

#ifdef _WIN32
// Get the default system font because Qt's way of obtaining it is outdated
NONCLIENTMETRICSW metrics = {};
LOGFONTW& logfont = metrics.lfMenuFont;
metrics.cbSize = sizeof(metrics);

if (SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, sizeof(metrics), &metrics, 0))
{
// Sadly Qt 5 doesn't support turning a native font handle into a QFont so this is the next best
// thing
QFont font = QApplication::font();
font.setFamily(QString::fromStdWString(logfont.lfFaceName));

font.setItalic(logfont.lfItalic);
font.setStrikeOut(logfont.lfStrikeOut);
font.setUnderline(logfont.lfUnderline);

// The default font size is a bit too small
font.setPointSize(QFontInfo(font).pointSize() * 1.2);

QApplication::setFont(font);
}
// On Windows, Qt 5's default system font (MS Shell Dlg 2) is outdated.
// Interestingly, the QMenu font is correct and comes from lfMenuFont
// (Segoe UI on English computers).
// So use it for the entire application.
// This code will become unnecessary and obsolete once we switch to Qt 6.
QApplication::setFont(QApplication::font("QMenu"));
#endif

auto parser = CommandLineParse::CreateParser(CommandLineParse::ParserOptions::IncludeGUIOptions);
Expand Down

0 comments on commit 44f602f

Please sign in to comment.