From 787740c0b2f023ecb1aeab7945656a736af83721 Mon Sep 17 00:00:00 2001 From: xdustinface Date: Fri, 29 May 2020 10:16:08 +0200 Subject: [PATCH 01/14] qt: Add Montserrat (picked in Dash Style Guide) as application font Includes the following methods - GUIUtil::loadFonts to load the fonts into the application's font database - GUIUtil::setApplicationFont to set the application font depending on the active theme - GUIUtil::setFont to set a specific font variation for a vector of widgets (Montserrat for dash themes, system default for traditional theme). - GUIUtil::getFont to get a specific montserrat variation as QFont (Montserrat for dash themes, system default for traditional theme). - GUIUtil::getFontWeightNormal to get the font weight to be used for normal text - GUIUtil::getFontWeightBold to get the font weight to be used for bolder text - GUIUtil::getFontNormal to get the default normal weighted QFont - GUIUtil::getFontBold to get the default bold weighted QFont There is a Qt bug on macOS (at least with macOS 10.15.4 and Qt 5.7.1) which leads to not mapping the font weights correctly to the different font types so that they can be selected by the appropriate methods to set the font weight. As result there is now way to properly select the different font styles from stylesheet or with QFont::setWeight() for the font Montserrat. There are only two different weights selectable over the full range of possible weight values. One very bold one and the "ExtraLight" version. As workaround its possible to select the fonts by using the font style string (QFont::setStyleName) as the Montserrat font becomes loaded as one family with one "font style" for each font file. The font wrapper added by this commit are taking care of this behaviour for all operating systems so there should be no other usage of QFont outside of GUIUtil and no more font changes in stylesheets. --- src/Makefile.qt.include | 24 ++- src/qt/dash.cpp | 3 + src/qt/dash.qrc | 20 ++ src/qt/guiutil.cpp | 200 ++++++++++++++++++ src/qt/guiutil.h | 34 +++ .../res/fonts/Montserrat/Montserrat-Black.otf | Bin 0 -> 230124 bytes .../Montserrat/Montserrat-BlackItalic.otf | Bin 0 -> 236868 bytes .../res/fonts/Montserrat/Montserrat-Bold.otf | Bin 0 -> 235192 bytes .../Montserrat/Montserrat-BoldItalic.otf | Bin 0 -> 243084 bytes .../fonts/Montserrat/Montserrat-ExtraBold.otf | Bin 0 -> 234432 bytes .../Montserrat/Montserrat-ExtraBoldItalic.otf | Bin 0 -> 242800 bytes .../Montserrat/Montserrat-ExtraLight.otf | Bin 0 -> 226772 bytes .../Montserrat-ExtraLightItalic.otf | Bin 0 -> 236444 bytes .../fonts/Montserrat/Montserrat-Italic.otf | Bin 0 -> 237828 bytes .../res/fonts/Montserrat/Montserrat-Light.otf | Bin 0 -> 228068 bytes .../Montserrat/Montserrat-LightItalic.otf | Bin 0 -> 237832 bytes .../fonts/Montserrat/Montserrat-Medium.otf | Bin 0 -> 230356 bytes .../Montserrat/Montserrat-MediumItalic.otf | Bin 0 -> 239660 bytes .../fonts/Montserrat/Montserrat-Regular.otf | Bin 0 -> 228620 bytes .../fonts/Montserrat/Montserrat-SemiBold.otf | Bin 0 -> 234056 bytes .../Montserrat/Montserrat-SemiBoldItalic.otf | Bin 0 -> 242672 bytes .../res/fonts/Montserrat/Montserrat-Thin.otf | Bin 0 -> 217636 bytes .../Montserrat/Montserrat-ThinItalic.otf | Bin 0 -> 227984 bytes src/qt/res/fonts/Montserrat/OFL.txt | 93 ++++++++ .../Montserrat/SIL_Open_Font_License.txt | 43 ++++ 25 files changed, 415 insertions(+), 2 deletions(-) create mode 100644 src/qt/res/fonts/Montserrat/Montserrat-Black.otf create mode 100644 src/qt/res/fonts/Montserrat/Montserrat-BlackItalic.otf create mode 100644 src/qt/res/fonts/Montserrat/Montserrat-Bold.otf create mode 100644 src/qt/res/fonts/Montserrat/Montserrat-BoldItalic.otf create mode 100644 src/qt/res/fonts/Montserrat/Montserrat-ExtraBold.otf create mode 100644 src/qt/res/fonts/Montserrat/Montserrat-ExtraBoldItalic.otf create mode 100644 src/qt/res/fonts/Montserrat/Montserrat-ExtraLight.otf create mode 100644 src/qt/res/fonts/Montserrat/Montserrat-ExtraLightItalic.otf create mode 100644 src/qt/res/fonts/Montserrat/Montserrat-Italic.otf create mode 100644 src/qt/res/fonts/Montserrat/Montserrat-Light.otf create mode 100644 src/qt/res/fonts/Montserrat/Montserrat-LightItalic.otf create mode 100644 src/qt/res/fonts/Montserrat/Montserrat-Medium.otf create mode 100644 src/qt/res/fonts/Montserrat/Montserrat-MediumItalic.otf create mode 100644 src/qt/res/fonts/Montserrat/Montserrat-Regular.otf create mode 100644 src/qt/res/fonts/Montserrat/Montserrat-SemiBold.otf create mode 100644 src/qt/res/fonts/Montserrat/Montserrat-SemiBoldItalic.otf create mode 100644 src/qt/res/fonts/Montserrat/Montserrat-Thin.otf create mode 100644 src/qt/res/fonts/Montserrat/Montserrat-ThinItalic.otf create mode 100644 src/qt/res/fonts/Montserrat/OFL.txt create mode 100644 src/qt/res/fonts/Montserrat/SIL_Open_Font_License.txt diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 854257d03cf1..8561587c1fc1 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -355,6 +355,26 @@ RES_CSS = \ qt/res/css/scrollbars.css \ qt/res/css/trad.css +RES_FONTS = \ + qt/res/fonts/Montserrat/Montserrat-Black.otf \ + qt/res/fonts/Montserrat/Montserrat-BlackItalic.otf \ + qt/res/fonts/Montserrat/Montserrat-Bold.otf \ + qt/res/fonts/Montserrat/Montserrat-BoldItalic.otf \ + qt/res/fonts/Montserrat/Montserrat-ExtraBold.otf \ + qt/res/fonts/Montserrat/Montserrat-ExtraBoldItalic.otf \ + qt/res/fonts/Montserrat/Montserrat-ExtraLight.otf \ + qt/res/fonts/Montserrat/Montserrat-ExtraLightItalic.otf \ + qt/res/fonts/Montserrat/Montserrat-Italic.otf \ + qt/res/fonts/Montserrat/Montserrat-Light.otf \ + qt/res/fonts/Montserrat/Montserrat-LightItalic.otf \ + qt/res/fonts/Montserrat/Montserrat-Medium.otf \ + qt/res/fonts/Montserrat/Montserrat-MediumItalic.otf \ + qt/res/fonts/Montserrat/Montserrat-Regular.otf \ + qt/res/fonts/Montserrat/Montserrat-SemiBold.otf \ + qt/res/fonts/Montserrat/Montserrat-SemiBoldItalic.otf \ + qt/res/fonts/Montserrat/Montserrat-Thin.otf \ + qt/res/fonts/Montserrat/Montserrat-ThinItalic.otf + RES_MOVIES = $(wildcard $(srcdir)/qt/res/movies/spinner-*.png) BITCOIN_RC = qt/res/dash-qt-res.rc @@ -367,7 +387,7 @@ qt_libdashqt_a_CXXFLAGS = $(AM_CXXFLAGS) $(QT_PIE_FLAGS) qt_libdashqt_a_OBJCXXFLAGS = $(AM_OBJCXXFLAGS) $(QT_PIE_FLAGS) qt_libdashqt_a_SOURCES = $(BITCOIN_QT_CPP) $(BITCOIN_QT_H) $(QT_FORMS_UI) \ - $(QT_QRC) $(QT_QRC_LOCALE) $(QT_TS) $(PROTOBUF_PROTO) $(RES_ICONS) $(RES_IMAGES) $(RES_CSS) $(RES_MOVIES) + $(QT_QRC) $(QT_QRC_LOCALE) $(QT_TS) $(PROTOBUF_PROTO) $(RES_ICONS) $(RES_IMAGES) $(RES_CSS) $(RES_FONTS) $(RES_MOVIES) nodist_qt_libdashqt_a_SOURCES = $(QT_MOC_CPP) $(QT_MOC) $(PROTOBUF_CC) \ $(PROTOBUF_H) $(QT_QRC_CPP) $(QT_QRC_LOCALE_CPP) @@ -430,7 +450,7 @@ $(QT_QRC_LOCALE_CPP): $(QT_QRC_LOCALE) $(QT_QM) $(SED) -e '/^\*\*.*Created:/d' -e '/^\*\*.*by:/d' > $@ @rm $(@D)/temp_$( $@ diff --git a/src/qt/dash.cpp b/src/qt/dash.cpp index fee5ad059fa4..d217e5fd4ca6 100644 --- a/src/qt/dash.cpp +++ b/src/qt/dash.cpp @@ -272,6 +272,9 @@ bool BitcoinCore::baseInitialize() { return false; } + if (!GUIUtil::loadFonts()) { + return false; + } return true; } diff --git a/src/qt/dash.qrc b/src/qt/dash.qrc index b66c470d61ac..2d4ba4a8c4aa 100644 --- a/src/qt/dash.qrc +++ b/src/qt/dash.qrc @@ -58,6 +58,26 @@ res/css/general.css res/css/scrollbars.css + + res/fonts/Montserrat/Montserrat-Black.otf + res/fonts/Montserrat/Montserrat-BlackItalic.otf + res/fonts/Montserrat/Montserrat-Bold.otf + res/fonts/Montserrat/Montserrat-BoldItalic.otf + res/fonts/Montserrat/Montserrat-ExtraBold.otf + res/fonts/Montserrat/Montserrat-ExtraBoldItalic.otf + res/fonts/Montserrat/Montserrat-ExtraLight.otf + res/fonts/Montserrat/Montserrat-ExtraLightItalic.otf + res/fonts/Montserrat/Montserrat-Italic.otf + res/fonts/Montserrat/Montserrat-Light.otf + res/fonts/Montserrat/Montserrat-LightItalic.otf + res/fonts/Montserrat/Montserrat-Medium.otf + res/fonts/Montserrat/Montserrat-MediumItalic.otf + res/fonts/Montserrat/Montserrat-Regular.otf + res/fonts/Montserrat/Montserrat-SemiBold.otf + res/fonts/Montserrat/Montserrat-SemiBoldItalic.otf + res/fonts/Montserrat/Montserrat-Thin.otf + res/fonts/Montserrat/Montserrat-ThinItalic.otf + res/css/dark.css res/css/light.css diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 9f69e9dd9835..1143861b645b 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -16,6 +16,7 @@ #include #include