1

Frustratingly, I am unable to make emoji render properly in any terminal on up-to-date Ubuntu 22.04. I have them working in the browser (fully expected), LibreOffice, even Emacs shell but not in any of my terminals. I've checked the locale (en_GB.UTF-8), fc-list "MesloLGS NF Regular" (or any other emoji friendly font installed with apt like fonts-noto-color-emoji or fonts-emojione and they all check out. I've rebuilt the fc-cache.

If I run shell in emacs alongside a terminal window and run the same commands in both, I get identical answers until I try to cat my test file. In Emacs shell I get

Hello World 

but in terminal (either Tilix, Guake or GNOME Termial 3.44.0) I get

Hello World  

Yes, the emoji character is there, it is just displayed as an empty character (and I know that because it pasted into my browser correctly so I had to remove it for illustrative purposes).

As requested, running

od -c emoji_test.txt

puts out

0000000   H   e   l   l   o       W   o   r   l   d     360 237 230 204
0000020  \n

The hex for the test emoji should be 😄 1F604 hex maps to 373004 in octal so I think I've got that bit right.

It doesn't make any difference what shell I'm running - zsh, bash or even sh.

I'm running libcairo2 version 1.16.0-5ubuntu2 and I do have an emoji conf file in .config/fontmanager/conf.d pointing to Noto Color Emoji.

I know I'm being stupid somewhere but has anyone got a debug guide to help me pin point just where?

rolandw
  • 21
  • I cannot imagine why anyone would ever actually want emojis in the terminal (you can always use smileys, :), if you absolutely must), but my guess is that you are using a terminal font that doesn't support them . Try switching to full unicode font. You mention Noto, try using that in the terminal, does that work for you? – terdon Dec 06 '23 at 10:26
  • Actually, I don't really want emojis in the terminal but lots of other people seem to put all sorts of stuff in the output of their scripts and apps and I just get missing characters which just looks odd. Sadly it doesn't seem to matter what font I chose for use in the terminal. – rolandw Dec 06 '23 at 11:20
  • Do you have the Noto Fonts Emoji package installed? – xangua Dec 08 '23 at 16:26
  • Yup. ```fonts-noto-color-emoji/jammy-updates,jammy-updates,now 2.038-0ubuntu1 all [installed]
    
    
    – rolandw Dec 08 '23 at 17:16

3 Answers3

1

Whether a glyph is displayed will depend on whether the font you are using supports it. If you switch to one that has emoji support, it should work as you expect. You mentioned Noto in your question, so try that. Open gnome-terminal, go to Preferences -> "Custom font" and choose Noto of something like Ubuntu Mono:

screenshot of gnome terminal preferences showing Ubuntu Mono as the selected font

This should let you see emojis:

screenshot of gnome terminal with working emoji

terdon
  • 100,812
  • I wish that were so. I've tried various fonts that should support emoji, including Ubunto Mono, and still I get no character displayed - just an empty space. It just seems to be something in my terminal that is stopping it! It should work but just doesn't! – rolandw Dec 06 '23 at 11:14
  • Hmm. Please edit your question and add the output of od -c test_file so we can see exactly what is in the file. – terdon Dec 06 '23 at 11:18
1

TLDR; There are chances that you have the font file in multiple system font folders. Remove those & try installing fonts-noto-color-emoji again.

I faced the same issue, even after I installed fonts-noto-color-emoji( as advised here and various other forums ) my system couldn't render emojis on the terminal, gedit, emote (emoji-picker), etc.

I stumbled upon this. And then when I ran $ fc-cache -f -v on my terminal, I figured that I had multiple folders with the same font file. I just removed them manually & did the process again.

dirtbkr
  • 11
  • I ran fc-cache -f -v multiple times without really realising that I had multiple versions of the same font file but I did spot it by checking the various locations. I did an extensive removal of duplicates and removed every font that I didn't actually need (reminded me of Mac System 6 & 7 days). With a minimum set of fonts, fc-cache just worked great. Now if only there was a method of automating this... – rolandw Feb 28 '24 at 17:58
  • @rolandw Good to hear that you solved it! Consider accepting the answer if it helped you. – dirtbkr Feb 29 '24 at 05:40
  • @rolandw I've added a bit of automation to an extended version of this answer below. I guess it should be easy to make it a complete script, but I'm unsure why there are no duplicate files allowed in the first place - I think this question needs to be answered first. – lumbric Mar 26 '24 at 12:39
0

This a more detailed version of @dirtbkr's answer, which is too much for a comment or edit, but migth add some more hints:

TL;TR: You might have duplicate font files. Use this command to locate them:

find /usr/share/fonts/truetype -name Noto\*

If you have installed fonts manually, you might recognize them in this list already. Delete the duplicates. You should keep the ones in /usr/share/fonts/truetype/noto - these should be the ones installed from the package fonts-noto-color-emoji.

If this did not help proceed with the long answer below.

Then run fc-cache -f -v.

Any running processes might still use the old files, so restart programs you use to test it (e.g. Libre Office). For some programs you might need to logout and log in again (e.g. the Gnome terminal).

Longer answer:

I've used this script to install all Google fonts. Turns out, using install scripts instead of official package repositories can break things, even if it is only about font files.

In my case, I simply removed all Google Fonts matching Noto*.

The following command lists all files with duplicate filename in the global font directory:

find /usr/share/fonts/ -type f -exec basename {} \; | sort | uniq -d

Use fc-list : file to find other font directories - you might need to widen your search.

Why?

I couldn't figure out. I tried removing the packages fonts-noto-color-emoji, fonts-noto-core, fonts-noto-cjk. After that, there were no other fonts installed in /usr/share/fonts/truetype/noto. So I thought I could use all Google Fonts and use the emojis from there. However, this did not work - no emojis displayed in this case.

See also

lumbric
  • 3,994