[SOLVED] Text rendering for Qt programs on gnome

Everything about X, Gnome, KDE, ... and everything running on it

[SOLVED] Text rendering for Qt programs on gnome

Postby nixmd » 2018-07-07 09:05

Hi, I just have installed debian 9 using gnome live image. Almost everything was good so far (except a few things like trust.gpg and netwoking service which could be solved easily). But when I tried to open a qt program (qtcreator actually) fonts were broken and ugly. Tried a few things like playing with /etc/fonts/ config files but it's still sh*t. Dunno what to do.
Last edited by nixmd on 2018-07-09 06:29, edited 1 time in total.
nixmd
 
Posts: 4
Joined: 2018-07-07 08:56

Re: Text rendering for Qt programs on gnome

Postby Head_on_a_Stick » 2018-07-07 09:07

nixmd wrote:Tried a few things like playing with /etc/fonts/ config files

Please list everything you have tried in order to prevent duplication of effort by any who choose to assist you.

Here is a general guide for making Qt applications work in a Gtk desktop:

https://wiki.archlinux.org/index.php/Un ... plications

It is intended for Arch but can be adapted for Debian.
Charlie don't hack
User avatar
Head_on_a_Stick
 
Posts: 7635
Joined: 2014-06-01 17:46
Location: /dev/chair


Re: Text rendering for Qt programs on gnome

Postby nixmd » 2018-07-07 12:37

Head_on_a_Stick wrote:Please list everything you have tried in order to prevent duplication of effort by any who choose to assist you.


I configure my rendering in ${HOME}/.Xresources:
Code: Select all
Xft.antialias:  1
Xft.autohint:   0
Xft.dpi:        96
Xft.hinting:    0
Xft.hintstyle:  hintnone
Xft.lcdfilter:  lcddefault
Xft.rgba:       rgb


Also I install fonts-croscore, fonts-crosextra-caladea and fonts-crosextra-carlito ($sudo apt install fonts-cros\*).

/etc/fonts/local.conf:
Code: Select all
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">

<fontconfig>
  <match target="font">      <edit mode="append" name="antialias">   <bool>true</bool>      </edit></match>
  <match target="font">      <edit mode="append" name="autohint">   <bool>false</bool>      </edit></match>
  <match target="font">      <edit mode="append" name="hintstyle">   <const>hintnone</const>      </edit></match>
  <match target="font">      <edit mode="append" name="hinting">   <bool>false</bool>      </edit></match>
  <match target="pattern">   <edit mode="append" name="lcdfilter">   <const>lcddefault</const>   </edit></match>

 <alias>
  <family>sans-serif</family>
   <prefer>
    <family>Noto Sans</family>
    <family>Arimo</family>
    <family>Liberation Sans</family>
    <family>DejaVu Sans</family>
   </prefer>
 </alias>

 <alias>
  <family>serif</family>
   <prefer>
    <family>Noto Serif</family>
    <family>Tinos</family>
    <family>Liberation Serif</family>
    <family>DejaVu Serif</family>
   </prefer>
 </alias>

 <alias>
  <family>monospace</family>
   <prefer>
    <family>Noto Mono</family>
    <family>Cousine</family>
    <family>Liberation Mono</family>
    <family>DejaVu Sans Mono</family>
   </prefer>
 </alias>

<match target="pattern">
  <test compare="eq" name="family" qual="any"><string>Verdana</string></test>
  <edit binding="same" mode="prepend" name="family"><string>DejaVu Sans</string></edit>
</match>

<match target="pattern">
  <test compare="eq" name="family" qual="any"><string>Arial Black</string></test>
  <edit binding="same" mode="prepend" name="family"><string>DejaVu Sans</string></edit>
  <edit mode="assign" name="weight"><double>200</double></edit>
</match>

<match target="font"> <!-- Switch off hinging for DejaVu Sans -->
  <test compare="eq" name="family" qual="any"><string>DejaVu Sans</string></test>
  <edit name="hinting" mode="assign"><bool>false</bool></edit>
</match>

<match target="pattern">
  <test compare="eq" name="family" qual="any"><string>Tahoma</string></test>
  <edit binding="same" mode="prepend" name="family"><string>Noto Sans</string></edit>
</match>

<match target="pattern">
  <test compare="eq" name="family" qual="any"><string>Arial</string></test>
  <edit binding="same" mode="prepend" name="family"><string>Arimo</string></edit>
</match>

<match target="pattern">
  <test compare="eq" name="family" qual="any"><string>Times New Roman</string></test>
  <edit binding="same" mode="prepend" name="family"><string>Tinos</string></edit>
</match>

<match target="pattern">
  <test compare="eq" name="family" qual="any"><string>Georgia</string></test>
  <edit binding="same" mode="prepend" name="family"><string>Noto Serif</string></edit>
</match>

<match target="pattern">
  <test compare="eq" name="family" qual="any"><string>Impact</string></test>
  <edit binding="same" mode="prepend" name="family"><string>Noto Serif</string></edit>
  <edit mode="assign" name="weight"><double>200</double></edit>
</match>

