Posts: 80
Rademes
Joined: 26 Dec 2016
#1
How to change fonts (type, size, hinting, geometry) for Qt5 applications by editing configuration files?

For Qt4 applications there is qt4-qtconfig utility available in default repository, and if you don't want to install it, you can edit Trolltech.conf file.
With Qt5 things are much worse. There is no utility for configuring available in repositories, some portals advice to use qt5ct, but it needs to be compiled and tweaked, so it is difficult for me.
Any ideas?
Last edited by Rademes on 23 Jan 2017, 07:57, edited 2 times in total.
Posts: 2,238
dolphin_oracle
Joined: 16 Dec 2007
#2
we have a Trolltech.conf file in mx with this:

Code: Select all

[Qt]
style=GTK+
which appears to allow gtk theme changes, including font, to flow thru to qt apps, as long as the app isn't set to override the font.
Posts: 80
Rademes
Joined: 26 Dec 2016
#3
That works with Qt4 applications only.
Here is my Trolltech.conf file:
Image
And here is shown, how its settings not working with Qt5 applications:
Image

Image
VLC and qBittorrent are Qt4 applications, their fonts are the same as GTK application fonts.
But qpdfview is Qt5 application, and it still has default small font. Same situation is with phototonic, which also Qt5 application, and also has small font.
There must be some other settings available for Qt5 applications.
Oh, and for some reasons qpdfview name does not shown in the taskbar...

Update: I can not compile qt5ct, because it requires:
- qtbase >= 5.4.0
- qtsvg >= 5.4.0 (For svg icons)
- qttools >= 5.4.0 (For build only)
But in repositories only versions 5.3.2 are available. __{{emoticon}}__
Posts: 80
Rademes
Joined: 26 Dec 2016
#4
I was able to set Qt5 applications fonts like rest gtk2 fonts after adding string to file /etc/environment:

Code: Select all

QT_STYLE_OVERRIDE=gtk
So this is solved.
Now I want to set sub-pixel geometry for Qt4 and Qt5 fonts, because for now they still refuse to accept sub-pixel geometry settings.
Problem with sub-pixel geometry solved by creating XML file ~/.fonts.conf with following content:

Code: Select all

<?xml version='1.0'?>

<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>

<fontconfig>
    <match target="font" >
        <edit mode="assign" name="rgba" >
            <const>rgb</const>
        </edit>
    </match>
    
    <match target="font" >
        <edit mode="assign" name="hinting" >
            <bool>true</bool>
        </edit>
    </match>
    
    <match target="font" >
        <edit mode="assign" name="hintstyle" >
            <const>hintfull</const>
        </edit>
    </match>
    
    <match target="font" >
        <edit mode="assign" name="antialias" >
            <bool>true</bool>
        </edit>
    </match>
</fontconfig>
Now all Qt4 and Qt5 fonts look great, just like default GTK2 fonts with appropriate size, hinting, antialiasing and sub-pixel geometry! __{{emoticon}}__
I think, these adjustments should be included in antiX release by default, because without them Qt5 application's fonts look very bad, but Qt4 application's fonts are without proper sub-pixel geometry, why I said proper, because nowadays most PC users have LCD monitors, so RGB geometry is the most suitable for them. Also it is much easier for users to modify existing configuration file instead of creating a new one in case something doesn't satisfy them.
Would be great to hear @anticapitalista and @dolphin_oracle opinions about including these adjustments in antiX release by default.
Update: For applications running under root account (NUetbootin) this file should be placed to /root directory (/root/.fonts.conf). I also changed ownership to root for this file, but I am not sure whether it is necessary or not.
Posts: 1,445
skidoo
Joined: 09 Feb 2012
#5
Thanks for the tips, Rademes !

hopefully a mod will move this topic to"tips-n-tricks" subforum

