Skip to content

Instantly share code, notes, and snippets.

@SohamG
Last active October 3, 2024 18:30
Show Gist options
  • Save SohamG/6b8830cc08a22bc5bc24c76ef799510a to your computer and use it in GitHub Desktop.
Save SohamG/6b8830cc08a22bc5bc24c76ef799510a to your computer and use it in GitHub Desktop.
Fix emoji in Linux and get color emoji in Discord! Place this fontconfig file in ~/.config/fontconfig/fonts.conf
<?xml version="1.0"?><!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!-- REQUIRES Noto fonts (along with Noto Color Emoji)
run `fc-list | grep -i -e "noto sans" -e "noto serif" -e "noto color emoji"` to confirm
-->
<!-- Change the string in the family tag to whatever font -->
<family>serif</family>
<prefer><family>Noto Serif</family></prefer>
</alias>
<alias>
<family>sans-serif</family>
<prefer><family>Noto Sans</family></prefer>
</alias>
<alias>
<family>sans</family>
<prefer><family>Noto Sans</family></prefer>
</alias>
<alias>
<family>monospace</family>
<prefer><family>Noto Mono</family></prefer>
</alias>
<!-- This adds Noto Color Emoji to the font families sans, serif, sans-serif and monospace -->
<match target="pattern">
<test name="family"><string>monospace</string></test>
<edit name="family" mode="append"><string>Noto Color Emoji</string></edit>
</match>
<match target="pattern">
<test name="family"><string>sans</string></test>
<edit name="family" mode="append"><string>Noto Color Emoji</string></edit>
</match>
<match target="pattern">
<test name="family"><string>serif</string></test>
<edit name="family" mode="append"><string>Noto Color Emoji</string></edit>
</match>
<!-- Discord loads the system's sans-serif font family, add Noto Color Emoji to it -->
<match target="pattern">
<test name="family"><string>sans-serif</string></test>
<edit name="family" mode="append"><string>Noto Color Emoji</string></edit>
</match>
<!-- Add emoji generic family -->
<alias binding="strong">
<family>emoji</family>
<default><family>Noto Color Emoji</family></default>
</alias>
<!-- Alias requests for the other emoji fonts -->
<alias binding="strong">
<family>Apple Color Emoji</family>
<prefer><family>Noto Color Emoji</family></prefer>
<default><family>emoji</family></default>
</alias>
<alias binding="strong">
<family>Segoe UI Emoji</family>
<prefer><family>Noto Color Emoji</family></prefer>
<default><family>emoji</family></default>
</alias>
<!-- Run "fc-cache -fv" after saving the file and kill and restart whichever app (like discord) and enjoy emoji -->
</fontconfig>
@Jojodicus
Copy link

Jojodicus commented Feb 15, 2022

missing <alias> between line 7 and 8

@SohamG
Copy link
Author

SohamG commented Feb 15, 2022 via email

@Shijikori
Copy link

there's a <alias> beacon missing between line 7 & 8 in the current revision.

Thanks a lot for the snippet. I've been using for quite a while :)

@BWindey
Copy link

BWindey commented Sep 20, 2024

UPDATE: it works, I just hadn't installed the colour-emojis 🤦

This isn't working for me. I downloaded the script and saved it to the ~/.config/fontconfig/fonts.conf, fixed the missing <alias> tag, and updated the font cache with fv-cache -fv, and restarted Discord.
image
image

As you can see in the images, emojis don't render with color when in username, servername or channelname. The other ones in text or as reactions seem to render properly.

The whole noto family, including emojis, is installed, and detected by fv-cache.

I'm on void linux, with i3 wm.

@SohamG
Copy link
Author

SohamG commented Oct 3, 2024

I no longer use this so I can't help, sorry.

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