Last active
April 30, 2024 10:19
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
## | |
## Usage: fc-reject.pl > ~/.config/fontconfig/conf.d/88-reject.conf | |
## Author: Kevin Ernst <ernstki -at- mail.uc.edu> | |
## License: MIT or CC-BY-SA-4.0, at your option | |
## Source: https://gist.github.com/ernstki/2ae279ad89888e4099c9852bf0ba5d11 | |
## | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
On Ubuntu 22.04 you might want to re-enable the emoji by removing
Noto Color Emoji
from the output. Otherwise you won't even see the 👍 in GitHub.And maybe
Noto Music
andNoto Sans Symbols
andNoto Sans Symbols2
-- although I'm not sure how often you run into those.As for the harmless warning, I suggest:
The atomic mv ensures that only the complete file is read.
Thanks for this gist, @ernstki !
My changes: