2

I have set Source Code Pro as my default monospace font and Noto Color Emoji for emojis, set in fontconfig as follows:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <alias>
    <family>serif</family>
    <prefer>
      <family>Noto Color Emoji</family>
      <family>DejaVu Sans</family>
    </prefer>
  </alias>
  <alias>
    <family>sans-serif</family>
    <prefer>
      <family>Noto Color Emoji</family>
      <family>DejaVu Serif</family>
    </prefer>
  </alias>
  <alias>
    <family>monospace</family>
    <prefer>
      <family>Noto Color Emoji</family>
      <family>Source Code Pro</family>
    </prefer>
  </alias>
</fontconfig>

This works fine for Gnome apps, but my terminal [Allacritty] still shows some emojis without using the emoji font. I suspect that is due to Source Code Pro having those glyphs because they work as expected with other fonts (e.g. Inconsolata).

For example ☕ and 💩 emojis:

enter image description here

Is there how to force the emoji font to be used for those glyphs also in terminal?

1 Answer 1

1

I had the same problem with a very similar fontconfig-config. Adding this helped:

  <match target="scan">
    <test name="family" compare="contains">
      <string>Source</string>
    </test>
    <edit name="charset" mode="assign" binding="same">
      <minus>
        <name>charset</name>
        <charset>
          <int>0x2611</int> <!-- ☑ -->
          <int>0x2615</int> <!-- ☕ -->
          <int>0x263a</int> <!-- ☺ -->
          <int>0x2665</int> <!-- ♥ -->
          <int>0x2713</int> <!-- ✓ -->
          <int>0x2714</int> <!-- ✔ -->
          <int>0x2764</int> <!-- ❤ -->
          <int>0x1f4a9</int> <!-- 💩 -->
          <int>0x1f916</int> <!-- 🤖 -->
        </charset>
      </minus>
    </edit>
  </match>

It hides the specified codepoints from fonts matching Source. Ranges are also possible:

      <minus>
        <name>charset</name>
        <charset>
          <range>
            <int>0x1f600</int>
            <int>0x1f640</int>
          </range>
        </charset>
      </minus>

Make sure to run fc-cache -f afterwards. This did not work in every program, for example it worked for xfce4-terminal but not alacritty (even after a reboot).

I could not find much documentation for it, apart from this bug report and the bug report linked within. The manpage is rather terse but might be helpful to understand the snippet better.

1
  • Interesting. But Alacritty is the first place I would need that. :( I'll try to teak this a bit and understand the config better to see if I can come up with a solution. Thanks. Sep 19, 2022 at 20:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .