aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2020-02-28 20:26:00 +0200
committerAhmad Samir <a.samirh78@gmail.com>2020-03-02 12:51:33 +0200
commita2774ff5b41987c3919a9ecc54c70e0d4b3758ae (patch)
tree0dc57d9450c55a68140bdd48adb0812555e5f810 /src
parentf98feb16981350480bdb292cf157f70005d5be12 (diff)
downloadkconfig-a2774ff5b41987c3919a9ecc54c70e0d4b3758ae.tar.gz
kconfig-a2774ff5b41987c3919a9ecc54c70e0d4b3758ae.tar.bz2
[KConfigGui] Clear styleName font property for Regular font sytles
Summary: If the styleName property is set for a QFont, using setBold(true) would lead to Qt using an "emboldended"/synthetic font style instead of using the bold style provided by the font itself (usually as a standalone font file), the former looks ugly (IIUC, Freetype emboldens fonts as a last resort for fonts that don't provide a bold style at all). Accoring to upstream[1] the styleName property is useful for fonts with fancy style names, and also it shouldn't be set if it's not needed; and indeed using styleName with e.g. "Regular" doesn't make sense, as there is no "Regular Bold" style AFAICS. Checking for "Regular|Normal|Book|Roman" is based on examining the font styles provided by the font packages available on OpenSuse Tumbleweed ATM, (I didn't include some of the weird/non-common ones e.g. I've seen "Roma" and "Rounded"). Some statistics about the "Regular"-like font styles from my testing: Regular: 2486 Normal: 66 Book: 20 Roman: 13 For more details see: [1] https://bugreports.qt.io/browse/QTBUG-63792 https://bugs.kde.org/show_bug.cgi?id=378523 BUG: 378523 FIXED-IN: 5.68 Test Plan: All unit tests still pass. Changing the fonts via e.g. the fonts KCM doesn't append the font sytleName, to the relevant font config entry, if the "Regular" style or co. is used. A simple test, look at the current dir name in the Dolphin url bar with and without ",Regular" appended to the font= entry (assuming you're using Noto Sans or DejaVu Sans as the styleName varies from font to font). Reviewers: #frameworks, dfaure, davidedmundson, cfeck, ervin Reviewed By: dfaure Subscribers: kde-frameworks-devel Tags: #frameworks Differential Revision: https://phabricator.kde.org/D27735
Diffstat (limited to 'src')
-rw-r--r--src/gui/kconfiggroupgui.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/gui/kconfiggroupgui.cpp b/src/gui/kconfiggroupgui.cpp
index 8031458e..ab9d4e20 100644
--- a/src/gui/kconfiggroupgui.cpp
+++ b/src/gui/kconfiggroupgui.cpp
@@ -166,10 +166,23 @@ static bool writeEntryGui(KConfigGroup *cg, const char *key, const QVariant &pro
cg->writeEntry(key, list, pFlags);
return true;
}
- case QMetaType::QFont:
- cg->writeEntry(key, prop.toString().toUtf8(), pFlags);
+ case QMetaType::QFont: {
+ QFont f = prop.value<QFont>();
+ // If the styleName property is set for a QFont, using setBold(true) would
+ // lead to Qt using an "emboldended"/synthetic font style instead of using
+ // the bold style provided by the font itself; the latter looks much better
+ // than the former. For more details see:
+ // https://bugreports.qt.io/browse/QTBUG-63792
+ // https://bugs.kde.org/show_bug.cgi?id=378523
+ if (f.styleName() == QLatin1String("Regular")
+ || f.styleName() == QLatin1String("Normal")
+ || f.styleName() == QLatin1String("Book")
+ || f.styleName() == QLatin1String("Roman")) {
+ f.setStyleName(QString());
+ }
+ cg->writeEntry(key, f.toString().toUtf8(), pFlags);
return true;
-
+ }
case QMetaType::QPixmap:
case QMetaType::QImage:
case QMetaType::QBrush: