Fontconfig error: Cannot load default config file: No such file: (null)
Hi, as mentioned on irc, here is the issue report. I created a bare bone repository demoing the issue. https://github.com/brummer10/CairoFontTest
So, when build this on my local machine I get this:
when I build local using PawPaw, I get the same view, but a warning like this:
Fontconfig warning: "/home/brummer/PawPawBuilds/targets/linux-x86_64/share/fontconfig/conf.avail/05-reset-dirs-sample.conf", line 6: unknown element "reset-dirs"
when I build it on github service I get this:
and a warning:
Fontconfig error: Cannot load default config file: No such file: (null)
resutling binary is here: https://github.com/brummer10/CairoFontTest/actions/runs/15520333037/artifacts/3283935293
now, when I run
export FONTCONFIG_PATH=/etc/fonts
the warning is gone and the fonts been displayed correct.
this could be reached as well by issue
setenv("FONTCONFIG_PATH", "/etc/fonts", true);
in the main function, but I guess it isn't a good idea to do so in a plugin.
this font issue could become more wired depending on the machine were the binary runs, look here for example: https://github.com/brummer10/NeuralRack/issues/18
Note, the same warnings appear when I didn't select a font for cairo but just use the default one. Do you've any idea how we could solve that?
the pics you have uploaded seem to be the same..?
Not really. Look at the "a" in "Sans", and the "i" in "Serif". That are not the same fonts. For the roboto fonts, it seems they are loaded correct.
So the only suitable solution I found was to add
export FONTCONFIG_PATH=/etc/fonts
to my ~.profile file.
env vars are not nice. we will need to either patch fontconfig or just change build to not use install prefix as the /etc location.
something like ./configure --prefix=~/PawPawBuilds/... --etcdir=/etc but didnt check if this is possible yet
I've tried to build fontconfig in PawPaw with
--sysconfdir=/etc
That should do the trick, but then fontconfig fail on the install step with no permission to write to '/etc'
huh that is not very nice. then I guess here we have no chance but to patch the sources to hardcode its location.
I got it working, somehow
I added FONTCONFIG_EXTRAFLAGS+=" --prefix=/usr" to the bootstrap-plugins.sh, and then after it is build, I run to all makefiles in the fontconfig subfolders and change prefix=/usr with prefix= the contend of "${PAWPAW_PREFIX}".
Also RUN_FC_CACHE_TEST needs to be disabled, as it fail, by set RUN_FC_CACHE_TEST = false in the topdir makefile
Then one could run make install successful.
Doing a build test shows that a resulting binary now use Fontconfig from /usr/share/
Okay, a bit easier will be just add the --prefix=/usr EXTRAFLAG and then implement DESTDIR="${PAWPAW_PREFIX}" before make install. That worked!
So this is what works for me:
--- a/bootstrap-plugins.sh
+++ b/bootstrap-plugins.sh
@@ -169,13 +169,19 @@ if [ "${MACOS}" -eq 0 ]; then
FONTCONFIG_EXTRAFLAGS+=" --enable-libxml2"
fi
+if [ "${LINUX}" -eq 1 ]; then
+ FONTCONFIG_EXTRAFLAGS+=" --prefix=/usr"
+fi
+
# workaround missing implementation, see https://github.com/emscripten-core/emscripten/issues/12093
if [ "${WASM}" -eq 1 ]; then
export EXTRA_CFLAGS="-Duuid_generate_random=uuid_generate"
fi
+FONTCONFIG_DESTDIR="${PAWPAW_PREFIX}"
+
download fontconfig "${FONTCONFIG_VERSION}" "${FONTCONFIG_URL}"
-build_autoconf fontconfig "${FONTCONFIG_VERSION}" "${FONTCONFIG_EXTRAFLAGS}"
+build_autoconf fontconfig "${FONTCONFIG_VERSION}" "${FONTCONFIG_EXTRAFLAGS}" "${FONTCONFIG_DESTDIR}"
--- a/setup/functions.sh
+++ b/setup/functions.sh
@@ -214,6 +214,7 @@ function build_autoconf() {
local pkgname="${1}"
local version="${2}"
local extraconfrules="${3}"
+ local extradestdir="${4}"
local pkgdir="${PAWPAW_BUILDDIR}/${pkgname}-${version}"
@@ -247,7 +248,11 @@ function build_autoconf() {
if [ ! -f "${pkgdir}/.stamp_installed" ]; then
pushd "${pkgdir}"
- make ${MAKE_ARGS} install -j 1
+ if [ -z "${extradestdir}" ]; then
+ make ${MAKE_ARGS} install -j 1
+ else
+ DESTDIR=${extradestdir} make ${MAKE_ARGS} install -j 1
+ fi
touch .stamp_installed
popd
fi