Hi,
I had some trouble getting fonts to work for weasyprint
in a Docker image I made with Nix via dockerTools.buildImage
. This apparently not a very common use case, so here’s my workaround which fixed it for me. Maybe it helps someone.
Just adding pkgs.liberation_ttf
isn’t enough. Setting FONTCONFIG_FILE=...
doesn’t make it find the font, and fc-list
shows only the one fallback font.
After some searching, it turns out the fonts end up in the Docker container under /share/fonts/...
, while fontconfig searches for them in /usr/share/fonts/...
. I couldn’t figure out how to teach dockerTools.buildImage to put the fonts in the right location, so I now execute this on startup:
ln -s /share /usr
(do include pkgs.coreutils so ln
is available)
Nothing else is needed, fc-list
now shows all the fonts, and weasyprint
also finds them all, and I can make pretty PDFs again.