Unexpected font selection on flatpak on ostree-based OS like Silverblue
Context
Flatpak do bind-mount the host font directory and fontconfig caches and expects to use a font from host without regenerating caches. This usually is done by remapping a font directory in fontconfig but this feature doesn't work well on ostree-based OS such as Silverblue.
[📦 org.fedoraproject.Platform ~]$ fc-match :variable=true file
:file=/usr/share/fonts/google-noto-vf/NotoSans[wght].ttf
[📦 org.fedoraproject.Platform ~]$ ls /usr/share/fonts/google-noto-vf
NotoSans-Italic-VF.ttf NotoSansMono-VF.ttf NotoSans-VF.ttf NotoSerif-Italic-VF.ttf NotoSerif-VF.ttf
Description
fontconfig determines a cache name from a directory path and generate a cache in the same name for /usr/share/fonts for example. flatpak runtime recognizes two cache files at least for own and host where is actually mounted at /run/host/fonts. fontconfig idenfifies caches by a directory path and timestamp. thus, there was no problem even though they have same cache name. However, ostree-based OS sets the epoch 0 timestamp to directories/files as well as flatpak. so fontconfig got confused and unable to remap them properly. To avoid this situation, flatpak may wants to give a different cache name for their own fonts and prevent a conflict.
Acceptance Criteria
I've added a test case for this in fontconfig upstream git repo: https://gitlab.freedesktop.org/fontconfig/fontconfig/-/commit/b0a5af1bd2ec8cffd718b437751b7a845c38eee9
Please check it out.
To see what exactly happens at this moment, try to remove salt="flatpak"
lines from the script at the above link.