Skip to content

Add helper to load font #448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/qt/bitcoin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@

#include <QApplication>
#include <QDebug>
#include <QFontDatabase>
#include <QLatin1String>
#include <QLibraryInfo>
#include <QLocale>
Expand Down Expand Up @@ -492,7 +491,7 @@ int GuiMain(int argc, char* argv[])
#endif

BitcoinApplication app;
QFontDatabase::addApplicationFont(":/fonts/monospace");
GUIUtil::LoadFont(QStringLiteral(":/fonts/monospace"));

/// 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these
// Command-line options take precedence:
Expand Down
6 changes: 6 additions & 0 deletions src/qt/guiutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ bool hasEntryData(const QAbstractItemView *view, int column, int role)
return !selection.at(0).data(role).toString().isEmpty();
}

void LoadFont(const QString& file_name)
{
const int id = QFontDatabase::addApplicationFont(file_name);
assert(id != -1);
}

QString getDefaultDataDirectory()
{
return boostPathToQString(GetDefaultDataDir());
Expand Down
5 changes: 5 additions & 0 deletions src/qt/guiutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ namespace GUIUtil

void setClipboard(const QString& str);

/**
* Loads the font from the file specified by file_name, aborts if it fails.
*/
void LoadFont(const QString& file_name);

/**
* Determine default data directory for operating system.
*/
Expand Down