Ubuntu – How to disable unused asiatic fonts

aptfontslibreofficelocalizationpackage-management

I'm configuring Ubuntu 18.04 LTS PCs for a school in Italy, and I've seen that more than 200 fonts got installed as dependencies of ubuntu-desktop package.

We don't need most of them, we don't expect tipycal users to write or read documents in Bengali or Thai, for example. Actually, so many fonts make font choices more difficult for our users (for example in LibreOffice), because it makes difficult for them to find useful fonts.

Is there a way to disable those non-Latin fonts system wide, so they don't appear in applications?

I know I could manually remove them (for example purging fonts-tlwg-* packages), but I want to keep them installed, so single users can enable them later on if needed, without affecting other users of the same system.

Best Answer

There's no need to uninstall any package, since fontconfig provides a way to blacklist some fonts or paths, and exclude them as if they didn't exist in the system.

You just need to add a few lines like these in system or user configuration:

<selectfont>
    <rejectfont>
    <glob>/usr/share/fonts/truetype/fonts-beng-extra/*</glob>
    </rejectfont>
</selectfont>

Where to put configuration

  • To disable those fonts system wide you put those instructions in /etc/fonts/local.conf
  • To disable those fonts for just one user you put them in ~/.config/fontconfig/fonts.conf

To set the default behaviour for each new user, put this configuration in /etc/skel/.config/fontconfig/fonts.conf.

This way unwanted fonts are disabled by default, but users can still enable them back editing their own fontconfig configuration file (this last approach seems more versatile for my use case).

Obviously if you put this configuration in /etc/skel/ it won't affect existing users. They need to manually copy it in their own home directories to make it work.

Example configuration

Here's my full fonts.conf file, that disable all non-latin fonts I don't need. It lives in ~/.config/fontconfig/fonts.conf.

This not only make fonts list shorter, but also make some applications such as LibreOffice a little faster, since they need to cope with less fonts to preview, and user can still enable some fonts for him/herself if needed, without affecting other users and without administrator privileges.

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <!-- disable non-latin fonts -->
    <selectfont>
        <rejectfont>
        <glob>/usr/share/fonts/opentype/malayalam/*</glob>
        <glob>/usr/share/fonts/opentype/noto/*CJK*</glob>
        <glob>/usr/share/fonts/truetype/abyssinica/*</glob>
        <glob>/usr/share/fonts/truetype/fonts-beng-extra/*</glob>
        <glob>/usr/share/fonts/truetype/fonts-deva-extra/*</glob>
        <glob>/usr/share/fonts/truetype/fonts-gujr-extra/*</glob>
        <glob>/usr/share/fonts/truetype/fonts-guru-extra/*</glob>
        <glob>/usr/share/fonts/truetype/fonts-kalapi/*</glob>
        <glob>/usr/share/fonts/truetype/fonts-orya-extra/*</glob>
        <glob>/usr/share/fonts/truetype/fonts-telu-extra/*</glob>
        <glob>/usr/share/fonts/truetype/Gargi/*</glob>
        <glob>/usr/share/fonts/truetype/Gubbi/*</glob>
        <glob>/usr/share/fonts/truetype/kacst/*</glob>
        <glob>/usr/share/fonts/truetype/kacst-one/*</glob>
        <glob>/usr/share/fonts/truetype/lao/*</glob>
        <glob>/usr/share/fonts/truetype/lohit*</glob>
        <glob>/usr/share/fonts/truetype/malayalam/*</glob>
        <glob>/usr/share/fonts/truetype/Nakula/*</glob>
        <glob>/usr/share/fonts/truetype/Navilu/*</glob>
        <glob>/usr/share/fonts/truetype/padauk/*</glob>
        <glob>/usr/share/fonts/truetype/pagul/*</glob>
        <glob>/usr/share/fonts/truetype/Sahadeva/*</glob>
        <glob>/usr/share/fonts/truetype/samyak/*</glob>
        <glob>/usr/share/fonts/truetype/samyak-fonts/*</glob>
        <glob>/usr/share/fonts/truetype/Sarai/*</glob>
        <glob>/usr/share/fonts/truetype/sinhala/*</glob>
        <glob>/usr/share/fonts/truetype/tibetan-machine/*</glob>
        <glob>/usr/share/fonts/truetype/tlwg/*</glob>
        <glob>/usr/share/fonts/truetype/ttf-khmeros-core/*</glob>
        </rejectfont>
    </selectfont>
</fontconfig>

References