Skip to content

How to priorize Emojione / Noto Emoji over monochrome emoji provided by other system fonts

1 / 3
Not downloaded yet
Not downloaded yet
Not downloaded yet

EDIT solved; see github/stove-panini/fontconfig-emoji and github/stove-panini/fontconfig-emoji/pull/2.

---

I'm referring to the screenshot below, where 🙂 is provided by Noto Emoji, but sad monochrome ♥ comes from some unidentified other system font providing the glyph. This is in bash in gnome-terminal 3.30.1, but other are affected (e.g. Chrome 71 & Firefox 64).

https://i.redd.it/s89a3rzxpns11.png

In other apps, the heart does display properly using Noto Emoji: the Emoji Selector Shell extension, gedit 3.30.1, nautilus. (Yes it is the same character, I can copy it from the emoji picker below into a terminal, and get the monochrome heart above).

​

https://i.redd.it/ccyh9x9amqs11.png

Archived/uncommentable post r/archlinux / "Enable Noto Color Emoji easily!" offers two fontconfig suggestions, and there's discussion about my problem in this thread, where u/charles_millette describes something that looks a lot like what I'm seeing:

The default font, DéjaVu, has a few emojis built-in. Since it has priority over Noto One, you need to replace it by something else if you want all emojis to show up.

I tried and failed with:

All my attempts were followed by an application restart, and I'm positive my ~/.config/fontconfig/fonts.conf is functional, as I use it successfully for four other replacements:

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <!-- I tried adding suggestions from
       https://www.reddit.com/r/archlinux/comments/6wkval/enable_noto_color_emoji_easily/
       here, without success -->
  <!-- I like Amazon Ember thickness and legibility, and use it to replace sans-serifs that suck. -->
  <match target="pattern">
    <test qual="any" name="family"><string>arial</string></test>
    <edit name="family" mode="assign" binding="same"><string>Amazon Ember</string></edit>
  </match>
  <match target="pattern">
    <test qual="any" name="family"><string>verdana</string></test>
    <edit name="family" mode="assign" binding="same"><string>Amazon Ember</string></edit>
  </match>
  <match target="pattern">
    <test qual="any" name="family"><string>calibri</string></test>
    <edit name="family" mode="assign" binding="same"><string>Amazon Ember</string></edit>
  </match>
  <match target="pattern">
    <test qual="any" name="family"><string>courier</string></test>
    <edit name="family" mode="assign" binding="same"><string>Ubuntu Mono</string></edit>
  </match>
</fontconfig>

What am I doing wrong? Thanks for the help.

EDIT noticed & mentioned apps where the heart is properly displayed.

EDIT2 found https://eev.ee/blog/2015/05/20/i-stared-into-the-fontconfig-and-the-fontconfig-stared-back-at-me/ , reading.

EDIT3 victory! Thanks to eevee's excellent post on fontconfig, especially final section "some hot parting tips", where s·he offers options to identify what font fontconfig whims chooses to pick for a specific glyph. Which I did using option 1. in a browser, which revealed (e.g. on this reddit page) the font providing a monochrome heart. So,

  <!-- Prefix with Noto fonts providing (a subset of) sad monochrome emojis -->
  <!-- https://www.reddit.com/r/archlinux/comments/9ouk2o/how_to_priorize_emojione_noto_emoji_over/ -->
  <!-- https://www.reddit.com/r/archlinux/comments/6wkval/enable_noto_color_emoji_easily/ -->
  <!-- https://victor.kropp.name/blog/emoji-on-linux/ -->
  <!-- https://eev.ee/blog/2015/05/20/i-stared-into-the-fontconfig-and-the-fontconfig-stared-back-at-me/#some-hot-parting-tips -->
  <match target="pattern">
    <test qual="any" name="family"><string>segoe ui</string></test>
    <edit name="family" mode="prepend_first" binding="weak">
      <string>Noto Color Emoji</string>
    </edit>
  </match>

It still sucks, as this match rule is bound to expand as I discover other fonts doing the same. Also, terminal isn't fixed. Do chime in if you see better alternatives 🙂.

EDIT4 well, no, now sites using Segoe UI are fucked up. I quit. Maybe I'll try more digging google/fontconfig emoji priority. Ideas welcome.

https://i.redd.it/kwgsybknjdt11.png

EDIT5 found github/stove-panini/fontconfig-emoji, which, so far, works!

Edited 20 Oct 2018. We only hold this version.

12 points15 comments
Open on Reddit
About this post
Posted
Archived
Edited
Score
12 · 100% up
Kind
Gallery · 3 files
ID
9ouk2o

Author

9
posts
91
comments
3
media
View profile

15 comments

so "♥️" is technically not an emoji. it's a standard character defined in unicode 1, and as such it should technically be rendered as an old character. you can force it to render as an emoji, but it will have the side effect of changing all other old unicode characters to the emoji variants, namely "▶️" which is used for a lot of play buttons like https://i.imgur.com/NBsJKRv.png

4 points

That makes sense, thanks. So, looking at my second screenshot (the one with gedit), that's the choice gedit is going for, right? These are not different characters, I copy-pasted "♥️".

2 points

yes. I think there is something in the standard about the old characters being allowed widths that terminals will prefer? not totally sure tbqh

