Qt/Win32: Use better method to obtain the default font
This commit is contained in:
parent
58b96eeb9d
commit
49a1b2e5df
|
@ -5,6 +5,8 @@
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
|
#include "Common/StringUtil.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <OptionParser.h>
|
#include <OptionParser.h>
|
||||||
|
@ -94,14 +96,27 @@ int main(int argc, char* argv[])
|
||||||
QApplication app(argc, argv);
|
QApplication app(argc, argv);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
// Force the default font to Segoe UI on Windows
|
// Get the default system font because Qt's way of obtaining it is outdated
|
||||||
QFont font = QApplication::font();
|
NONCLIENTMETRICS metrics = {};
|
||||||
font.setFamily(QStringLiteral("Segoe UI"));
|
auto& logfont = metrics.lfMenuFont;
|
||||||
|
metrics.cbSize = sizeof(NONCLIENTMETRICS);
|
||||||
|
|
||||||
// The default font size is a bit too small
|
if (SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(metrics), &metrics, 0))
|
||||||
font.setPointSize(QFontInfo(font).pointSize() * 1.2);
|
{
|
||||||
|
// 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);
|
||||||
|
|
||||||
QApplication::setFont(font);
|
// The default font size is a bit too small
|
||||||
|
font.setPointSize(QFontInfo(font).pointSize() * 1.2);
|
||||||
|
|
||||||
|
QApplication::setFont(font);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
auto parser = CommandLineParse::CreateParser(CommandLineParse::ParserOptions::IncludeGUIOptions);
|
auto parser = CommandLineParse::CreateParser(CommandLineParse::ParserOptions::IncludeGUIOptions);
|
||||||
|
|
Loading…
Reference in New Issue