5

xubuntu-desktop installs by default many non-latin fonts, which is great for asian or arabic users but clutters my (western-user) interface to pick a font in the fonts list.

So I did remove many fonts I never use:

sudo apt-get remove --purge fonts-beng fonts-beng-extra fonts-deva fonts-deva-extra fonts-gargi fonts-gubbi fonts-gujr fonts-gujr-extra fonts-guru fonts-guru-extra fonts-indic fonts-kalapi
  fonts-khmeros-core fonts-knda fonts-lao fonts-lklug-sinhala fonts-lohit-beng-assamese fonts-lohit-beng-bengali fonts-lohit-deva fonts-lohit-gujr fonts-lohit-guru
  fonts-lohit-knda fonts-lohit-mlym fonts-lohit-orya fonts-lohit-taml fonts-lohit-taml-classical fonts-lohit-telu fonts-mlym fonts-nakula fonts-navilu 
  fonts-orya fonts-orya-extra fonts-pagul fonts-sahadeva fonts-samyak-deva fonts-samyak-gujr fonts-samyak-mlym
  fonts-samyak-taml fonts-sarai fonts-sil-abyssinica fonts-sil-padauk fonts-smc fonts-smc-anjalioldlipi fonts-smc-chilanka fonts-smc-dyuthi fonts-smc-gayathri
  fonts-smc-karumbi fonts-smc-keraleeyam fonts-smc-manjari fonts-smc-meera fonts-smc-rachana fonts-smc-raghumalayalamsans fonts-smc-suruma fonts-smc-uroob fonts-taml
  fonts-telu fonts-telu-extra fonts-thai-tlwg fonts-tibetan-machine fonts-tlwg-garuda fonts-tlwg-garuda-ttf fonts-tlwg-kinnari fonts-tlwg-kinnari-ttf fonts-tlwg-laksaman
  fonts-tlwg-laksaman-ttf fonts-tlwg-loma fonts-tlwg-loma-ttf fonts-tlwg-mono fonts-tlwg-mono-ttf fonts-tlwg-norasi fonts-tlwg-norasi-ttf fonts-tlwg-purisa
  fonts-tlwg-purisa-ttf fonts-tlwg-sawasdee fonts-tlwg-sawasdee-ttf fonts-tlwg-typewriter fonts-tlwg-typewriter-ttf fonts-tlwg-typist fonts-tlwg-typist-ttf fonts-tlwg-typo
  fonts-tlwg-typo-ttf fonts-tlwg-umpush fonts-tlwg-umpush-ttf fonts-tlwg-waree fonts-tlwg-waree-ttf fonts-yrsa-rasa 
  fonts-noto-core fonts-noto-hinted fonts-noto-ui-core  fonts-noto-cjk

And thus my fonts list (in LibreOffice or Inkscape, a.o.) became much more useable, huray !

But this purge had the side-effect of removing xubuntu-default-settings (depending on fonts-noto-hinted), and thus xubuntu-core and xubuntu-desktop as well... meaning most of my software (including LibreOffice) is now on the apt autoremove list... so I can't clean my installs anymore.

How can I remove these non latin fonts while keeping the software stack of xubuntu-desktop untouched ?

I tried to reinstall xubuntu-desktop without recommended packages but to no avail (due to dependency on fonts-noto):

sudo apt-get install --no-install-recommends xubuntu-desktop

I also tried to Pin all these fonts to never install via adding to /etc/apt/preferences:

Package: <all fonts packages>
Pin: release *
Pin-Priority: -1

But my problem remained.

Berteh
  • 111
  • 6
  • 4
    Simple answer: You can't. You may want to call the Xubuntu developers' attention to it. Or accept that the Xubuntu distro relies on the fonts-noto-core and fonts-noto-ui-core packages being present. – Gunnar Hjalmarsson Oct 18 '20 at 20:04
  • 1
    When removing packages this way, you'll get a confirmation of any packages that will also need to get removed as a result of them being dependent on the ones you are removing. Instead of using a single command to wipe them all out, you can issue them one by one or in small batches so that you can audit what else they will remove. Keep the packages that are dependencies for packages you need – Nmath Oct 18 '20 at 21:11

