diff --git a/kcms/fonts/fonts.cpp b/kcms/fonts/fonts.cpp --- a/kcms/fonts/fonts.cpp +++ b/kcms/fonts/fonts.cpp @@ -103,7 +103,26 @@ if (dbase.isSmoothlyScalable(family, style) && result.pointSize() == floor(size)) { result.setPointSizeF(size); } - return result; + + bool sameFont = font.toString() == result.toString(); + // A "Regular" font will have an empty styleName e.g. "DejaVu Sans,12,-1,5,50,0,0,0,0,0" + // so that setBold(true) can work (we deliberately clear the styleName for "Regular"-like + // font styles when saving via KConfig, see: writeEntryGui() from kconfiggroupgui.cpp). + // Here in this method we could end up with a "result" font that's using a Regular style + // and that has the styleName set, so the the original "font" param. and "result" are + // actually the same font + if (!sameFont + && font.weight() == QFont::Normal && font.styleName().isEmpty() + && result.weight() == QFont::Normal + && (result.styleName() == QLatin1String("Regular") + || result.styleName() == QLatin1String("Normal") + || result.styleName() == QLatin1String("Book") + || result.styleName() == QLatin1String("Roman"))) { + result.setStyleName(QString()); + sameFont = font.toString() == result.toString(); + } + + return sameFont ? font : result; } /**** FontAASettings ****/ @@ -572,7 +591,8 @@ // previews engine()->addImageProvider("preview", new PreviewImageProvider(m_settings->font())); - // KCM expect save state to be false at this point (can be true because of setNearestExistingFonts + // KCM expect save state to be false at this point (can be true because of setNearestExistingFonts), + // see: https://phabricator.kde.org/D27452 setNeedsSave(false); }