4

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.

0
3

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

2

@gerlos's answer is great, but, personally, I don't like specifying individual folders for each language. This feels a bit cumbersome and seems fragile.

An alternative could be to exclude all fonts that do not support the desired language(s), e.g. English (en) in my case.

The user config file (~/.config/fontconfig/fonts.conf) could then look something like this:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<!-- $XDG_CONFIG_HOME/fontconfig/fonts.conf for per-user font configuration -->
<fontconfig>
  <selectfont>
    <!-- reject all fonts -->
    <rejectfont>
      <pattern>
      </pattern>
    </rejectfont>
    <!-- accept only fonts that support english -->
    <acceptfont>
      <pattern>
        <patelt name="lang">
          <string>en</string>
        </patelt>
      </pattern>
    </acceptfont>
  </selectfont>
</fontconfig>

If this is too restrictive, we can accept additional fonts as required.

1
  • Very interesting solution! I didn't know you can specify a language, it seems a more robust approach. Choosing a single language it's too restrictive for me, since I'm living in Europe and I often read/write contents in different languages, but I guess I could rework this solution to accept everything and then reject Asian languages I won't need. I'll give it a try!
    – gerlos
    Nov 8 '20 at 10:17
1

Please note that ubuntu-desktop recommends most of those fonts packages; it does not depend on them. Hence you should be able to safely remove fonts packages and still keep ubuntu-desktop.

1
  • 1
    Right, I actually misunderstood what happens when a package recommends another one. So I can safely remove them. Nevertheless, leaving them installed and disabling them in default user configuration can still be useful in a school, since some of them can be needed by single students, and enabled/disabled per-user, without any administrative privileges. I edited the question.
    – gerlos
    May 4 '19 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.