Fontconfig issue in snap (+kde-neon extension)

Hi. I’m building a snap for the swi-prolog language using the kde-neon extension.
The snap fails to start with x11 support (it cannot run the integrated emacs release) because it fails to load the fonts.
If we run fc-cache -r in the snap it then starts to work properly.
This didn’t happen in when the snap was first created (with the kde content snap connected, but not using the extension).
Where do the snaps read the fontconfig data from? The host or the snap(+content snap)?
The yaml can be read here: https://github.com/LyzardKing/swipl-devel/blob/lkfork/kde-neon/snap/snapcraft.yaml
Any insight in this could be very useful.
Thanks

We are using a custom build script to run optimizations, and in the build log I get an issue that could be related…

runtime library [libSM.so.6] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
  /snap/kde-frameworks-5-core18-sdk/current/usr/lib/x86_64-linux-gnu
runtime library [libICE.so.6] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
  /snap/kde-frameworks-5-core18-sdk/current/usr/lib/x86_64-linux-gnu
runtime library [libfreetype.so.6] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
  /snap/kde-frameworks-5-core18-sdk/current/usr/lib/x86_64-linux-gnu
runtime library [libfontconfig.so.1] in /usr/lib/x86_64-linux-gnu may be hidden by files in:
  /snap/kde-frameworks-5-core18-sdk/current/usr/lib/x86_64-linux-gnu

The snap is now available as a confined snap in the beta and edge channel.
The fontconfig issue remains.
Is this still an unsolved issue?

1 Like

Just a though. I think the fontconfig configuration comes from /etc/fonts/fonts.conf in the application snap. This file contains (near the end) a declaration for the font config cache directory, setting it to /var/cache/fontconfig. I guess the problem is due to the host and the snap having a different font config and a different set of fonts, but sharing the cache directory?

Possibly we should simple remove the global cache and only leave the XDG personal one in place?

1 Like

This seems not enough. I tried adding this to the build step:

sed -i '/\/var\/cache\//'d $SNAPCRAFT_PART_INSTALL/etc/fonts/fonts.conf

I can confirm that this line is indeed gone from the application snap, but the font issue prevails :frowning:

Does anyone have a clue what is the root cause of this and how to fix it?

@jamesh @lucyllewy Could this be an issue with the kde base?
Is it related to https://forum.snapcraft.io/t/snapped-app-not-loading-fonts-on-fedora-and-arch/?