remap-dir doesn't seem to work
I'm trying to make use of the font-dirs.xml fragment that flatpak generates, with elements, but it does not seem to work.
My analysis so far:
I bind mount /usr/share/fonts to ~/test-fonts and /usr/lib/fontconfig/cacheto ~/test-font-caches, and make a configuration that has the following:
<dir>/var/home/mclasen/test-fonts</dir>
<cachedir>/var/home/mclasen/test-font-caches</cachedir>
<remap-dir as-path="/usr/share/fonts">/var/home/mclasen/test-fonts</remap-dir>
The idea is to mimic what flatpak does with the font dirs and caches.
When I run fc-match cantarell (with some debug spew), I see the following triples in config->fontDirs:
[...]
/var/home/mclasen/test-fonts NULL NULL
/var/home/mclasen/test-fonts /usr/share/fonts NULL
[...]
The first of these comes from the <dir>
element, and the second from the <remap-dir>
.
Sadly, this has the consequence that FcConfigMapFontPath never maps /var/home/mclasen/test-fonts to anything else, since it always finds the first triple, never the one that has the mapping.
I think the problem is that FcStrSetAddFilenamePairWithSalt() tries to remove the existing entry by calling FcStrSetMemberAB() which does not find the entry without the map. If I replace
if (FcStrSetMemberAB (set, new_a, new_b, &rs))
{
FcStrSetDel (set, rs);
}
with
FcStrSetDel (set, new_a);
things work as I would expect them to.