Snapped app not loading fonts on Fedora (and Arch)

As I understand it, they didn’t bump the cache version because:

  1. the file format did not change, and
  2. the file names for UUID and MD5-directory-name based cache files would never collide, due to the different lengths and extra dashes.

Further more, if the 2.13 libfontconfig encountered a read-only directory without a UUID file, it would fall back to checking for an MD5 cache file.

Looking at the 2.13.91 source, it looks like it will also be able to reuse existing valid UUID based cache files, but will attempt to remove UUID files from writeable directories.

So, can you give me some workaround for this issue pls (Arch linux)?
Part of my snap-apps can’t start

user@thinkpad$ libreoffice.writer 
Fontconfig warning: FcPattern object weight does not accept value [40 210)
Application Error

and the other part starts without letters…

BTW, code (VSCode) and telegram work pretty well… Maybe they use some internal fontconfig.

If it is important for anyone in future, here is my solution:

sudo rm /var/cache/fontconfig/*
rm ~/.cache/fontconfig/*
2 Likes

Is deleting the font cache the only workaround?

Don’t know, but it has fixed my issues

I still have this rectangle boxes instead of text issue with snap-store. I am running 5.4.13-arch1-1.
I have Opera installed from snap without issues.
I have tried the following with no avail:

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

Any new updates on this issue?

I am having the same issue with Cherrytree on Manjaro KDE and the above steps did not fix it, any good workaround to fix this.

Hello!

Thank you for all the comments and workarounds provided.

We are developing an application in Electron.js, the app works great in Ubuntu, but in Fedora, only the main views characters are rendered well, the dialogs show squares instead of letters:

Electron dialog in Fedora:

we did deleted the fontcofig cache, but just to check if it works, but it didn’t work.

we are using the default configuration of https://www.electron.build/configuration/snap to generate the snap build. are we missing something? is there anything we can include before creating the snap to make the app able to read the fontconfig and not require our users to apply workarounds ?

Thank you in advance!

1 Like

I’ve bisected libfontconfig versions between 2.12.6 (which we know to work), and current master (2.13.92+). I’ve made sure that there is only one source of fontconfig cache under /var/cache/fontconfig and no other location can be written to inside the snap.

The commit that broke it was correctly identified by @jamesh before:

If we want to get it working, we need to have a way of ensuring that the generated font cache is comptible with whatever the libfontconfig version is used by the snap (be it the core* one, or Gnome runtime one).

2 Likes

As I mentioned on IRC, it is quite possible that the breakage is earlier than this commit. The difference is that commits from this one on produce cache files that Bionic’s fontconfig can see (i.e. based on the MD5 of the file name), and the ones just before it don’t (i.e. a UUID matching the $dir/.uuid file).

It would probably be possible to bisect further back by generating a cache and then symlinking the UUID cache file to the equivalent MD5 name and see if the snap is still broken.

1 Like

Having worked around the UUID thing, I was able to narrow it down to this single commit.

Reverting the commit in full and regenerating the cache, made the fonts works again. In your view, what is the best way to proceed with the upstream?

2 Likes

Debugging this further. The fonts work on Focal and Debian 10, both using libfontconfig 2.13.1. I’ve pulled the actual libfontconfig.so.1.12.0 binary from Debian and font files. Also mounted an empty tmpfs over /etc/fonts (and then /etc/fonts/conf.d) to make sure we’re using a vanilla config. Then symlinked the MD5-named cache file expected by gnome-3-28-1804 is symlinked to the right UUID-name file as expected by the Debian version.

In the end fonts were still rendering as boxes, suggesting that perhaps problem is somewhere else in the stack. I need to consult with @jamesh on how to proceed with debugging this.

Clearing fontconfig cache fixed this problem for me on Arch Linux. I use infinality patched font BTW

Once you do fc-cache -f on the host, and then run the snap again, the font should be broken in snaps again. I haven’t been able to do it yet, but the next step is probably dissecting the cache file generated by 2.13.1 and 2.13.92+ to check the differences.

1 Like

Hi, had the same issue with CherryTree.
My fix was:

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

Thanks @vgm106

1 Like

Thank you for that fix. It makes one wonder why there is still font caching in Linux at all considering it takes about 600ms for fc-cache to run so why does it even exist? Seems like some relic of the Xfree86 days, as in 1986 presumably(?)

I discovered a thing while testing some stuff because of an issue I had with Standard Notes . I basically had the same issue described here: The fonts in the Electron app itself worked fine but all the fonts of system dialogs were broken. I’m on Fedora 32 and using the Roboto font. But changing font and GTK theme to system’s default doesn’t change anything regarding this issue. I tested with some more apps:

Electron:

  • Standard Notes: Fonts broken in system dialogs, system dialog’s theme matches system GTK theme
  • Simplenote: Fonts broken in system dialogs, system dialog’s theme matches system theme
  • Polar Bookshelf: Fonts broken in system dialogs, system dialog’s theme matches system theme
  • "electrontestapp: Fonts not broken in system dialogs, system dialog’s theme doesn’t match system theme, but font actually is Roboto

Native (as in not Electron) apps:

  • Snap Store: Fonts broken for the whole app, theme matches system theme
  • Midori Browser: Fonts not broken, theme doesn’t match the system theme, but font actually is Roboto

I don’t know if this correlation can lead to any valuable conclusion (maybe it’s just that the non-matching apps ship their own stuff or something), I just wanted to get it out there.

1 Like

Could you test mattermost-desktop? Maybe this is an issue with the electron-builder tooling. The mattermost-desktop snap uses electron but not the electron-builder tooling.

I installed mattermost-desktop for testing: The system dialogs match my system GTK theme here. And again all fonts in those system dialogs are broken (= displayed as box characters).

This is a great test case, which is very difficult to reproduce. Could you please test the inkscape snap? There’s been a proposed fix for fontconfig mismatches in the inkscape snap and we would love to get confirmation that it works in cases like your’s.

Thanks!