Feature Freeze Exception: Seeding the official Firefox snap in Ubuntu Desktop

Another area with a need to look closer into is fonts.

When playing around with the Firefox snap, I see that it uses NotoSansCJK-Regular.ttc for CJK scripts. I don’t find that file in the snaps, which indicates that /etc/apparmor.d/abstractions/fonts is in use.

Nevertheless, the symlinks in /etc/fonts/conf.d seem not to work as expected. It might be due to an ordering issue. I mean, the order in which the font configuration files are read by fontconfig is crucial — hence the prefix numbers in the file names. Can it possibly be that it’s configured to read /snap/gnome-3-*-*/current/etc/fonts/conf.d first, and /etc/fonts/conf.d only afterwards? In that case that may be one explanation why the system’s font config files are ignored to a large extent.

Edit:

In /snap/gnome-3-38-2004/76/etc/fonts/fonts.conf I see this section:

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

Should an entry representing the system’s /etc/fonts/conf.d be added to or replace that entry?

Edit 2:

In an IRC discussion I was asked to provide a specific, reproducible example. Here it is:

  • Generate a Chinese locale:

    sudo locale-gen zh_CN.UTF-8
    
  • Start firefox with that locale applied:

    LC_CTYPE=zh_CN.UTF-8 firefox
    
  • Go to https://zh.wikipedia.org

  • Use More tools -> Web Developer Tools to examine which fonts are used.

    • If firefox is a .deb, then you see “Fonts Used: Noto Sans CJK SC” as expected.

    • If firefox is a snap, then you see “Fonts Used: Noto Sans CJK JP” which means that some characters are rendered using the equivalent Japanese glyphs, which is not optimal and a regression for users with a Chinese locale.

  • In other words: The /etc/fonts/conf.d/69-language-selector-zh-cn.conf file was not loaded by the snap.

The issue can be worked around temporarily by opening the file:

~/snap/firefox/current/.config/fontconfig/fonts.conf

for editing and adding this line:

<include ignore_missing="yes">/etc/fonts/conf.d</include>

And a more proper fix is on its way:

https://github.com/snapcore/snapcraft/pull/3586

4 Likes