From 5d2ab77af89061cf388b34720095ac9b0ac9b4fa Mon Sep 17 00:00:00 2001 From: Ross Nicoll Date: Wed, 29 Sep 2021 19:58:28 +0100 Subject: [PATCH] Rebuild font setting --- src/qt/bitcoingui.cpp | 39 +++++++++++++++++++++++--------------- src/qt/forms/intro.ui | 2 +- src/qt/splashscreen.cpp | 2 +- src/qt/transactiondesc.cpp | 2 +- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 223935f37a8..a1038908440 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -88,6 +88,30 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty move(QGuiApplication::primaryScreen()->availableGeometry().center() - frameGeometry().center()); } + QFontDatabase database; + QString family = "Comic Sans MS"; + if (!database.families().contains(family)) { + // Dogecoin: load fallback font in case Comic Sans is not availble on the system + int id = QFontDatabase::addApplicationFont(":fonts/ComicNeue-Regular"); + if (id < 0) { + LogPrintf("Qt failed to load ComicNeue-Regular font\n"); + } else { + family = QFontDatabase::applicationFontFamilies(id).at(0); + } + QFontDatabase::addApplicationFont(":fonts/ComicNeue-Regular-Oblique"); + QFontDatabase::addApplicationFont(":fonts/ComicNeue-Bold"); + QFontDatabase::addApplicationFont(":fonts/ComicNeue-Bold-Oblique"); + QFontDatabase::addApplicationFont(":fonts/ComicNeue-Light"); + QFontDatabase::addApplicationFont(":fonts/ComicNeue-Light-Oblique"); + QFont::insertSubstitution("Comic Sans MS", family); + } + + // Dogecoin: Specify Comic Neue as new font. + QFont newFont(family, 10); + + // Dogecoin: Set new application font + QApplication::setFont(newFont); + #ifdef ENABLE_WALLET enableWallet = WalletModel::isWalletEnabled(); #endif // ENABLE_WALLET @@ -115,21 +139,6 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const PlatformStyle *_platformSty modalOverlay = new ModalOverlay(enableWallet, this->centralWidget()); - // Dogecoin: load fallback font in case Comic Sans is not availble on the system - QFontDatabase::addApplicationFont(":fonts/ComicNeue-Bold"); - QFontDatabase::addApplicationFont(":fonts/ComicNeue-Bold-Oblique"); - QFontDatabase::addApplicationFont(":fonts/ComicNeue-Light"); - QFontDatabase::addApplicationFont(":fonts/ComicNeue-Light-Oblique"); - QFontDatabase::addApplicationFont(":fonts/ComicNeue-Regular"); - QFontDatabase::addApplicationFont(":fonts/ComicNeue-Regular-Oblique"); - QFont::insertSubstitution("Comic Sans MS", "Comic Neue"); - - // Dogecoin: Specify Comic Sans as new font. - QFont newFont("Comic Sans MS", 10); - - // Dogecoin: Set new application font - QApplication::setFont(newFont); - // Accept D&D of URIs setAcceptDrops(true); diff --git a/src/qt/forms/intro.ui b/src/qt/forms/intro.ui index f27a4ebe44d..e098752f28c 100644 --- a/src/qt/forms/intro.ui +++ b/src/qt/forms/intro.ui @@ -17,7 +17,7 @@ - QLabel { font-style:italic; } + QLabel { font-family: Comic Neue; font-style:italic; } Welcome to %1. diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp index 375172435c3..f00f086d1e5 100644 --- a/src/qt/splashscreen.cpp +++ b/src/qt/splashscreen.cpp @@ -44,7 +44,7 @@ SplashScreen::SplashScreen(Qt::WindowFlags f, const NetworkStyle *networkStyle) QString copyrightText = QString::fromUtf8(CopyrightHolders(strprintf("\xc2\xA9 %u-%u ", 2009, COPYRIGHT_YEAR)).c_str()); QString titleAddText = networkStyle->getTitleAddText(); - QString font = "Comic Sans MS"; + QString font = QApplication::font().toString(); // create a bitmap according to device pixelratio QSize splashSize(480*devicePixelRatio,320*devicePixelRatio); diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index ece3a9cf483..125477f7aee 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -88,7 +88,7 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall QString strHTML; strHTML.reserve(4000); - strHTML += ""; + strHTML += ""; int64_t nTime = wtx.time; CAmount nCredit = wtx.credit;