Font configuration/fontconfig examples - ArchWiki

# Font configuration/fontconfig examples

Configurations can vary to a degree. Please post Fontconfig configurations with an explanation for why they were done.

## brebs' configuration

This article or section needs language, wiki syntax or style improvements.

Reason: Rewrite in impersonal style. (Discuss in Talk:Font configuration/fontconfig examples#)

This is a quest to get all fonts looking beautiful at all sizes, weights, etc., by tweaking the Fontconfig rules for Infinality rendering. The latest version is maintained here -- brebs

### Basic config with no hinting for italic or bold and some other tuning

    <?xml version='1.0'?>
    <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
    <fontconfig>
      <match target="font" >
        <edit mode="assign" name="autohint">  <bool>true</bool></edit>
        <edit mode="assign" name="hinting">	  <bool>false</bool></edit>
        <edit mode="assign" name="lcdfilter"> <const>lcddefault</const></edit>
        <edit mode="assign" name="hintstyle"> <const>hintslight</const></edit>
        <edit mode="assign" name="antialias"> <bool>true</bool></edit>
        <edit mode="assign" name="rgba">      <const>rgb</const></edit>
      </match>

      <match target="font">
        <test name="pixelsize" qual="any" compare="more"><double>15</double></test>
        <edit mode="assign" name="lcdfilter"><const>lcdlight</const></edit>
        <edit mode="assign" name="hintstyle"><const>hintnone</const></edit>
      </match>

      <match target="font">
        <test name="weight" compare="more"><const>medium</const></test>
        <edit mode="assign" name="hintstyle"><const>hintnone</const></edit>
        <edit mode="assign" name="lcdfilter"><const>lcdlight</const></edit>
      </match>

      <match target="font">
        <test name="slant"  compare="not_eq"><double>0</double></test>
        <edit mode="assign" name="hintstyle"><const>hintnone</const></edit>
        <edit mode="assign" name="lcdfilter"><const>lcdlight</const></edit>
      </match>

    </fontconfig>

### Sharp fonts

It took me a while to find font settings that are sharp and not overly blurred. This font config does exactly that and seems to work fine everywhere. I searched for this because "Chromium" wasn't looking good with no aliasing at all. The below config fixes that as well.

    <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
    <fontconfig>
      <match target="font">
        <edit name="antialias" mode="assign"><bool>true</bool></edit>
        <edit name="hinting" mode="assign"><bool>true</bool></edit>
        <edit name="hintstyle" mode="assign"><const>hintfull</const></edit>
        <edit name="lcdfilter" mode="assign"><const>lcddefault</const></edit>
        <edit name="rgba" mode="assign"><const>rgb</const></edit>
      </match>
    </fontconfig>

## Liberation Font configuration

For font consistency, all applications should be set to use the serif, sans-serif, and monospace aliases, which are mapped to particular fonts by fontconfig. The Liberation fonts were chosen to follow metric-compatibility of the MS Core 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>hintslight</const></edit>
            <edit mode="assign" name="lcdfilter"><const>lcddefault</const></edit>
            <edit mode="assign" name="rgba"><const>rgb</const></edit>
        </match>

        <match target="pattern">
            <test qual="any" name="family"><string>serif</string></test>
            <edit name="family" mode="assign" binding="same"><string>Liberation 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>Liberation Sans</string></edit>
        </match>
        <match target="pattern">
            <test qual="any" name="family"><string>monospace</string></test>
            <edit name="family" mode="assign" binding="same"><string>Liberation Mono</string></edit>
        </match>

        <match target="pattern">
            <edit name="dpi" mode="assign"><double>96</double></edit>
        </match>
    </fontconfig>

Category:

- Fonts