#1006685 kde-plasma-desktop: KDE does not display Emojis correctly

Package:
kde-plasma-desktop
Source:
meta-kde
Description:
KDE Plasma Desktop and minimal set of applications
Submitter:
Max Görner
Date:
2022-03-04 14:30:02 UTC
Severity:
normal
#1006685#5
Date:
2022-03-02 11:33:41 UTC
From:
To:
Dear Maintainer,

for several years KDE on Debian seems to be unable to display emojis
correctly. I experience this problem on Debian testing and on Debian stable.

One can reproduce it by running `echo "Heart Face Emoji 🥰"` in Konsole
or by opening https://www.youtube.com/watch?v=YaYoJziCgto in Fireofox or
Konqueror. The emojis will be displayed only as blank rectangles.

The problem does not occur on Ubuntu. It also does not occur when using
Debian/Xfce and when using the Xfce-Terminal from within a Plasma
session. Thus, I can have a Konsole and Xfce-Terminal side by side with
the former showing the problem and the latter not so.

I reproduced the problem by setting up a Debian/Testing in a virtual
machine yesterday.

I tried to set a different font, but to no avail. Maybe I have not tried
hard enough. However, I think Emojis should be displayed properly in the
default configuration.

#1006685#10
Date:
2022-03-02 13:01:11 UTC
From:
To:
Hi Max,
I just tried it myself on Arch (I am running) and didn't see the emojis.
Then I did:
- install fonts-noto-emoji
- added configuration to /etc/fonts/local.conf (easily findable on the
  internet what is necessary)
And now emojis are properly shown in konsole, as well as other Qt based
programs.
- the default font you set is for text, and emojis are most likely not
  contained in the font you set
- the libraries in use need to deal with missing glyphs in the defined
  font, and there are several ways to do it. One is to display TOFU

This is not specific to KDE, but to fontconfig and how Debian handles
fallback fonts.

Best

Norbert

#1006685#15
Date:
2022-03-03 08:52:49 UTC
From:
To:
Hi Norbert,

thank you very much for your reply.
I really tried, but I could not find a guide how to do so. I found
https://wiki.archlinux.org/title/Font_configuration but it seems not to have a
section to configure fallback fonts.

Could you point me to a guide or maybe post your XML snippet here? It would
help me a lot.
So maybe this is not related to KDE directly, but I still think its an
unfortunate situation, and fixing at would significantly improve the user
experience? Would it make sense to file another bug report against the
appropriate package, e.g. fontconfig?


Best regards
Max Görner

#1006685#20
Date:
2022-03-03 22:06:02 UTC
From:
To:
Hi Max,

I used a different config file, but just found this here which indicates
that it is related to hinting:

https://bugs.freedesktop.org/show_bug.cgi?id=104542

$ cat /etc/fonts/conf.d/68-color-emoji.conf

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
	<match target="font">
		<test name="family" compare="contains">
			<string>Emoji</string>
		</test>
		<edit name="hinting" mode="assign">
			<bool>true</bool>
		</edit>
		<edit name="hintstyle" mode="assign">
			<const>hintslight</const>
		</edit>
		<edit name="embeddedbitmap" mode="assign">
			<bool>true</bool>
		</edit>
	</match>
</fontconfig>

$

Does that work (after sudo fc-cache -f  and relogin)?

If not, then

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
 <alias>
   <family>sans-serif</family>
   <prefer>
     <family>Noto Sans</family>
     <family>Noto Color Emoji</family>
     <family>Noto Emoji</family>
     <family>DejaVu Sans</family>
   </prefer>
 </alias>
 <alias>
   <family>serif</family>
   <prefer>
     <family>Noto Serif</family>
     <family>Noto Color Emoji</family>
     <family>Noto Emoji</family>
     <family>DejaVu Serif</family>
   </prefer>
 </alias>
 <alias>
  <family>monospace</family>
  <prefer>
    <family>Noto Mono</family>
    <family>Noto Color Emoji</family>
    <family>Noto Emoji</family>
    <family>DejaVu Sans Mono</family>
   </prefer>
 </alias>
</fontconfig>

Would help, too.

My guess is that the fonts-noto-emoji or so should ship a fontconfig
file that activates it, best with the above.

But I am not running Debian anymore on my main machine, so cannot really
check.

Best

Norbert

#1006685#25
Date:
2022-03-04 09:44:27 UTC
From:
To:
Hi Norbert,
Thank you very much for finding this.

Meanwhile, I had a look at how Kubuntu is configured in this regard.

I copied two files from Kubuntu's /etc/fonts/conf.avail/, 50-user.conf and
56-kubuntu-noto.conf and put them to Debian's /etc/fonts/conf.avail and
~/.config/fontconfig/conf.d/, respectively.

Then I refreshed the fonts cache using `sudo fc-cache -fv`, just as you
suggested. For everyone landing here: **It was crucial to relogin!**

Now I have working emoji support wherever I expect it. Thank you very much!

I could not find a primary source for both files, so I attached them to this
e-mail. Hopefully they will arrive in Debian's bug ticket frontend.
I will open a bugreport for that package.


Again, thank you very much for your help. I think this bug report can be
closed now.


Best Regards
Max Görner

#1006685#30
Date:
2022-03-04 14:27:35 UTC
From:
To:
Hallo Max,

So yes, re-logging in is probably necessary indeed.

I checked the two files, the 50-user.conf should not be necessary since
this is already present in Debian, too ... if it is missing on your
side, this is surprising.

Concerning 50-kubuntu-noto.conf, this does *a hell of a lot of things*
... if you are happy with the output, then all is fine. The part that it
does right is adding the Noto emoji font to the search list at the
front. (I personally found some interesting things concerning hinting
for CJK fonts, which - as I live in Japan - is of great interest!)

Well, if it works and all is fine with you, that is perfect!

All the best

Norbert