# Fixing fonts in Nix Container images

**URL:** https://discourse.nixosstag.fcio.net/t/fixing-fonts-in-nix-container-images/62586
**Category:** Guides
**Created:** [April 3, 2025, 7:51am UTC](https://discourse.nixosstag.fcio.net/t/fixing-fonts-in-nix-container-images/62586 "2025-04-03T07:51:48Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![alicebob](https://discourse.nixosstag.fcio.net/user_avatar/discourse.nixosstag.fcio.net/alicebob/32/17240_2.png) [@alicebob](https://discourse.nixosstag.fcio.net/u/alicebob)
#### Post date: [April 3, 2025, 7:51am UTC](https://discourse.nixosstag.fcio.net/t/fixing-fonts-in-nix-container-images/62586/1 "2025-04-03T07:51:48Z")

</div>

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:

```auto
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.