For anyone who wants to test the before-n-after from applying these tweaks:
The preinstalled"smtube","luckybackup" and"unetbootin" utilize QT4
and"antix-installer" (minstall) and"iso-snapshot-antix" (isosnapshot) both utilize QT5
Posts: 1,445
skidoo
Joined: 09 Feb 2012
#6
I can not compile qt5ct, because it requires:
- qtbase >= 5.4.0
- qtsvg >= 5.4.0 (For svg icons)
- qttools >= 5.4.0 (For build only)
But in repositories only versions 5.3.2 are available.
Enable the"debian testing" respository and recheck; you'll find debian stretch ("testing" repo) has:
qtbase5-dev (5.7.1+dfsg-2)
libqt5svg5-dev (5.7.1~20161021-2)
qttools5-dev (5.7.1-1)

Before you pursue building it, glance at these:

========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"https://github.com/mati75/qt5ct/commit/ce09b9d74504322c8891f047d6fffc967967ced8"
linktext was:"https://github.com/mati75/qt5ct/commit/ ... 967967ced8"
====================================


========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"https://github.com/mati75/qt5ct/commit/51e147cd15fcb5771ced5804817f0801ecfb9107"
linktext was:"https://github.com/mati75/qt5ct/commit/ ... 01ecfb9107"
====================================

and
consider adding this patch before building (IMO, the patch is important/necessary)

========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"https://sourceforge.net/p/qt5ct/tickets/28/"
linktext was:"https://sourceforge.net/p/qt5ct/tickets/28/"
====================================


The github comment indicates that after installing qt5ct, you need to edit .xsession file and add a line:
export QT_QPA_PLATFORMTHEME=qt5ct
(and it will take effect after your next logout/login)
Posts: 80
Rademes
Joined: 26 Dec 2016
#7
Thank you for instruction, but I prefer not touch testing repositories. Besides, current Qt5 font settings fully satisfy me, so I will not build qt5ct.
Update: Qt5 applications running under root such as antix-installer and iso-snapshot-antix still use small default fonts, but sub-pixel geometry works correctly. Looks like QT_STYLE_OVERRIDE=gtk works only for currently running account.

========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"https://s24.postimg.org/ojlivrrcl/Qt5_root.png"
linktext was:"https://s24.postimg.org/ojlivrrcl/Qt5_root.png"
====================================
Last edited by Rademes on 19 Jan 2017, 11:00, edited 1 time in total.
Posts: 1,445
skidoo
Joined: 09 Feb 2012
#8
FYI, there's a related recent topic"Making QT apps fit with GTK" at bunsenlabs forum

========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"https://forums.bunsenlabs.org/viewtopic.php?id=3192"
linktext was:"https://forums.bunsenlabs.org/viewtopic.php?id=3192"
====================================

In post #3 there, he suggests editing ~.xsession
Posts: 80
Rademes
Joined: 26 Dec 2016
#9
Also I have noticed, that Qt5 application names are not displayed in IceWM desktop environment:

========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"https://s29.postimg.org/smoo4iejr/Qt5_names.png"
linktext was:"https://s29.postimg.org/smoo4iejr/Qt5_names.png"
====================================

skidoo wrote:FYI, there's a related recent topic"Making QT apps fit with GTK" at bunsenlabs forum

========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"https://forums.bunsenlabs.org/viewtopic.php?id=3192"
linktext was:"https://forums.bunsenlabs.org/viewtopic.php?id=3192"
====================================

