Bug 354963 - config created by kde-gtk-config forces apps to ignore system default fonts
Summary: config created by kde-gtk-config forces apps to ignore system default fonts
Status: RESOLVED FIXED
Alias: None
Product: kde-gtk-config
Classification: Plasma
Component: general (show other bugs)
Version: 5.4.2
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: Manuel Tortosa
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-06 20:02 UTC by Sudhir Khanger
Modified: 2019-08-24 21:11 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.17.0


Attachments
side by side comparison of the problem (98.10 KB, image/png)
2015-11-06 20:04 UTC, Sudhir Khanger
Details
buggy gtkrc-2.0 (407 bytes, text/plain)
2015-11-06 20:05 UTC, Sudhir Khanger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sudhir Khanger 2015-11-06 20:02:11 UTC
kde-gtk-config adds following code to ~/.gtkrc-2.0.

style "user-font" 
{
	font_name="Oxygen-Sans Sans-Book"
}
widget_class "*" style "user-font"

this code forces apps like Inkscape or Chrome to start ignoring fonts set by SystemSettings.

As long as I comment out the "widget_class" line in the above code gtk apps starts using fonts set by SystemSettings.

Reproducible: Always
Comment 1 Sudhir Khanger 2015-11-06 20:04:05 UTC
Created attachment 95360 [details]
side by side comparison of the problem

On one side app uses some font but on the right side the same app is using default fonts set by System Settings.
Comment 2 Sudhir Khanger 2015-11-06 20:05:07 UTC
Created attachment 95361 [details]
buggy gtkrc-2.0

comment out following section and problem goes away.

widget_class "*" style "user-font"
Comment 3 Aleix Pol 2015-11-16 23:51:00 UTC
Could somebody check if this patch solves the issue? (and hopefully doesn't introduce regressions...?)

diff --git a/src/appearancegtk2.cpp b/src/appearancegtk2.cpp
index b1e0b52..6499cf8 100644
--- a/src/appearancegtk2.cpp
+++ b/src/appearancegtk2.cpp
@@ -119,7 +119,6 @@ bool AppearanceGTK2::saveSettings(const QString& gtkrcFile) const
             << "\tfont_name=\""<< fontFamily << "\"\n"
             << "}\n";
     
-    flow << "widget_class \"*\" style \"user-font\"\n";
     flow << "gtk-font-name=\"" << m_settings["font"] << "\"\n";
     flow << "gtk-theme-name=\"" << m_settings["theme"] << "\"\n";
     flow << "gtk-icon-theme-name=\""<< m_settings["icon"] << "\"\n";
Comment 4 Kevin Kofler 2019-07-16 22:33:26 UTC
Are you sure that that change does the right thing? I suspect it will make GTK+ follow the systemwide defaults, which are NOT necessarily the same as the Plasma defaults. Plasma defaults to Noto upstream and in most distros, but the systemwide default is the plain "Sans" alias, which is whatever the distro defaults to (e.g., on Fedora, "Sans" is an alias for DejaVu Sans).
Comment 5 Nate Graham 2019-08-24 13:06:54 UTC
Git commit a9f3a3ddcb0b197f96b750323201da438f15c4ad by Nate Graham, on behalf of Mikhail Zolotukhin.
Committed on 24/08/2019 at 13:06.
Pushed by ngraham into branch 'master'.

Keep existing configurations' strings               

Summary:
Gtk configurator has been replacing .gtkrc-2.0 config file with it's own settings, discarding present file contents. Now it only modifies configuration strings, or add them if they are not present at the beginning of the file.

This patch also removes redundant configurations, such as including theme from /usr/share/themes gtkrc's, "user-font" style, widget_class and unneeded symlink .gtkrc-2.0-kde4. Those options do not seem needed, as gtk2 applications look the same without these options without any regressions. This was tested on Gimp, Inkscape and BleachBit apps on Manjaro, OpenSUSE and KDE Neon distributions.

As for gtk3 ini file - this is not reproducible anymore, any line, which does not hold parameter changeable in configurator, remains in settings.ini.
Related: bug 322797, bug 342320
FIXED-IN: 5.17.0

Test Plan:
Insert some lines in .gtkrc-2.0 file, that do not represent settings, that configurator changes, check if they are still present after applying new settings.

Check if gtk2 apps look identical with or without .gtkrc-2.0-kde4 symlink, with or without similar lines in .gtrkrc-2.0:

```
include "/usr/share/themes/Breeze/gtk-2.0/gtkrc"
style "user-font"
{
	font_name="Noto Sans Regular"
}
widget_class "*" style "user-font"

```

Reviewers: apol, #plasma

Reviewed By: apol

Subscribers: GB_2, ngraham, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D21524

M  +52   -51   src/appearancegtk2.cpp
M  +2    -0    src/appearancegtk2.h

https://commits.kde.org/kde-gtk-config/a9f3a3ddcb0b197f96b750323201da438f15c4ad
Comment 6 Kevin Kofler 2019-08-24 21:11:06 UTC
This needs to be tested on a distro such as Fedora where the default Sans alias, the default Plasma font, and the default GNOME font are all different. (On Fedora, those are DejaVu Sans, Noto Sans, and Cantarell, respectively.)