Nixpkgs: terminus not found by fontconfig in 18.03

Created on 28 Mar 2018  Â·  18Comments  Â·  Source: NixOS/nixpkgs

Issue description

With pkgs.terminus_font, a bitmap font, in fonts.fonts, as of 18.03 fc-match Terminus does not find the font, fc-cache -v |grep fonts/terminus returns existing cache is valid: 0 fonts, 0 dirs, and fontconfig-based programs formerly configured to use it switch to a fallback font.

In 17.09, the font is found correctly, and fc-cache -v |grep fonts/terminus returns existing cache is valid: 18 fonts, 0 dirs. Strangely, xlsfonts is able to find the font in both 17.09 and 18.03. fc-scan seems to successfully process the font files.

The contents of the font directory appear to be the same on both systems:

fonts.dir        ter-x12n.pcf.gz  ter-x16b.pcf.gz  ter-x18n.pcf.gz  ter-x22b.pcf.gz  ter-x24n.pcf.gz  ter-x32b.pcf.gz
fonts.scale      ter-x14b.pcf.gz  ter-x16n.pcf.gz  ter-x20b.pcf.gz  ter-x22n.pcf.gz  ter-x28b.pcf.gz  ter-x32n.pcf.gz
ter-x12b.pcf.gz  ter-x14n.pcf.gz  ter-x18b.pcf.gz  ter-x20n.pcf.gz  ter-x24b.pcf.gz  ter-x28n.pcf.gz

Steps to reproduce

Set fonts.fonts = [ pkgs.terminus_font ]; and attempt to use the font, e.g. with fc-match Terminus.

Technical details

  • system: "x86_64-linux"
  • host os: Linux 4.14.27, NixOS, 18.03pre131327.0e7c9b32817 (Impala)
  • multi-user?: yes
  • sandbox: no
  • version: nix-env (Nix) 2.0
  • channels(root): "nixos-18.03pre131327.0e7c9b32817"
  • channels(user): ""
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
stale

Most helpful comment

There's a fix!

Nuking ~/.cache/fontconfig fixed the issue for me. I'm guessing a GC following the update to 18.03 invalidated the path to [an intermediate reference to] terminus and fontconfig silently fell back on another font instead of reporting the error.

To prevent this issue from recurring in the future, fontconfig could be fixed to drop a cache that contains invalid data, or perhaps we could somehow force all user-specific caches to be dropped.

All 18 comments

I confirm that this issue reproduces for me also.

Interestingly, fc-match Terminus returns nothing, but sudo fc-match Terminus gives the correct font files. Same issue with pkgs.profont
Issue both in 17.09 and now in 18.03.

I can't reproduce this. fc-match as my regular user produces ter-x32n.pcf.gz: "Terminus (ttf)" "Regular" if terminus_font is in fonts.fonts or in the user profile for me.

 - system: `"x86_64-linux"`
 - host os: `Linux 4.15.15, NixOS, 18.03.131807.489a14add9a (Impala)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.0`
 - channels(root): `"nixos-18.03.131807.489a14add9a"`
 - channels(linus): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs`

This still reproduces for me on latest 18.03. I also confirm that fc-match gives the correct result as root for some reason.

There's a fix!

Nuking ~/.cache/fontconfig fixed the issue for me. I'm guessing a GC following the update to 18.03 invalidated the path to [an intermediate reference to] terminus and fontconfig silently fell back on another font instead of reporting the error.

To prevent this issue from recurring in the future, fontconfig could be fixed to drop a cache that contains invalid data, or perhaps we could somehow force all user-specific caches to be dropped.

@Ralith The issue actually reproduces for me after some time -- something in the cache/fontconfig folder is being recreated.

That seems very strange; where could it be getting invalid/obsolete data from? Still working fine here; I take it you're certain you didn't perform any nix operations that might have affected fonts or fontconfig in the intervening time?

fc-cache -f might also be worth trying.

I just had this issue recur, nuked the cache to fix it, and then had it recur again in the space of a few hours during which I ran no nix operations whatsoever, although a long-running LLVM build required by a nix-shell invocation may have completed. It looks like this isn't (just) an issue with updates: something is actively mangling the cache.

edit: it just happened again in the last ten minutes o_O

Which desktop environment are you using? Maybe there's some connection with that.

I don't use a DE, just i3.

The plot thickens…

(same here)

As a hack, maybe try removing the contents of ~/.cache/fontconfig and then setting it read-only?

I have figured out that the fix works fine for me unless I restart chromium, which then leads to the problem again. I am not sure, how it can be related, but it perfectly reproduces.

I haven't been restarting chromium at all, but I do make much heavier use of it on the machine where the issue was recurring than on the machine where it doesn't seem to recur...

Chromium uses its own bundled fontconfig, built during the huge build, just as it does with many other libraries – see CC obj/third_party/fontconfig/fontconfig/... in the logs. I have no idea what differences they have.

I use Firefox, but used chromium for a quick check yesterday and that brought back the issue.

Encountered this issue yesterday, with same cause and fix.

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

tomberek picture tomberek  Â·  3Comments

spacekitteh picture spacekitteh  Â·  3Comments

sid-kap picture sid-kap  Â·  3Comments

rzetterberg picture rzetterberg  Â·  3Comments

grahamc picture grahamc  Â·  3Comments