3 Answers3

6

One workaround is to install Font Manager:

sudo apt install font-manager

... and then disable the ones you won't use (like most Noto fonts) I disabled over 180 fonts this way, things run a lot better. They're still "installed" but no other programs on your system will see them. Unless you have limited drive space and every kilobyte counts that's the way to go. Still don't have a clue why at least 100 fonts very few users will ever need are a dependency! enter image description here

DrGecko
  • 234
fixitmanarizona
  • 190
  • 1
  • 7
  • This tool is extremely useful! However it seems to be necessary to check each font individually (407 fonts on my system…). I did not find a way to deselect at once all fonts that don't contain one certain orthography, which would be the orthography that I need for my language. – w-sky Jul 25 '23 at 14:37
  • That is probably correct. However, it wasn't a huge problem for me as English is my primary language, and uses roman alphabet based alphabet. I re-selected several other fonts so that non-roman alphabets can still show, but I did not leave many. I haven't tried the "language" tab (at bottom left on the picture above.) I would imagine that would show a particular language that you can select? – fixitmanarizona Jul 27 '23 at 02:46
2

Following @gunnar-hjalmarsson's pointer I left the fonts on with the metapackage had strong depegdencies installed (fonts-noto-core fonts-noto-hinted fonts-noto-ui-core)... and removed only the 'recommended' ones that are installed by default in the (X)Ubuntu install process:

sudo apt-get remove --purge fonts-beng fonts-beng-extra fonts-deva \
    fonts-deva-extra fonts-gargi fonts-gubbi fonts-gujr fonts-gujr-extra \
    fonts-guru fonts-guru-extra fonts-indic fonts-kalapi fonts-khmeros-core \
    fonts-knda fonts-lao fonts-lklug-sinhala fonts-lohit-beng-assamese \
    fonts-lohit-beng-bengali fonts-lohit-deva fonts-lohit-gujr \
    fonts-lohit-guru fonts-lohit-knda fonts-lohit-mlym fonts-lohit-orya \
    fonts-lohit-taml fonts-lohit-taml-classical fonts-lohit-telu fonts-mlym \
    fonts-nakula fonts-navilu fonts-orya fonts-orya-extra fonts-pagul \
    fonts-sahadeva fonts-samyak-deva fonts-samyak-gujr fonts-samyak-mlym \
    fonts-samyak-taml fonts-sarai fonts-sil-abyssinica fonts-sil-padauk \
    fonts-smc fonts-smc-anjalioldlipi fonts-smc-chilanka fonts-smc-dyuthi \
    fonts-smc-gayathri fonts-smc-karumbi fonts-smc-keraleeyam \
    fonts-smc-manjari fonts-smc-meera fonts-smc-rachana \
    fonts-smc-raghumalayalamsans fonts-smc-suruma fonts-smc-uroob fonts-taml \
    fonts-telu fonts-telu-extra fonts-thai-tlwg fonts-tibetan-machine \
    fonts-tlwg-garuda fonts-tlwg-garuda-ttf fonts-tlwg-kinnari \
    fonts-tlwg-kinnari-ttf fonts-tlwg-laksaman fonts-tlwg-laksaman-ttf\
    fonts-tlwg-loma fonts-tlwg-loma-ttf fonts-tlwg-mono fonts-tlwg-mono-ttf \
    fonts-tlwg-norasi fonts-tlwg-norasi-ttf fonts-tlwg-purisa \
    fonts-tlwg-purisa-ttf fonts-tlwg-sawasdee fonts-tlwg-sawasdee-ttf \
    fonts-tlwg-typewriter fonts-tlwg-typewriter-ttf fonts-tlwg-typist \
    fonts-tlwg-typist-ttf fonts-tlwg-typo fonts-tlwg-typo-ttf \
    fonts-tlwg-umpush fonts-tlwg-umpush-ttf fonts-tlwg-waree \
    fonts-tlwg-waree-ttf fonts-yrsa-rasa fonts-noto-cjk

