[Tutorial] Managing fonts

Date: December 25, 2023 7:25 AM

Difficulty: ★★★☆☆ (I don’t find it difficult. But then, I like using the terminal…)

Tons of fonts get installed on Linux systems and that makes the font scroll list in editors or word processors painfully long. Then I found a solution using ~/.config/fontconfig/fonts.conf, thanks to CMarch on the Endeavour OS forum:

Also see:
Whitelist and blacklist fonts.
https://wiki.archlinux.org/index.php/Font_configuration#Whitelisting_and_blacklisting_fonts

This solution is easy to implement, can be easily modified, and can be used over and over. A benefit is the fonts are not deleted, they just don’t show up in your user session.

Edit your ~/.config/fontconfig/fonts.conf file and:

  1. Put the fonts you do not want to see in the <rejectfont> section.
  2. Put any fonts from the above rejection groups that you might want to keep in the <acceptfont> section.
  3. Fonts not added to the <rejectfont> section will not be affected.

My ~/.config/fontconfig/fonts.conf, as example:

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'urn:fontconfig:fonts.dtd'>
<fontconfig>
[...]

    <!--
    Added by Mirdarthos, to hide some of the fonts.
    -->
    <selectfont>
        <rejectfont>
            <glob>/usr/share/fonts/noto/Noto*</glob>
            <glob>/usr/share/fonts/noto-cjk/*</glob>
            <glob>/usr/share/fonts/encodings/*</glob>
            <glob>/usr/share/fonts/misc/*</glob>
            <glob>/usr/share/fonts/adobe-source-code-pro/*</glob>
            <glob>/usr/share/fonts/TTF/Noto*</glob>
            <glob>/usr/share/fonts/TTF/Inconsolata-*</glob>
            <glob>/usr/share/fonts/TTF/Inconsolata-*</glob>
            <glob>/usr/share/fonts/droid/*</glob>
            <glob>/usr/share/fonts/cyrillic/*</glob>
            <glob>/usr/share/fonts/droid/*</glob>
        </rejectfont>
        <!--
        <acceptfont>
            <glob>/usr/share/fonts/noto/NotoSans-*</glob>
            <glob>/usr/share/fonts/noto/NotoSerif-*</glob>
            <glob>/usr/share/fonts/gsfonts/NimbusMono*</glob>
            <glob>/usr/share/fonts/gsfonts/NimbusRoman*</glob>
            <glob>/usr/share/fonts/gsfonts/NimbusSans*</glob>
            <glob>/usr/share/fonts/gsfonts/URW*</glob>
        </acceptfont>
        -->
    </selectfont>
    <!--
    End of Mirdarthos' edits
    -->
</fontconfig>

Note:

There was a lot of things already in the file, I just left everything as-is and added the <selectfont></selectfont> section at the end of the file inside the <fontconfig></fontconfig> section.

Note #2:

As this is in your $HOME directory, please remember that it will not affect other users, current or future.

5 Likes

If you use Plasma desktop, this can be easily done via Plasma Font Management interface, you can disable personal fonts for current user, or system fonts for all users

3 Likes

If someone has a issue with missing icon fonts, see the solution: :point_down:

2 Likes

Wow, that’s tasty.

Amazing that I hated this issue for quite a while now.

1 Like