Snap package cannot read fonts conf

I started move to Ubuntu 20.04 but when i install chromium form Snap

apt install chromium-browser

Chromium cannot read /etc/fonts/conf.d/65-ubuntu-font-family-arabic.conf that contain

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <match target="pattern">
        <test name="family" compare="eq">
            <string>Ubuntu</string>
        </test>
        <test name="lang" compare="contains">
            <string>ar</string>
        </test>
        <edit name="family" mode="assign" binding="strong">
            <string>Ubuntu Arabic</string>
        </edit>
    </match>
    <match target="pattern">
        <test name="family" compare="eq">
            <string>DejaVu</string>
        </test>
        <test name="lang" compare="contains">
            <string>ar</string>
        </test>
        <edit name="family" mode="assign" binding="same">
            <string>Ubuntu Arabic</string>
        </edit>
    </match>
    <match target="pattern">
        <test name="family" compare="eq">
            <string>DejaVu Sans</string>
        </test>
        <test name="lang" compare="contains">
            <string>ar</string>
        </test>
        <edit name="family" mode="assign" binding="same">
            <string>Ubuntu Arabic</string>
        </edit>
    </match>
    <match target="pattern">
        <test name="family" compare="eq">
            <string>DejaVu Serif</string>
        </test>
        <test name="lang" compare="contains">
            <string>ar</string>
        </test>
        <edit name="family" mode="assign" binding="same">
            <string>Ubuntu Arabic</string>
        </edit>
    </match>
    <match target="pattern">
        <test name="family" compare="eq">
            <string>DejaVu Serif</string>
        </test>
        <test name="lang" compare="contains">
            <string>ar</string>
        </test>
        <edit name="family" mode="assign" binding="strong">
            <string>Ubuntu Arabic</string>
        </edit>
    </match>
    <alias>
  	<family>DejaVu Serif</family>
	<prefer>
	  <family>Ubuntu Arabic</family>
	  <family>DejaVu Serif</family>
	</prefer>
    </alias>
    <alias>
  	<family>DejaVu Sans</family>
	<prefer>
	  <family>Ubuntu Arabic</family>
	  <family>DejaVu Sans</family>
	</prefer>
    </alias>
    <alias>
  	<family>DejaVu</family>
	<prefer>
	  <family>Ubuntu Arabic</family>
	  <family>DejaVu</family>
	</prefer>
    </alias>
</fontconfig>

font source: https://launchpad.net/ubuntu/+source/ubuntu-font-family-sources/0.84~mono0.83+arabicfontconfig-0ubuntu1

How i can make snap package read that files?

If you notice, Chromium and Ubuntu Software not use default system fonts
Gedit, Firefox and Files use System fonts correctly
5d7b5d484663304713a92398e6691625f7001617_2_690x335

Chromium binary works well
4306285c980d0650fbbec37e2f8596b092629d12_2_690x335

Sorry for the late feedback @SYaslem.

If you’re willing to re-install the chromium snap to help us diagnose and fix the problem, could you run it and in parallel have the following command running in a separate terminal window:

journalctl -f | grep DEN

Then please share the output here. Thanks in advance!

2 Likes

(note to self) possibly related thread: Snapped app not loading fonts on Fedora (and Arch)

أبريل 20 18:59:02 syaslem audit[665]: USER_AVC pid=665 uid=100 auid=4294967295 ses=4294967295 msg='apparmor="DENIED" operation="dbus_method_call"  bus="system" path="/" interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" mask="send" name="org.bluez" pid=4077 label="snap.chromium.chromium"
أبريل 20 18:59:02 syaslem kernel: audit: type=1107 audit(1587398342.076:77): pid=665 uid=100 auid=4294967295 ses=4294967295 msg='apparmor="DENIED" operation="dbus_method_call"  bus="system" path="/" interface="org.freedesktop.DBus.ObjectManager" member="GetManagedObjects" mask="send" name="org.bluez" pid=4077 label="snap.chromium.chromium

Thanks. There is no denial on /etc/fonts/. I’ll see if I can reproduce the bug in a VM.

Pardon my ignorance, how did you manage to get that font installed in 20.04? It appears it was in xenial only, not available in later versions, and when I download the deb to manually install it, I get a conflict with fonts-ubuntu.