DrGecko
  • 234
Berteh
  • 111
  • 6
1

Let's first take a minute to appreciate the accomplishment that is Noto. It's certainly a noble thing to want users of any language from Afar to Zulu to be able to see all the characters of their native writing system on their computers, by default, out of the box.

Sadly, the technical implementation (at least for Debian-derived Linux distros) leaves a lot to be desired because of the hundreds of separate fonts that comprise Noto. As you note, these clog up font menus and make selecting from the fonts for the languages you actually use more of a chore.


As pointed out in fixitmanarizona's answer, you can disable the ones you don't want to see. I believe this accomplishes your goal without removing individual font packages—thus risking breaking other packages which depend on those fonts.

Font Manager creates a ~/.config/fontconfig/conf.d/78-Reject.conf with fonts that you've deselected with its GUI. The downside to this, of course, is that you'd have to do that over a hundred times to deselect all the Noto Sans fonts that only support non-Western scripts, times all the systems that you use.

Below is a Perl script that will do that for you. Use it like this:

mkdir -p ~/.config/fontconfig/conf.d
perl fc-reject.pl > ~/.config/fontconfig/conf.d/88-reject.conf

This will hide any fonts in the $rejectfam regular expression which don't specify $mylang (also a RE) as one of their supported languages. For me that was 120 fonts that I don't have to scroll through anymore, in janky font selection drop-downs like LibreOffice's—quite a relief!

If you wish to name the file something else besides 88-reject.conf, just make sure it ends in .conf and begins with two digits. This is a requirement for fontconfig to find it.

Testing if it worked

You can see whether or not it worked by grepping the output of fc-list for fonts that you're sure should be excluded, like Linear A.

fc-list | grep 'Linear A'

There should be no output, or at least no Noto fonts in the output.

Undoing / disabling what the script does

To undo what the script has done simply remove the .conf file. Changes take effect immediately. Some programs may need to be restarted, though.

You can momentarily disable the config (re-enabling all the excluded fonts) by renaming it to not have a .conf extension, like so:

# e.g., for the Bash shell
mv 88-reject.conf{,.disabled}

Incidentally, visiting the Wikipedia article for Linear A is an effective test to see if Noto is doing its job. That is, if the font is properly installed, you should see "no tofu" (no Unicode replacement symbols) in that article.

The fc-reject.pl script

#!/usr/bin/env perl
# Usage:   fc-reject.pl > ~/.config/fontconfig/conf.d/88-reject.conf
# Author:  https://askubuntu.com/users/681614
# License: CC-BY-SA-4.0 (see https://askubuntu.com/help/licensing)
use v5.12;
use warnings;
use autodie;

my $mylang = 'en'; # use '(en|lang1|lang2)' for other languages my $rejectfam = 'Noto'; # use '(Noto|Other Family|Another Family)' for others my $rejectlist = {};

open my $fh, '-|', 'fc-cat'; while (<$fh>) { if (/.* "([^:,]+).:lang=([^:]):.*/) { my ($name, $lang) = ($1, $2); if ($name =~ /$rejectfam/ and (!$lang or $lang !~ /$mylang/)) { $rejectlist->{$name} = 1; } } } close $fh;

print <<EOF; <?xml version="1.0"?> <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> <fontconfig> <selectfont> <rejectfont> EOF

foreach my $name (keys %$rejectlist) { print <<EOF; <pattern> <patelt name="family"> <string>$name</string> </patelt> </pattern> EOF }

print <<EOF; </rejectfont> </selectfont> </fontconfig> EOF

This was tested on an Ubuntu 20.04 derivative (elementaryOS 6.1 Jólnir). Your mileage with other distros may vary.

Kevin E
  • 141