< Font configuration

Font configuration/Examples

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

See Font configuration for the main article.

Hinted fonts

~/.config/fontconfig/fonts.conf
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
  <match target="font">
    <edit mode="assign" name="antialias">
      <bool>true</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>
</fontconfig>

No hinting for italic or bold

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig: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>

Enable anti-aliasing only for bigger fonts

Some users prefer the sharper rendering that anti-aliasing does not offer:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
  <match target="font">
    <edit name="antialias" mode="assign">
      <bool>false</bool>
    </edit>
  </match>

  <match target="font" >
    <test name="size" qual="any" compare="more">
      <double>12</double>
    </test>
    <edit name="antialias" mode="assign">
      <bool>true</bool>
    </edit>
  </match>

  <match target="font" >
    <test name="pixelsize" qual="any" compare="more">
      <double>16</double>
    </test>
    <edit name="antialias" mode="assign">
      <bool>true</bool>
    </edit>
  </match>
</fontconfig>

Disable bold font

For when a font does not present itself well in bold and you cannot disable bold fonts in the application (st for example).

...
<match target="pattern">
    <test qual="any" name="family">
        <string>Envy Code R</string>
    </test>
    <test name="weight" compare="more">
        <const>medium</const>
    </test>
    <edit name="weight" mode="assign" binding="same">
        <const>medium</const>
    </edit>
</match>
...

Disable ligatures for monospaced fonts

This prevents letter combinations like "ffi" from being squashed into a single-width character in some monospaced fonts. The whole <match> block needs to be duplicated to include extra fonts.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
  <description>Disable ligatures for monospaced fonts to avoid ff, fi, ffi, etc. becoming only one character wide</description>

  <match target="font">
    <test name="family" compare="eq" ignore-blanks="true">
      <string>Nimbus Mono PS</string>
    </test>
    <edit name="fontfeatures" mode="append">
      <string>liga off</string>
      <string>dlig off</string>
    </edit>
  </match>
</fontconfig>

Some other fonts may also require disabling features such as calt and/or clig.

You can test the effectiveness of this with the following command:

$ echo -e "| worksheet |\n| buffering |\n| difficult |\n| finishing |\n| different |\n| efficient |" | pango-view --font="Nimbus Mono PS" /dev/stdin

Some programs (such as Firefox) do not support the fontfeatures tag, so for those replacing the font with another is the only option. See Font configuration#Set default or fallback fonts for details.

Default fonts

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. See Metric-compatible fonts for options and examples.

Arabic

Example fonts.conf which specifies a default font for the Arabic language and keeps western style fonts for Latin letters. You will require either ttf-arabeyes-fontsAUR or for the below to work. You can also choose to install any other Arabic fonts and accordingly change the font name below based on your preference

The above should work for most applications but some applications like Chromium do not work with the language match test. If you find some applications not using your selected fonts, you can use the below alias and prefer tags which seems to work.

Japanese

Example fonts.conf which also specifies a default font for the Japanese locale (ja_JP) and keeps western style fonts for Latin letters.

Chinese in Noto Fonts

Apply Noto Fonts while replacing Microsoft Fonts with WenQuanYi Micro Hei

~/.config/fontconfig/fonts.conf
or
/etc/fonts/local.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "urn:fontconfig:fonts.dtd">
<fontconfig>
    <match target="font">
        <edit name="embeddedbitmap" mode="assign">
            <bool>false</bool>
        </edit>
    </match>
    <match>
        <test qual="any" name="family">
            <string>serif</string>
        </test>
        <edit name="family" mode="prepend" binding="strong">
            <string>Noto Serif</string>
        </edit>
    </match>
    <match target="pattern">
        <test qual="any" name="family">
            <string>sans-serif</string>
        </test>
        <edit name="family" mode="prepend" binding="strong">
            <string>Noto Sans</string>
        </edit>
    </match>
    <match target="pattern">
        <test qual="any" name="family">
            <string>monospace</string>
        </test>
        <edit name="family" mode="prepend" binding="strong">
            <string>Noto Sans Mono</string>
        </edit>
    </match>
    <match>
        <test name="lang" compare="contains">
            <string>zh</string>
        </test>
        <test name="family">
            <string>serif</string>
        </test>
        <edit name="family" mode="prepend">
            <string>Noto Serif CJK SC</string>
        </edit>
    </match>
    <match>
        <test name="lang" compare="contains">
            <string>zh</string>
        </test>
        <test name="family">
            <string>sans-serif</string>
        </test>
        <edit name="family" mode="prepend">
            <string>Noto Sans CJK SC</string>
        </edit>
    </match>
    <match>
        <test name="lang" compare="contains">
            <string>zh</string>
        </test>
        <test name="family">
            <string>monospace</string>
        </test>
        <edit name="family" mode="prepend">
            <string>Noto Sans Mono CJK SC</string>
        </edit>
    </match>

    <!--WenQuanYi Zen Hei -> WenQuanYi Micro Hei -->
    <match target="pattern">
        <test qual="any" name="family">
            <string>WenQuanYi Zen Hei</string>
        </test>
        <edit name="family" mode="assign" binding="same">
            <string>WenQuanYi Micro Hei</string>
        </edit>
    </match>
    <match target="pattern">
        <test qual="any" name="family">
            <string>WenQuanYi Zen Hei Lite</string>
        </test>
        <edit name="family" mode="assign" binding="same">
            <string>WenQuanYi Micro Hei Lite</string>
        </edit>
    </match>
    <match target="pattern">
        <test qual="any" name="family">
            <string>WenQuanYi Zen Hei Mono</string>
        </test>
        <edit name="family" mode="assign" binding="same">
            <string>WenQuanYi Micro Hei Mono</string>
        </edit>
    </match>

    <!--Microsoft YaHei, SimHei, SimSun -> WenQuanYi Micro Hei -->
    <match target="pattern">
        <test qual="any" name="family">
            <string>Microsoft YaHei</string>
        </test>
        <edit name="family" mode="assign" binding="same">
            <string>WenQuanYi Micro Hei</string>
        </edit>
    </match>
    <match target="pattern">
        <test qual="any" name="family">
            <string>SimHei</string>
        </test>
        <edit name="family" mode="assign" binding="same">
            <string>WenQuanYi Micro Hei</string>
        </edit>
    </match>
    <match target="pattern">
        <test qual="any" name="family">
            <string>SimSun</string>
        </test>
        <edit name="family" mode="assign" binding="same">
            <string>WenQuanYi Micro Hei</string>
        </edit>
    </match>
    <match target="pattern">
        <test qual="any" name="family">
            <string>SimSun-18030</string>
        </test>
        <edit name="family" mode="assign" binding="same">
            <string>WenQuanYi Micro Hei</string>
        </edit>
    </match>
</fontconfig>

CJK, but other Latin fonts are preferred

Requires noto-fonts-cjk.

You can replace // with your favorite // fonts.

Alternate stylistic sets for fonts

Certain fonts come with alternate stylistic sets for characters through an OpenType feature. Generally these stylistic sets are named and contain small changes to individual characters. This shows how to change the default dotted zero to a slashed zero for the monospace version of ttf-ibm-plex.

See What are "Stylistic Sets?" for more information on this.

gollark: I think Go→WASM also exists.
gollark: I'm sure there's a JS/Rust/Go FFI thing.
gollark: And also serverless.
gollark: In the cloud!
gollark: <@237328509234708481> You need to use a blockchain, too!

See also

This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.