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.
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:
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)
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.
@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.
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.
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.
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 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