<match target="pattern">
  <test compare="eq" name="family" qual="any"><string>Courier New</string></test>
  <edit binding="same" mode="prepend" name="family"><string>Nimbus Mono L</string></edit>
</match>

<match target="pattern">
  <test compare="eq" name="family" qual="any"><string>Trebuchet MS</string></test>
  <edit binding="same" mode="prepend" name="family"><string>Linux Biolinum O</string></edit>
</match>

<match target="pattern">
  <test compare="eq" name="family" qual="any"><string>Lucida Console</string></test>
  <edit binding="same" mode="prepend" name="family"><string>DejaVu Sans Mono</string></edit>
</match>

<match target="pattern">
  <test compare="eq" name="family" qual="any"><string>Lucida Sans Unicode</string></test>
  <edit binding="same" mode="prepend" name="family"><string>DejaVu Sans</string></edit>
</match>

<match target="pattern">
  <test compare="eq" name="family" qual="any"><string>Palatinio Linotype</string></test>
  <edit binding="same" mode="prepend" name="family"><string>URW Palladio L</string></edit>
 </match>

<match target="pattern">
  <test compare="eq" name="family" qual="any"><string>Consolas</string></test>
  <edit binding="same" mode="prepend" name="family"><string>Inconsolata</string></edit>
</match>

</fontconfig>
nixmd
 
Posts: 4
Joined: 2018-07-07 08:56

Re: Text rendering for Qt programs on gnome

Postby stevepusser » 2018-07-07 16:04

In MX Linux, we get Qt 5 programs to follow the GTK look in xfce4 by adding a /etc/X11/Xsession.d/98qtconfig file with the contents:

Code: Select all
[ "$XDG_CURRENT_DESKTOP" != "KDE" ] && {
        export QT_QPA_PLATFORMTHEME=gtk2
        export QT_PLATFORMTHEME=gtk2
        export QT_PLATFORM_PLUGIN=gtk2
}


I think it will work in GNOME if you chose a theme with both GTK 2 and 3 support; Arc is one such.
The MX Linux repositories: Backports galore! If we don't have something, just ask and we'll try--we like challenges. New packages: GIMP 2.10.2, Pale Moon 27.9.3, wine-staging 3.11, QuiteRSS 0.18.11, Linux kernel 4.17, Krita 4.1.0
User avatar
stevepusser
 
Posts: 9709
Joined: 2009-10-06 05:53

Re: Text rendering for Qt programs on gnome

Postby nixmd » 2018-07-08 01:34

stevepusser wrote:In MX Linux, we get Qt 5 programs to follow the GTK look in xfce4 by adding a /etc/X11/Xsession.d/98qtconfig file with the contents:

Code: Select all
[ "$XDG_CURRENT_DESKTOP" != "KDE" ] && {
        export QT_QPA_PLATFORMTHEME=gtk2
        export QT_PLATFORMTHEME=gtk2
        export QT_PLATFORM_PLUGIN=gtk2
}


I think it will work in GNOME if you chose a theme with both GTK 2 and 3 support; Arc is one such.


tried that. didn't work

This is actually what I get here.
left is text in Qt, right is in Gtk

Image
nixmd
 
Posts: 4
Joined: 2018-07-07 08:56

Re: Text rendering for Qt programs on gnome

Postby Head_on_a_Stick » 2018-07-08 15:50

nixmd wrote:I configure my rendering in ${HOME}/.Xresources

That file is not read by all programs.

Use ~/.config/fontconfig/fonts.conf, try this for more information:
Code: Select all
zcat /usr/share/doc/fontconfig/fontconfig-user.txt.gz

You local.conf file has an almost correct stanza in it but also a lot of nonsense so strip it out.

Here's my fonts.conf for aliasing and hinting, note that the settings are "assign"ed rather than "append"ed as in your file, I don't know how much difference that makes:
Code: Select all
<fontconfig>
    <match target="font">
        <edit mode="assign" name="hinting" >
            <bool>true</bool>
        </edit>
        <edit mode="assign" name="autohint" >
            <bool>true</bool>
        </edit>
        <edit mode="assign" name="hintstyle" >
            <const>hintslight</const>
        </edit>
        <edit mode="assign" name="rgba" >
            <const>rgb</const>
        </edit>
        <edit mode="assign" name="antialias" >
            <bool>true</bool>
        </edit>
        <edit mode="assign" name="lcdfilter">
            <const>lcddefault</const>
        </edit>
    </match>
</fontconfig>

nixmd wrote:tried that. didn't work

Did you also install the qt5-style-plugins & libqt5svg5 packages? They are required in my dwm desktop:

Image

^ As you can see, my fonts are lovely under Qt5 :)
Charlie don't hack
User avatar
Head_on_a_Stick
 
Posts: 7635
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: Text rendering for Qt programs on gnome

Postby nixmd » 2018-07-09 06:28

Thanks @Head_on_a_Stick
I tried fonts.conf and now my fonts are nice and good looking!
nixmd
 
Posts: 4
Joined: 2018-07-07 08:56


Return to Desktop & Multimedia

Who is online

Users browsing this forum: No registered users and 9 guests

fashionable