Skip to content

Commit

Permalink
Merge pull request dolphin-emu#6761 from spycrab/qt_win_font
Browse files Browse the repository at this point in the history
Qt/Win32: Use better method to obtain the default font
  • Loading branch information
leoetlino authored May 6, 2018
2 parents 8e3cad9 + 49a1b2e commit 26be225
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions Source/Core/DolphinQt2/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#ifdef _WIN32
#include <Windows.h>
#include <cstdio>

#include "Common/StringUtil.h"
#endif

#include <OptionParser.h>
Expand Down Expand Up @@ -94,14 +96,27 @@ int main(int argc, char* argv[])
QApplication app(argc, argv);

#ifdef _WIN32
// Force the default font to Segoe UI on Windows
QFont font = QApplication::font();
font.setFamily(QStringLiteral("Segoe UI"));

// The default font size is a bit too small
font.setPointSize(QFontInfo(font).pointSize() * 1.2);
// Get the default system font because Qt's way of obtaining it is outdated
NONCLIENTMETRICS metrics = {};
auto& logfont = metrics.lfMenuFont;
metrics.cbSize = sizeof(NONCLIENTMETRICS);

QApplication::setFont(font);
if (SystemParametersInfo(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::fromStdString(UTF16ToUTF8(logfont.lfFaceName)));
font.setWeight(logfont.lfWeight);
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);
}
#endif

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

0 comments on commit 26be225

Please sign in to comment.