Snapped app not loading fonts on Fedora (and Arch)

you were missing one command to re-generate the cache, so you just end up with a generated cache by the snap again, the full sequence should be:

$ rm -rf ~/.cache/fontconfig 
$ rm -rf ~/snap/codium/common/.cache
$ fc-cache -r
$ codium

see if this works any better …

Didn’t work.

image

image

well, was worth a try at least :slight_smile:

1 Like

image

Recently I was digging into the following font related bug report:

It’s not an identical problem, but I think it might point to the root cause: that the contents of the fontconfig cache depend on both the fontconfig version (for the exact cache file format) and Freetype version (for what information about the font is stored in the cache).

One possibility here is that the host system has a newer Freetype than inside the snap’s sandbox, so the host system fontconfig caches suggest the use of a font in a way the sandbox Freetype can’t handle.

I think the solution is going to involve ignoring the host system fontconfig caches, and having each GNOME platform snap create and maintain a fontconfig cache that matches their (fontconfig, freetype) pair. By having all snaps that use the same platform snap share the cache, the overhead should be manageable.

2 Likes

FWIW, I see this problem in Kubuntu 20.04 with Plasma. When I first install my snap using the gnome-3-28 extension, I see rectangles. The suggested workaround fixes it:

sudo rm /var/cache/fontconfig/*
rm ~/.cache/fontconfig/*
fc-cache -r

I am trying to follow along with all of you but wondering if this is the same error.

$ cloudcompare.CloudCompare

QSocketNotifier: Can only be used with threads started with QThread
Gtk-Message: 21:49:04.756: Failed to load module “canberra-gtk-module”
Gtk-Message: 21:49:04.790: Failed to load module “colorreload-gtk-module”
Fontconfig warning: FcPattern object weight does not accept value [40 210)
Segmentation fault (core dumped)

Confirm this works for me too (in my case, testing with joplin-james-carroll.joplin)

I maintain Beekeeper Studio and users have reported this issue on Fedora 32 and Manjaro. I’ve confirmed the broken fonts with a totally fresh VM.

I’ve tried all the workarounds listed here and nothing seems to fix the fonts.

Did anyone find the correct workaround?

Any way to fix this issue in my Electron build process?

2 Likes

This does not work for me on Manjaro KDE and trying to use CloudCompare:

rm ~/.cache/fontconfig/*
[somebody ~]$ fc-cache -r
[somebody ~]$ cloudcompare.CloudCompare       
QSocketNotifier: Can only be used with threads started with QThread
Gtk-Message: 21:14:02.771: Failed to load module "canberra-gtk-module"
Gtk-Message: 21:14:02.806: Failed to load module "colorreload-gtk-module"
Fontconfig warning: FcPattern object weight does not accept value [40 210)
Segmentation fault (core dumped)

I know there is some ongoing work to make the snap caches private to respective snaps. @kenvandine did a PoC with Inkscape snap which worked well when I tried it. Perhaps he or @jamesh can comment on the current status.

2 Likes

@mborzecki thanks so much.

@kenvandine @jamesh would love to learn more about your work and how you worked around this problem. Even if I have to hard-code a font into my app or something it would be a big improvement.

Thanks for your time on this bug :pray:

I am also having this problem with Manjaro ARM. None of the solutions above have worked.

Any thoughts here? This is a big issue for my app as it makes my Snap unusable on Fedora and Manjaro for anyone who needs to open the file open dialog.

2 Likes

Although that above did not get the app to work, this, slightly different set of commands, DID work to allow me to run the app. **I am on Manjaro

$ sudo rm -f /var/cache/fontconfig/*
$ rm -f ~/.cache/fontconfig/*

That came from philm of Manjaro: https://forum.manjaro.org/u/philm
**I could not find the post where he offered it.

the DASH EFF seems to do the trick. (-f)

2 Likes

These commands worked for me except I got the ‘Argument list too long’ error on the second command so I deleted the fontconfig dir and added an empty one. I am using Manjaro KDE. Thanks for this solution. :clap:

FWIW – Saw this problem with stock Ubuntu 20.04 with a custom gnome theme installed (have no idea if that makes a difference – just saying).

Again, this fixes it:

The snap that displays this problem for me is “namegen” – a GTK3-based random name generator. I have since taken it private until I have time to work this more carefully or until the solution is found.

I think I’m running into this on Ubuntu 20.04 when testing a 18.04-based rst2pdf snap before publishing (pull request here https://github.com/rst2pdf/rst2pdf/pull/928). The tool produces PDFs, so it does need to access the fonts on the user’s system, and we know our user base has a mix of geekiness, so we can’t recommend people run command to clear their font caches as a general thing :confused: Is there a way to manage the font config/cache from within the snap so we can publish a new version? At the moment trying to do anything with fonts is producing FileNotFoundError: [Errno 2] No such file or directory: 'fc-match': 'fc-match' and no output. Advice gratefully received …

If there’s a better way (or something integrated in the extensions) it would be very nice…
In a snap I maintain (the swi-prolog snap: https://snapcraft.io/swi-prolog) this issue appears from time to time, and while it can be solved by removing the fontconfig cache it is not convenient.
In my case the snap is using the kde-neon extension, if that makes any difference

Will this ever get fixed? None of the workarounds work anymore, on some snaps…