Skip to content

Instantly share code, notes, and snippets.

@ernstki
Last active December 16, 2025 23:30
Show Gist options
  • Select an option

  • Save ernstki/2ae279ad89888e4099c9852bf0ba5d11 to your computer and use it in GitHub Desktop.

Select an option

Save ernstki/2ae279ad89888e4099c9852bf0ba5d11 to your computer and use it in GitHub Desktop.
Easily disable fonts that aren't in your language, for Debian and derivatives (and possibly other Linux distros)

Noto is an impressive accomplishment, no doubt. And it's a noble thing to want to enable all the people of the world to see their native writing systems accurately represented 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. These clog up font menus and make selecting from the fonts for the languages you actually use more of a chore.

This script allows you to selectively disable fonts that don't support your language(s), but easily re-enable them if necessary. While this is technically possible with point-and-click interfaces like Font Manager, it can take hundreds of clicks to get them all.1

It's a much better solution than what is commonly recommended, which is to remove a bunch of font packages, upon which other packages often depend. This can result in a broken system, or at least accidental removal of some applications that you didn't intend to remove.

Installation

GIST='https://gist.githubusercontent.com/ernstki/2ae279ad89888e4099c9852bf0ba5d11/raw/fc-reject.pl'
curl -Lo fc-reject.pl $GIST || wget -O fc-reject.pl $GIST
mkdir -p ~/.config/fontconfig/conf.d

# assuming the Bash shell
chmod a+x fc-reject.pl
./fc-reject.pl > ~/.config/fontconfig/conf.d/88-reject.conf.new && \
mv ~/.config/fontconfig/conf.d/88-reject.conf{.new,}

This will hide any fonts matching the $filterfam regular expression which don't specify $mylangs (also a regexp) as one of their supported languages. This greatly reduces the length of font selection drop-downs in applications like GIMP or LibreOffice, making it easier to find the fonts you do use.

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.

Tip

As suggested by @DJGoossens below, you may be able to re-use the same filename Font Manager uses, or at least copy-paste the relevant parts from the output of fc-reject.pl into an existing config. This allows you to employ the Font Manager GUI for further refinements.

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:

fc-list | grep Devanagari

There should be no output, or at least no Noto fonts in the output. Obviously I'm writing this from the perspective of a Westerner who can't read non-Latin scripts, so substitute with something appropriate for you.

There may be rare cases (which I haven't encountered) where you need to regenerate fontconfig's caches from scratch. If you run into that situation

fc-cache -rv

should do the trick for that.

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 ~/.config/fontconfig/conf.d/88-reject.conf{,.disabled}

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

See also

Footnotes

  1. …at least with the version of Font Manager that's in the LTS repositories as of this writing

#!/usr/bin/env perl
##
## Easily disable fonts that aren't for your language, or language-specific
## variants from large font families like Noto -- WITHOUT uninstalling them
##
## Authors: Kevin Ernst <ernstki -at- mail.uc.edu>, @wdoekes
## License: MIT or CC-BY-SA-4.0, at your option
## Source: https://gist.github.com/ernstki/2ae279ad89888e4099c9852bf0ba5d11
##
## Usage:
## ./fc-reject.pl > ~/.config/fontconfig/conf.d/88-reject.conf.new && \
## mv ~/.config/fontconfig/conf.d/88-reject.conf{.new,}
##
use v5.12;
use warnings;
use autodie;
my $rejectlist = {};
# languages I want to keep, e.g., my native language plus 'und-zsye' for emoji
# (ref: https://www.unicode.org/reports/tr35)
my $mylangs = 'en|de|und-zsye';
# reject these fonts unconditionally, even if they claim to support my language
# (easier than uninstalling; they may be depends/recommends for other packages)
my $rejectfam = '^(Kacst|AR PL|Noto.*CJK)'; # Arabic and East Asian scripts
# filter out language-specific font variants for languages I don't use from any
# font family matched by the $filterfam regexp
my $filterfam = '^Noto';
# always keep fonts that match the $keepfam regexp, regardless of lang. support
my $keepfam = '^Noto (Music|Symbols|Sans Linear [AB])';
open my $fh, '-|', 'fc-cat';
while (<$fh>) {
# a typical line of output from `fc-cat` looks like this:
# "NotoSerifHebrew-Regular.ttf" 0 "Noto Serif Hebrew:…:lang=he(|…):…
# …which would yield $name = 'Noto Serif Hebrew' and @langs = ('he')
if (/.* "([^:,]+).*:lang=([^:]*)/) {
my ($name, @langs) = ($1, split(/\|/, $2));
next if $name =~ /$keepfam/;
if ($name =~ /$rejectfam/) {
$rejectlist->{$name} = 1;
next;
}
if ($name =~ /$filterfam/) {
unless (@langs) {
# if you want to retain any of these, add to $keepfam, above
warn "Family '$name' specified no languages\n";
$rejectlist->{$name} = 1;
next;
}
$rejectlist->{$name} = 1 unless map { /$mylangs/ } @langs;
}
}
}
close $fh;
print <<EOF;
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<selectfont>
<rejectfont>
EOF
foreach my $name (sort keys %$rejectlist) {
print <<EOF;
<pattern>
<patelt name="family">
<string>$name</string>
</patelt>
</pattern>
EOF
}
print <<EOF;
</rejectfont>
</selectfont>
</fontconfig>
EOF
# vim: shiftwidth=4 tabstop=4 expandtab
@wdoekes
Copy link

wdoekes commented Jan 19, 2025

Hope you're OK with the original license (MIT).

Anything is fine. Thanks for asking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment