Skip to content

Commit 15587b4

Browse files
committed
Merge bitcoin-core#448: Add helper to load font
d54ec27 qt: Add helper to load font (João Barbosa) Pull request description: Originally submitted as bitcoin-core/gui-qml#49. ACKs for top commit: hebasto: re-ACK d54ec27 stratospher: Tested ACK d54ec27. Refactoring the code and defining `loadFont()` in `src/qt/guiutil.cpp` reduces redundant imports of the `QFontDatabase` and is a better design. shaavan: ACK d54ec27 Tree-SHA512: b156bb6ffb08dd57476f383a29bbb0a1108b62794d430debb77252f7d09df1409a7532b09d17d8836d1c2ab7c126a6618231164b9d0def1b8f361a81ef22d107
2 parents 9275869 + d54ec27 commit 15587b4

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)