install fonts manual in
/usr/local/share/fonts

then create /etc/fonts/conf.avail/65-ubuntu-font-family-arabic.conf contains

<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
    <match target="pattern">
        <test name="family" compare="eq">
            <string>Ubuntu</string>
        </test>
        <test name="lang" compare="contains">
            <string>ar</string>
        </test>
        <edit name="family" mode="assign" binding="strong">
            <string>Ubuntu Arabic</string>
        </edit>
    </match>
    <match target="pattern">
        <test name="family" compare="eq">
            <string>DejaVu</string>
        </test>
        <test name="lang" compare="contains">
            <string>ar</string>
        </test>
        <edit name="family" mode="assign" binding="same">
            <string>Ubuntu Arabic</string>
        </edit>
    </match>
    <match target="pattern">
        <test name="family" compare="eq">
            <string>DejaVu Sans</string>
        </test>
        <test name="lang" compare="contains">
            <string>ar</string>
        </test>
        <edit name="family" mode="assign" binding="same">
            <string>Ubuntu Arabic</string>
        </edit>
    </match>
    <match target="pattern">
        <test name="family" compare="eq">
            <string>DejaVu Serif</string>
        </test>
        <test name="lang" compare="contains">
            <string>ar</string>
        </test>
        <edit name="family" mode="assign" binding="same">
            <string>Ubuntu Arabic</string>
        </edit>
    </match>
    <match target="pattern">
        <test name="family" compare="eq">
            <string>DejaVu Serif</string>
        </test>
        <test name="lang" compare="contains">
            <string>ar</string>
        </test>
        <edit name="family" mode="assign" binding="strong">
            <string>Ubuntu Arabic</string>
        </edit>
    </match>
    <alias>
  	<family>DejaVu Serif</family>
	<prefer>
	  <family>Ubuntu Arabic</family>
	  <family>DejaVu Serif</family>
	</prefer>
    </alias>
    <alias>
  	<family>DejaVu Sans</family>
	<prefer>
	  <family>Ubuntu Arabic</family>
	  <family>DejaVu Sans</family>
	</prefer>
    </alias>
    <alias>
  	<family>DejaVu</family>
	<prefer>
	  <family>Ubuntu Arabic</family>
	  <family>DejaVu</family>
	</prefer>
    </alias>
</fontconfig>

and create syslink for it in /etc/fonts/conf.d/

have you tried putting the font into

~/.local/share/fonts/

might be that snapd’s desktop interface simply does not allow access to /usr/local/share/fonts …

As per https://gitlab.com/apparmor/apparmor/-/blob/master/profiles/apparmor.d/abstractions/fonts, it should be readable.

ah i had only checked the snapd source, not the apparmor font abstraction …

the issue not read fonts
chromium can found “Ubuntu Arabic” but cannot read conf.d that make it replace to "DejaVu "

%D9%84%D9%82%D8%B7%D8%A9%20%D8%B4%D8%A7%D8%B4%D8%A9%20%D9%85%D9%86%202020-04-20%2021-45-30

Can you try the following? Edit ~/snap/chromium/current/.config/fontconfig/fonts.conf to add the following line:

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

Then save the file and restart chromium.

I’m not really sure what to expect visually, but I can tell that when stracing the snap, adding that line allowed the app to find and read your custom fonts configuration file.

2 Likes

Thank you, that work great!
%D9%84%D9%82%D8%B7%D8%A9%20%D8%B4%D8%A7%D8%B4%D8%A9%20%D9%85%D9%86%202020-04-22%2016-35-01

how i can do it globally?

@jamesh is this something we should consider for addition to the desktop helpers?

1 Like

That will be helpful :+1:

after restart the changes removed

Ah, that’s quite unfortunate… Indeed the fontconfig file is regenerated everytime there’s an update (a new revision) to the snap. We need a way for users to define custom configs that stick.

Create an empty fontconfig-user.conf if it doesn’t exist for <include>? Only touch that file if it doesn’t exist, so that the fontconfig ruleset doesn’t break by it potentially not being present, allowing the user to add their custom rules in this separate non-generated file.

1 Like