Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[SOLVED] Text rendering for Qt programs on gnome

Graphical Environments, Managers, Multimedia & Desktop questions.
Post Reply
Message
Author
nixmd
Posts: 4
Joined: 2018-07-07 08:56

[SOLVED] Text rendering for Qt programs on gnome

#1 Post by nixmd »

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.

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Text rendering for Qt programs on gnome

#2 Post by Head_on_a_Stick »

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.
deadbang

User avatar
debiman
Posts: 3063
Joined: 2013-03-12 07:18

Re: Text rendering for Qt programs on gnome

#3 Post by debiman »

it seems you're not the only one....

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

Re: Text rendering for Qt programs on gnome

#4 Post by nixmd »

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>

User avatar
stevepusser
Posts: 12930
Joined: 2009-10-06 05:53
Has thanked: 41 times
Been thanked: 71 times

Re: Text rendering for Qt programs on gnome

#5 Post by stevepusser »

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.
MX Linux packager and developer

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

Re: Text rendering for Qt programs on gnome

#6 Post by nixmd »

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

User avatar
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: Text rendering for Qt programs on gnome

#7 Post by Head_on_a_Stick »

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 :)
deadbang

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

Re: Text rendering for Qt programs on gnome

#8 Post by nixmd »

Thanks @Head_on_a_Stick
I tried fonts.conf and now my fonts are nice and good looking!

Post Reply