In post #3 there, he suggests editing ~.xsession
Added this file to /root/.xsession - no effect. Qt5 apps launched by root still have small fonts.
Posts: 1,445
skidoo
Joined: 09 Feb 2012
#10
Unless someone points out that doing so would be counterproductive, I support the suggestion to enable anti-aliasing + full (or medium) hinting in the default configuration. (For CRT displays, aren't those settings simply ignored?)

Personally, until the time we're using a significant number of QT4/QT5 applications, I'm not inclined to fuss/wrestle with how to possibly, maybe, hopefully tweak a given QT app. It has become a sad state of affairs -- app authors have become so pissed from packagers/designers/themers wrecking their work (and triggering gobs of 'bug' reports) that many are going out of their way to enforce their own app specific theming (and, yes, font declarations). Bloat, bloat, bloat because many authors are now compelled to bundle hardcoded dependent theme/font resources.

FWIW, right now the only QT-based apps I go out of my way to install are a couple games

========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"https://gottcode.org/"
linktext was:"https://gottcode.org/"
====================================

(authored by the same fella who created"Whisker Menu" addon for xfce)
I've heard no complaints from folks for whom I've preinstalled those games into remastered antiX16 installs.
Currently,"tanglet" and"connectagram" are installed here & across the months I've tested with various PCs (intel, nvidia, amd) using nouveau driver. Throughout my testing, the game screens have always been well-rendered.

Whichever specific app(s) you're wrestling with, I'm suggesting you should investigate/determine whether the the app author is enforcing an app-specific font/theming override.
Posts: 80
Rademes
Joined: 26 Dec 2016
#11
skidoo wrote:Unless someone points out that doing so would be counterproductive, I support the suggestion to enable anti-aliasing + full (or medium) hinting in the default configuration. (For CRT displays, aren't those settings simply ignored?)
Thank You for support, skidoo!
Modifying and/or deleting existing configuration files is much easier than creating new ones, especially when you don't know how to create, where to create and forced to search the solution through various forums, like I did.
Posts: 2,238
dolphin_oracle
Joined: 16 Dec 2007
#12
I just worked on an issue with missing icons for some of the mx-tool apps on antiX (qt5).

I used this to launch, for instance, mx-compton

Code: Select all

env XDG_CURRENT_DESKTOP=LXDE mx-compton
thanks to some info in the arch wiki.


========= SCRAPER REMOVED AN EMBEDDED LINK HERE ===========
url was:"https://wiki.archlinux.org/index.php/qt"
linktext was:"https://wiki.archlinux.org/index.php/qt"
====================================
Configuration of Qt5 apps under environments other than KDE Plasma
Unlike Qt4, Qt5 doesn't ship a qtconfig utility to configure fonts, icons or styles. Instead, it will try to use the settings from the running DE. In KDE Plasma or GNOME this works well, but in other less popular DEs or WM it can lead to missing icons in Qt5 applications. One way to solve this is to fake the running desktop environment by setting XDG_CURRENT_DESKTOP=KDE or GNOME, and then using the corresponding configuration application to set the desired icon set.
This appeared to effect fonts as well. I changed the gtk font to bold and it seems to have carried through.
Posts: 2,238
dolphin_oracle
Joined: 16 Dec 2007
#13
I've been doing more work on this qt5 thing, because many of the mx-tools are qt5 and at least a couple I would like to work on my antix install.
Rademes wrote:Oh, and for some reasons qpdfview name does not shown in the taskbar...
icwem has a problem with the title bars and qt5. gtk settings won't affect those, so there is something else going on there with icewm. fluxbox and jwm do not exhibit this problem.

Thanks for getting the ball rolling on this stuff!
Posts: 80
Rademes
Joined: 26 Dec 2016
#14
dolphin_oracle wrote: icwem has a problem with the title bars and qt5. gtk settings won't affect those, so there is something else going on there with icewm. fluxbox and jwm do not exhibit this problem.
Today installed Qupzilla (uses Qt 5.3.2), and it also has problem with name on title bar and taskbar.
Image
Anyway, there is some work needs to be done with IceWM. I wonder, if author still supports IceWM?
Posts: 2,238
dolphin_oracle
Joined: 16 Dec 2007
#15
Rademes wrote:
dolphin_oracle wrote: icwem has a problem with the title bars and qt5. gtk settings won't affect those, so there is something else going on there with icewm. fluxbox and jwm do not exhibit this problem.
Today installed Qupzilla (uses Qt 5.3.2), and it also has problem with name on title bar and taskbar.
Image
Anyway, there is some work needs to be done with IceWM. I wonder, if author still supports IceWM?

i installed the icewm from testing, and qt5 apps did have titles. however, I couldn't launch my own mx-compton from the menu. ran fine from the rox terminal, and the menu entry does look correct.