Bug 412645

Summary: kcm_fonts shouldn't set the font styleName property in most cases
Product: [Applications] systemsettings Reporter: Ahmad Samir <a.samirh78>
Component: kcm_fontsAssignee: Unassigned bugs mailing-list <unassigned-bugs>
Status: RESOLVED NOT A BUG    
Severity: normal CC: filipfila.kde, kde, kde, nate, unassigned-bugs
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
See Also: https://bugs.kde.org/show_bug.cgi?id=378523
Latest Commit: Version Fixed In:

Description Ahmad Samir 2019-10-05 19:34:01 UTC
Due to an upstream issue[1], when setting a font using the fonts_kcm module the QFont styleName property gets set (evident by examining kdeglobals after setting a font, e.g. you will get ',Regular' appended to that font settings entry).

The upstream rationale is that this is necessary so that fonts that have weird style names would work, and that if the styleName property is set (with QFont::setStyleName()) it overrides all other font properties. This is problematic for some KDE apps, e.g. Dolphin which uses QFont::setBold() to make a certain part of its UI use the Bold variant of whatever font it's using.

The recommended way to "fix" this issue is to use setStyleName() with an empty string before saving/loading the font (with QFont::to/fromString()), see the upstream bug report.

Some KDE apps already use that method since they have their own embedded font selection dialogues:
Konsole: https://phabricator.kde.org/R319:41693fe9ee263f8f2281852a740ee52d55f003ef
KTextEditor: https://phabricator.kde.org/R39:4d91fa7e918d983e6569798dfe20c7c9faf4bb9e

See also bug 378523 and https://phabricator.kde.org/D9070

[1] https://bugreports.qt.io/browse/QTBUG-63792
Comment 1 Ahmad Samir 2019-10-12 16:20:59 UTC
Actually not setting the sytleName when saving font settings has the side effect that the next time I open kcm_fonts, then open the dialogue to set/select e.g. "General" font, Condensed in selected instead of "Regular"... I guess each kde app will have to discard the styleName property before calling setBold() on any QFont...

I'll close this report, sorry for the noise.