Skip to content

Commit d54ec27

Browse files
committed
qt: Add helper to load font
1 parent c0b6c96 commit d54ec27

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/qt/bitcoin.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646

4747
#include <QApplication>
4848
#include <QDebug>
49-
#include <QFontDatabase>
5049
#include <QLatin1String>
5150
#include <QLibraryInfo>
5251
#include <QLocale>
@@ -492,7 +491,7 @@ int GuiMain(int argc, char* argv[])
492491
#endif
493492

494493
BitcoinApplication app;
495-
QFontDatabase::addApplicationFont(":/fonts/monospace");
494+
GUIUtil::LoadFont(QStringLiteral(":/fonts/monospace"));
496495

497496
/// 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these
498497
// Command-line options take precedence:

src/qt/guiutil.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,12 @@ bool hasEntryData(const QAbstractItemView *view, int column, int role)
272272
return !selection.at(0).data(role).toString().isEmpty();
273273
}
274274

275+
void LoadFont(const QString& file_name)
276+
{
277+
const int id = QFontDatabase::addApplicationFont(file_name);
278+
assert(id != -1);
279+
}
280+
275281
QString getDefaultDataDirectory()
276282
{
277283
return boostPathToQString(GetDefaultDataDir());

src/qt/guiutil.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ namespace GUIUtil
113113

114114
void setClipboard(const QString& str);
115115

116+
/**
117+
* Loads the font from the file specified by file_name, aborts if it fails.
118+
*/
119+
void LoadFont(const QString& file_name);
120+
116121
/**
117122
* Determine default data directory for operating system.
118123
*/

0 commit comments

Comments
 (0)