Open wereturtle opened 8 years ago
I also forgot to mention that both Mate and Xfce desktops somehow set the DPI for Qt5 apps appropriately (though they still do not set the antialiasing and hinting correctly). Perhaps we can borrow from them?
I tracked down the font DPI issue to Qt not accepting floating point values for Xft.dpi. Please see QTBUG-64738. This font DPI bug in Qt affects any desktop environment whose settings manager uses a scaling factor for setting the font DPI (including Gnome 3). This is why Mate and XFCE desktop environments are not affected by this bug.
I came to this bug too. I checked the the source code, and found the following https://github.com/linuxmint/cinnamon-settings-daemon/blob/e1cd34de9ab9bb9da82569d6110d73f316b8bd35/plugins/xsettings/csd-xsettings-manager.c#L457-L458 https://github.com/linuxmint/cinnamon-settings-daemon/blob/e1cd34de9ab9bb9da82569d6110d73f316b8bd35/plugins/xsettings/csd-xsettings-manager.c#L527 https://github.com/linuxmint/cinnamon-settings-daemon/blob/e1cd34de9ab9bb9da82569d6110d73f316b8bd35/plugins/xsettings/csd-xsettings-manager.c#L560 https://github.com/linuxmint/cinnamon-settings-daemon/blob/e1cd34de9ab9bb9da82569d6110d73f316b8bd35/plugins/xsettings/csd-xsettings-manager.c#L685-L686
So let's look at an example, if TEXT_SCALING_FACTOR
is set to be 1.2
, and window_scale
is set to be 2
, i.e., for HiDPI, then get_dpi_from_gsettings
will give (double) 96 * 1.2
, so scaled_dpi
will be *`(int) 96 1.2 2 1024**, i.e.,
235929, finally,
Xft.dpiwill be set to
(double) 235929 / 1024.0, which is
230.3994140625`, and is not an integer. Then QT cannot recognize it, and fallback to DPI=96, according to QTBUG-64738 and www/Specifications/XSettingsRegistry
One more thing about the TEXT_SCALING_FACOTR
. If this number is a multiple of 1/(2^16 × 3)
(window_scale=2
) or 1/(2^15 x 3)
(window_scale=1
), then scaled_dpi
will be an integer
, instead of a rounded one from a double
.
widget = GSettingsSpinButton(_("Text scaling factor"), "org.cinnamon.desktop.interface", "text-scaling-factor", step=0.1, size_group=size_group)
the step is set to be 0.1
, which will cause scaled_dpi
to be rounded from a float, then Xft.dpi
to be a non-integer.
Finally, I think https://github.com/linuxmint/Cinnamon/issues/4902#issuecomment-502331390 is also related to this issue.
@wereturtle are you still experiencing this issue?
@icarter09 I don't know. I switched to KDE plasma. But I know it still happens in Gnome 3. I presume Cinnamon lifted from it?
Right now, Cinnamon, and pretty much all other GTK-based desktops, have great difficulty adjusting the font DPI and hinting/antialiasing settings for both GTK applications and Qt5 applications. Qt5 applications do not honor the GTK+ settings, because they get their settings differently than Qt4 ones.
I know it has been brought up here before a long time ago, and that the thought was that the Qt devs needed to add support for Mate and Cinnamon in their code. However, after multiple bug reports have been filed over the years in the Qt bug tracker, I'm thinking this isn't entirely the case, especially since desktops like Gnome 3 suffer from the same issue.
From the few responses we have from the Qt devs, it seems that GTK-based desktops are expected to do something special to set font DPI and hinting/antialiasing, though I'm not sure what. However, there have been workarounds discovered. Can some of these be worked into the Cinnamon settings manager? I'm more of a Qt app programmer, but I'd be willing to learn GTK and pitch in.
First, it appears that Qt5 applications do honor fontconfig settings (except for DPI) in the user's ~/.config/fontconfig/fonts.conf file. Interestingly enough, the qt5ct tool is setting the Qt5 font hinting/antialiasing by creating this file. Is this the best way for the Cinnamon settings manager to go about setting the Qt5 font hinting? By similarly creating a ~/.config/fontconfig/fonts.conf file? At the end of this bug report/feature request is sample content for what works.
Second, the only way I've found to change the Qt5 applications' font DPI is to add a call to xrandr in my Startup Applications settings, like so:
Obviously, this isn't something we would want to hard code into the Cinnamon settings manager. Is there an API for xrandr? How do we ensure that the DPI setting is retained upon reboot? Is there an xrandr configuration file Cinnamon uses?
Sorry for the questions. I'm not sure what is the best way to tackle the problem. I am willing to learn, however, and to try to code and test some possible solutions.
FYI, the Gnome team have been developing the QGnomePlatform tool, which is somewhat similar to qt5ct. Perhaps we can merge in their solution?
I know that I could just use qt5ct or continue with my hack, but I'm thinking about all the novice Linux transitioners, how they just want everything to work seamlessly without a fuss.
Thanks in advance. Below is my current fonts.conf file, as an example:
Below are some links to existing bug reports filed against Qt. Contained are some of the solutions I listed above, plus valuable Qt dev feedback.
QTBUG-29582 QTBUG-48632 QTBUG-50174