How can I fix my broken GTK fonts?

Ever since I upgraded to 20.09 I’ve had broken fonts in some GTK apps, for example GIMP:

I figured it might be names of fonts in my fonts.fontconfig.defaultFonts:

{
  fonts = {
    fontconfig = {
      cache32Bit = true;
      allowBitmaps = true;
      useEmbeddedBitmaps = true;
      defaultFonts = {
        serif = [ "Inconsolata" ];
        sansSerif = [ "Inconsolata" ];
        monospace = [ "Inconsolata" ];
      };
    };
}

But when I follow the Fonts Wiki page instructions I can’t get the list:

 > cd /nix/var/nix/profiles/system/sw/share/X11-fonts   
cd: no such file or directory: /nix/var/nix/profiles/system/sw/share/X11-fonts

Because the specified folder doesn’t exist.

What am I doing wrong?

This is most likely corrupted font cache. Try deleting ~/.cache/fontconfig.

2 Likes

Good idea, but no cigar, deleted ~/.cache/fontconfig but nothing changed. Even restarted X server.

Can you make sure your GIMP is from the same channel revision as your underlying system? For example, you are not using GIMP from 20.03 installed by nix-env?

1 Like

Oh, yes, yes it was!

 > which gimp
/home/sochan/.nix-profile/bin/gimp

I didn’t know this could cause issues like that. Good to know. Thanks for help @jtojnar.

Yes. Nix and Nixpkgs try very hard to make everything hermetic but unfortunately some libraries are inherently stateful or rely on global data.

We have managed to make packages built against fontconfig from recent revisions of 20.03, 20.09 and nixos-unstable compatible with each other but some older revisions (this was fixed in September on 20.03) do not contain our compatibility patches so programs based on those will cause issues.

It is generally a good idea to use the latest revisions of nixos-unstable and nixos stable branches, which are least likely to have incompatibility issues like this.

2 Likes