Ubuntuで絵文字 fonts-noto-color-emoji インストール後に一部のアプリで文字がおかしくなる


Ubuntu 20.04で確認。

Ubuntuで絵文字を表示するには、fonts-noto-color-emoji パッケージをインストールする。
インストールするだけで、Chromeなどでも絵文字が適用されるようになる。

sudo apt install fonts-noto-color-emoji

しかし、それ以降、数字が黒文字の全角になったり、妙なSerif(明朝体)になったりした。

何の文字があたっているかfont-managerで調べていると、Noto Color Emojiが該当した。

フォントの優先順位を確認するfc-matchを使うと、Noto Color Emojiが最初に出てくるようになった。

fc-match -a | head -5

NotoColorEmoji.ttf: "Noto Color Emoji" "Regular"
DejaVuSans.ttf: "DejaVu Sans" "Book"
DejaVuSansCondensed.ttf: "DejaVu Sans" "Condensed"
DejaVuSans-ExtraLight.ttf: "DejaVu Sans" "ExtraLight"
DejaVuSans-Bold.ttf: "DejaVu Sans" "Bold"

おそらく、Noto Color Emojiのインストールでこれが優先順位の先頭になり、一部最も上位のフォントしか使わないアプリケーションで、このフォントだけが使われるようになって、このようなことになっていると思われる。

フォントの優先順位を操作する ~/.config/fontconfig/fonts.conf をみてみると、Noto Color Emojを先頭に挿入する操作が書かれていた。

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
 <match>
  <test name="family">
   <string>sans-serif</string>
  </test>
  <edit mode="prepend" binding="strong" name="family">
   <string>Noto Color Emoji</string>
  </edit>
 </match>
 <match>
  <test name="family">
   <string>serif</string>
  </test>
  <edit mode="prepend" binding="strong" name="family">
   <string>Noto Color Emoji</string>
  </edit>
 </match>

これに、Noto Sans/Serif CJK JPに変更した。

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
 <match>
  <test name="family">
   <string>sans-serif</string>
  </test>
  <edit mode="prepend" binding="strong" name="family">
   <string>Noto Sans CJK JP</string>
  </edit>
 </match>
 <match>
  <test name="family">
   <string>serif</string>
  </test>
  <edit mode="prepend" binding="strong" name="family">
   <string>Noto Serif CJK JP</string>
  </edit>
 </match>

確認すると、順位が下がっていた。

fc-match -a | head -10

NotoSansCJK-Regular.ttc: "Noto Sans CJK JP" "Regular"
NotoSansCJK-Medium.ttc: "Noto Sans CJK JP" "Medium"
NotoSansCJK-DemiLight.ttc: "Noto Sans CJK JP" "DemiLight"
NotoSansCJK-Light.ttc: "Noto Sans CJK JP" "Light"
NotoSansCJK-Thin.ttc: "Noto Sans CJK JP" "Thin"
NotoSansCJK-Bold.ttc: "Noto Sans CJK JP" "Bold"
NotoSansCJK-Black.ttc: "Noto Sans CJK JP" "Black"
NotoColorEmoji.ttf: "Noto Color Emoji" "Regular"

引き続きChromeなどでは絵文字が利用でき、加えてNoto Color Emojiが不必要にあたっていたアプリでも正常に表示されるようになった。