How to priorize Emojione / Noto Emoji over monochrome emoji provided by other system fonts
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:
- Both extra/noto-fonts-emoji and AUR/ttf-emoji.
- Reading wiki.archlinux/Fonts#Emoji_and_symbols and wiki/Font_configuration#Replace_or_set_default_fonts.
- Following both fontconfig suggestions offered at Enable Noto Color Emoji easily!
- Also, I don't understand u/Foxboron's suggestion in this post: how are the two match+prepend_first rules supposed to work? Why
<string>Icons</string>in the first one?!
- Also, I don't understand u/Foxboron's suggestion in this post: how are the two match+prepend_first rules supposed to work? Why
- Removing
ttf-dejavu(following the mention in the above-mentioned post). By the way, how can I identify which font provides "♥" on my system?
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.
About this post
- Posted
- Archived
- Edited
- Score
- 12 · 100% up
- Kind
- Gallery · 3 files
- ID
- 9ouk2o
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
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 "♥️".
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.
Are you using other fonts config globally (in
/etc/fonts/local.conf)?Also, what's the output of
fc-match emojiandfc-match NotoColorEmoji?I don't have an
local.confanywhere in/etc/fonts:I've had lots of problems with emoji before and now I just use a simple configuration like this:
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.
Can you try using this
.config/fontconfig/conf.d/01-emoji.confconfig and let me know if it works better?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/
Hi, thanks for chiming in!
Sorry, on my machine your rule doesn't help. But out of curiosity, why would it?
Segoe UI Emoji, which I don't have/use on my machine ? (By the way I tried to replace it withsans-serif, no success either).binding="same"?Good day/night 🙂
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.