Home | News | Download | Packages | Forum | Wiki | Github

Please share your fontconfig configuration


#1

Today my new collegue at work (with his macbook) was looking at my screen and said: “Oh my god your fonts looks so ugly”. My fonts look okay but compared to his OS X he was right! It looked much better than mine…

That’s why I created tis thread…

  • Which steps have you done to get nice font rendering on void?
  • How does your fontconfig configuration look like?
  • etc…

Please share your experiences.

For me the only thing I have done was putting the folling config to ~/.config/fontconfig/fonts.conf:

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
  <!--
  <dir>~/.local/share/fonts</dir>
  -->
  <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>

Thx for your expertise. :slight_smile:


#2

robiha fixed my fontconfig problems and provided this link:

http://blog.brunomiguel.net/geekices/how-to-get-good-font-rendering-in-void-linux

thanks robiha


#3

Thx but that was exactly the link I posted to him… :wink: I do not get better font rendering with it… :confused:


(Nonico) #4

I use Openbox, so I’m not sure how much it will help.

  1. I create a new file in /etc/fonts/

  2. Name the file local.conf

  3. …and copy and paste the following into it…

         <?xml version="1.0"?>
         <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
         <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>
    
         <!-- Set preferred serif, sans serif, and monospace fonts. -->
             <alias>
                 <family>serif</family>
                 <prefer>
                     <family>Droid Serif</family>
                 </prefer>
             </alias>
             <alias>
                 <family>sans-serif</family>
                 <prefer>
                     <family>Droid Sans</family>
                 </prefer>
             </alias>
             <alias>
                 <family>sans</family>
                 <prefer>
                     <family>Droid Sans</family>
                 </prefer>
             </alias>
             <alias>
                 <family>monospace</family>
                 <prefer>
                     <family>Droid Sans Mono</family>
                 </prefer>
             </alias>
             <alias>
                 <family>mono</family>
                 <prefer>
                     <family>Droid Sans Mono</family>
                 </prefer>
             </alias>
    
         </fontconfig>
    

Save and close the file. Log out/in, and fonts look better.

Disclaimer #1: This has worked on any Openbox system that I’ve tried…whether Arch, Debian/Devuan, Slackware-based, Ubuntu, or Calculate Linux with Openbox…and now Void.
Disclaimer #2: Despite the fonts listed in the file, I use the Ubuntu font as my system font, and that seems to give me the best font rendering.


#5

Thank you very much this looks great. I will give it a try asap and report… :slight_smile:


#6

I’m very picky about font rendering and in my experience the fontconfig configuration has to match the fonts for best results. Most of my fonts look blurry with autohint, but some few absolutely need it. As seen in the “How to get good font rendering” screenshot, hintslight causes blur and uneven stroke width, so you typically want hintfull, except at huge sizes where hintslight can sometimes give smoother edges at the expense of some blur.

My config, no further changes required apart from installing the fonts:

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<match target="font">
    <edit mode="assign" name="antialias"><bool>true</bool></edit>
    <edit mode="assign" name="autohint"><bool>false</bool></edit>
    <edit mode="assign" name="embeddedbitmap"><bool>false</bool></edit>
    <edit mode="assign" name="hinting"><bool>true</bool></edit>
    <edit mode="assign" name="hintstyle"><const>hintfull</const></edit>
    <edit mode="assign" name="lcdfilter"><const>lcddefault</const></edit>
    <edit mode="assign" name="rgba"><const>rgb</const></edit>
    <alias><family>monospace</family><prefer><family>Consolas</family></prefer></alias>
    <alias><family>sans-serif</family><prefer><family>Meiryo UI</family></prefer></alias>
    <alias><family>serif</family><prefer><family>Times New Roman</family></prefer></alias>
</match>
<match target="font">
    <test name="family"><string>Consolas</string></test>
    <edit mode="assign" name="autohint"><bool>true</bool></edit>
    <edit mode="assign" name="rgba"><const>none</const></edit>
</match>
<match target="font">
    <test name="family"><string>IPAex明朝</string></test>
    <edit mode="assign" name="autohint"><bool>true</bool></edit>
    <edit mode="assign" name="rgba"><const>none</const></edit>
</match>
<match target="font">
    <test name="family"><string>Meiryo</string></test>
    <test name="pixelsize" compare="more_eq"><double>20.0</double></test>
    <edit mode="assign" name="hintstyle"><const>hintslight</const></edit>
</match>
<match target="font">
    <test name="family"><string>Meiryo UI</string></test>
    <test name="pixelsize" compare="more_eq"><double>20.0</double></test>
    <edit mode="assign" name="hintstyle"><const>hintslight</const></edit>
</match>
</fontconfig>

I haven’t yet found any libre fonts that can compete with the Microsoft ones, so the config is optimized for those. If you don’t care about Japanese characters, you can use Arial or even Tahoma instead of Meiryo UI. They all look nice in GUIs.

For code and terminals, nothing beats Consolas IMHO. With the right fontconfig it looks stunning at any size and resolution. Unfortunately it’s buggy, i.e. its glyphs are slightly offset vertically. So out of the box it can look weird in some applications, most notably urxvt. To fix this, the font can be patched using these instructions: https://wincent.com/wiki/Fixing_the_baseline_on_the_Consolas_font_on_OS_X this script: https://gist.github.com/commandtab/4b04b479b256fa243f95.

As mentioned in the blog post, you can also experiment with FREETYPE_PROPERTIES=truetype:interpreter-version=. I used to prefer 35 (“Classic”) because it is the finest and crispest, but this setting is generally incompatible with Chromium-based browsers and there can be occasional gaps at certain angles. There’s zero difference between 38 (“Infinality”) and 40 (“Minimal”, the default) in any western fonts I use. For CJK fonts the former can be ever so slightly broader in rare cases, but the difference is hard to spot, even in direct comparison.


#7

Thx for this detailed reply. :slight_smile: I will have a deep look into it later when I have more time and report…