Bug 412645 - kcm_fonts shouldn't set the font styleName property in most cases
Summary: kcm_fonts shouldn't set the font styleName property in most cases
Status: RESOLVED NOT A BUG
Alias: None
Product: systemsettings
Classification: Applications
Component: kcm_fonts (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-10-05 19:34 UTC by Ahmad Samir
Modified: 2019-10-12 16:20 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.