anyways, I'm a sucker for emoji and did go the overriding route, so here is my config as an example: https://github.com/jshap70/dotfiles/blob/master/.config/fontconfig/fonts.conf

note that you probably also want this config https://github.com/jshap70/dotfiles/blob/master/.config/fontconfig/conf.d/20-no-embedded.conf , which keeps embedded bitmaps off for non emoji fonts like the Microsoft one's if your using them. I have to use the outlook 365 web app for work, which uses calibri, and boy does it look gross with bitmaps.

3 points

Are you using other fonts config globally (in /etc/fonts/local.conf)?

Also, what's the output of fc-match emoji and fc-match NotoColorEmoji?

3 points

Are you using other fonts config globally (in /etc/fonts/local.conf )?

I don't have an local.conf anywhere in /etc/fonts:

~ ls /etc/fonts/
conf.avail/  conf.d/  fonts.conf  fonts.dtd

~ fd local.conf /etc/fonts/
/etc/fonts/conf.avail/51-local.conf
/etc/fonts/conf.d/51-local.conf

~ ls -la /etc/fonts/conf.d/51-local.conf
lrwxrwxrwx 1 root root 35 Oct  5 00:06 /etc/fonts/conf.d/51-local.conf -> /etc/fonts/conf.avail/51-local.conf

~ cat /etc/fonts/conf.d/51-local.conf
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <its:rules xmlns:its="http://www.w3.org/2005/11/its" version="1.0">
    <its:translateRule translate="no" selector="/fontconfig/*[not(self::description)]"/>
  </its:rules>

  <description>Load local customization file</description>
        <!-- Load local system customization file -->
        <include ignore_missing="yes">local.conf</include>
</fontconfig>

Also, what's the output of fc-match emoji and fc-match NotoColorEmoji ?

~ fc-match emoji
NotoColorEmoji.ttf: "Noto Color Emoji" "Regular"
~ fc-match NotoColorEmoji
NotoColorEmoji.ttf: "Noto Color Emoji" "Regular"
1 points

I've had lots of problems with emoji before and now I just use a simple configuration like this:

    <match target="pattern">
        <test name="family" qual="first" compare="contains">
            <string>emoji</string>
        </test>
        <edit mode="assign" name="color">
            <bool>true</bool>
        </edit>
        <edit mode="assign" name="family">
            <string>Noto Color Emoji</string>
        </edit>
    </match>

    <match target="pattern">
        <test name="prgname" compare="not_eq">
            <string>java</string>
        </test>
        <test name="prgname" compare="not_eq">
            <string>chromium</string>
        </test>
        <edit name="family" mode="prepend">
            <string>Noto Color Emoji</string>
        </edit>
    </match>

The reason for excluding chromium is that (at the time when I was messing with fontconfig) prepending emoji font to the head of the list effectively breaks all Phabricator instances, because of their CSS font rule puts emoji font at the first. Just checked - it's still broken now: https://imgur.com/a/l0JAjxo

Note that you may run into further issues, mostly in terminals, due to problems with the characters' width. Your terminal may consider an emoji character having width 1 (taking up 1 "cell"), while in your fonts it appears to be 2. Then you may have to append a space to make the emoji display correctly.

The usual way for a console application to decide the width of a character is the glibc function wcwidth(), which may return 1 for the old smiley face and ♥️. This character width data relies on locale. Glib (used by VTE) has its own width table, and these two tables might disagree on some occasions. You may notice the problem mostly in ncurses applications (i.e. weechat), while pressing backspace to remove emoji characters. And there are ligatures, used for skin tones/country flags, which are also very hard to get right in terminal.

Also note that if you try to force emojify a character, it might look like this: https://imgur.com/a/mXuQ0Ad

Reference: http://maskray.me/blog/2016-03-13-terminal-emulator-fullwidth-color-emoji a blog post in Chinese, sorry. But Google Translate gives pretty good result. Most of the code fixes to various packages are not needed now.

2 points

Can you try using this .config/fontconfig/conf.d/01-emoji.conf config and let me know if it works better?

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
  <!-- Use Google Emojis -->
  <match target="pattern">
    <test qual="any" name="family"><string>Segoe UI Emoji</string></test>
    <edit name="family" mode="assign" binding="same"><string>Noto Color Emoji</string></edit>
  </match>
</fontconfig>

I've struggled making emojis work and I figured out this and it seems to work pretty well. You linked one thread in your post but there's a few more threads about emojis. Here's my post from 2 years ago: https://www.reddit.com/r/archlinux/comments/52k3t0/proper_color_emoji_support/d7l05nt/

1 points

Hi, thanks for chiming in!

Sorry, on my machine your rule doesn't help. But out of curiosity, why would it?

  1. Why match on Segoe UI Emoji, which I don't have/use on my machine ? (By the way I tried to replace it with sans-serif, no success either).
  2. Can you explain what's going on with binding="same" ?

Good day/night 🙂

1 points

Okay this is interesting. So I just tried removing that file (renaming it) and restarting Chrome, and the emojis still work like they did before. Maybe this is a recent change.

To answer your question, I don't remember, haha. I googled for Segoe, and apparently these are the emojis I see on Windows 10 when I use a computer with it at work. I don't know actually haha.

I didn't actually write this config, but I think i modified it from someone else and got emojis to work years ago but maybe stuff has changed.

2 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.