Howto: Improve font rendering

Share your own howto's etc. Not for support questions!

Howto: Improve font rendering

Postby Hallvor » 2018-02-02 13:32

What's wrong with the default font rendering?
If you like the default one, then nothing. But people have different preferences... For those of you than have been around for a while, there is probably not much to learn here. This is mainly targeted at beginners.

Fonts.conf
We will make a hidden .fonts.conf configuration file in the home directory. These settings will be loaded on each boot. (To remove these configurations, simply delete the file.)

Create the file as regular user in your home directory:

Code: Select all
nano .fonts.conf


Copy and paste the 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>hintslight</const>
  </edit>
 </match>
 <match target="font">
  <edit mode="assign" name="antialias">
   <bool>true</bool>
  </edit>
 </match>
  <match target="font">
  <edit mode="assign" name="lcdfilter">
    <const>lcddefault</const>
  </edit>
  </match>
</fontconfig>


Save with Ctrl + X, and then Y to exit.

Better font rendering in the web browser
Your web browser may be configured to let all web pages use their own fonts. Some pages may render very well, while others may look pretty bad.

In order to fix this issue, you may want to install the following fonts (as root):

Code: Select all
apt-get install ttf-freefont ttf-mscorefonts-installer ttf-bitstream-vera ttf-dejavu ttf-liberation


All done! After a reboot, you should have better font rendering.

The image below is enlarged, so the fonts look sharper on my screen:
Image
Last edited by Hallvor on 2018-02-03 09:06, edited 2 times in total.
HP Elitebook 2570p, Intel Core i5 3320-M CPU @ 2.60 GHz, 6 GB RAM, Intel HD 4000 graphics, 240 GB SSD, Debian Stretch (KDE)
User avatar
Hallvor
 
Posts: 815
Joined: 2009-04-16 18:35
Location: Norway

Re: Howto: Improve font rendering

Postby Bulkley » 2018-02-02 17:34

Question, should it be .fonts.conf or .config/fontconfig/fonts.conf ?
Bulkley
 
Posts: 5579
Joined: 2006-02-11 18:35

Re: Howto: Improve font rendering

Postby Hallvor » 2018-02-02 17:39

All of these should work:

/etc/fonts/fonts.conf
/etc/fonts/fonts.dtd
/etc/fonts/conf.d
$XDG_CONFIG_HOME/fontconfig/conf.d
$XDG_CONFIG_HOME/fontconfig/fonts.conf
~/.fonts.conf.d
~/.fonts.conf

Source: https://www.freedesktop.org/software/fo ... -user.html
HP Elitebook 2570p, Intel Core i5 3320-M CPU @ 2.60 GHz, 6 GB RAM, Intel HD 4000 graphics, 240 GB SSD, Debian Stretch (KDE)
User avatar
Hallvor
 
Posts: 815
Joined: 2009-04-16 18:35
Location: Norway

Re: Howto: Improve font rendering

Postby pawRoot » 2018-02-03 03:45

Didn't test your config but i just FINALLY discovered a way for perfect fonts, a bit different
than yours but anyway...

Code: Select all
apt install -y fontconfig fonts-noto ttf-dejavu ttf-liberation


create /etc/fonts/local.conf
Code: Select all
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <match>
        <edit mode="prepend" name="family"><string>Noto Sans</string></edit>
    </match>
    <match target="pattern">
        <test qual="any" name="family"><string>serif</string></test>
        <edit name="family" mode="assign" binding="same"><string>Noto Serif</string></edit>
    </match>
    <match target="pattern">
        <test qual="any" name="family"><string>sans-serif</string></test>
        <edit name="family" mode="assign" binding="same"><string>Noto Sans</string></edit>
    </match>
    <match target="pattern">
        <test qual="any" name="family"><string>monospace</string></test>
        <edit name="family" mode="assign" binding="same"><string>Noto Mono</string></edit>
    </match>
</fontconfig>


create .gtkrc-2.0 in your home directory or just modify it if it exist:
Code: Select all
gtk-xft-antialias=1
gtk-xft-hinting=1
gtk-xft-hintstyle="hintslight"
gtk-xft-rgba="rgb"


same about .config/gtk-3.0/settings.ini
Code: Select all
gtk-xft-antialias=1
gtk-xft-hinting=1
gtk-xft-hintstyle=hintslight
gtk-xft-rgba=rgb


and my ~/.Xresources
Code: Select all
Xft.autohint: 1
Xft.antialias: 1
Xft.hinting: true
Xft.hintstyle: hintslight
Xft.rgba: rgb
Xft.lcdfilter: lcddefault


Code: Select all
sudo ln -s /etc/fonts/conf.avail/10-sub-pixel-rgb.conf /etc/fonts/conf.d


Although i am not sure if you need to edit those 3 files above if you have fontconfig,
so would be nice if someone experienced could confirm.

I will post screenshot soon
Last edited by pawRoot on 2018-02-03 13:14, edited 1 time in total.
User avatar
pawRoot
 
Posts: 509
Joined: 2016-12-28 18:26
Location: Poland

Re: Howto: Improve font rendering

Postby pawRoot » 2018-02-03 12:25

Here is how they look:

Image
User avatar
pawRoot
 
Posts: 509
Joined: 2016-12-28 18:26
Location: Poland


Return to Docs, Howtos, Tips & Tricks

Who is online

Users browsing this forum: No registered users and 4 guests

fashionable