diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 52133ec9f9..2671bf980c 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -302,13 +302,23 @@ void setupAmountWidget(QLineEdit *widget, QWidget *parent) void setupAppearance(QWidget* parent, OptionsModel* model) { if (!QSettings().value("fAppearanceSetupDone", false).toBool()) { - // First make sure SystemDefault has reasonable default values if it does not support the full range of weights. - if (fontFamily == FontFamily::SystemDefault && getSupportedWeights().size() < 4) { - fontWeightNormal = mapSupportedWeights[FontFamily::SystemDefault].front(); - fontWeightBold = mapSupportedWeights[FontFamily::SystemDefault].back(); - QSettings().setValue("fontWeightNormal", weightToArg(fontWeightNormal)); - QSettings().setValue("fontWeightBold", weightToArg(fontWeightBold)); + std::vector vecWeights = getSupportedWeights(); + // See if the default value for normal weight is available + if (std::find(vecWeights.begin(), vecWeights.end(), defaultFontWeightNormal) == vecWeights.end()) { + // If not, use the lightest available weight as normal weight + fontWeightNormal = vecWeights.front(); } + + // See if the default value for bold weight is available + if (std::find(vecWeights.begin(), vecWeights.end(), defaultFontWeightBold) == vecWeights.end()) { + // If not, use the second lightest available weight as bold weight default or also the lightest if there is only one + int nBoldOffset = vecWeights.size() > 1 ? 1 : 0; + fontWeightBold = vecWeights[nBoldOffset]; + } + + QSettings().setValue("fontWeightNormal", weightToArg(fontWeightNormal)); + QSettings().setValue("fontWeightBold", weightToArg(fontWeightBold)); + // Create the dialog QDialog dlg(parent); dlg.setObjectName("AppearanceSetup");