NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.06k stars 14.1k forks source link

terminus not found by fontconfig in 18.03 #38017

Open Ralith opened 6 years ago

Ralith commented 6 years ago

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

volhovm commented 6 years ago

I confirm that this issue reproduces for me also.

ghost commented 6 years ago

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.

lheckemann commented 6 years ago

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`
Ralith commented 6 years ago

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

Ralith commented 6 years ago

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.

volhovm commented 6 years ago

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

Ralith commented 6 years ago

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?

lheckemann commented 6 years ago

fc-cache -f might also be worth trying.

Ralith commented 6 years ago

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

lheckemann commented 6 years ago

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

Ralith commented 6 years ago

I don't use a DE, just i3.

lheckemann commented 6 years ago

The plot thickens…

(same here)

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

volhovm commented 6 years ago

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.

Ralith commented 6 years ago

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

vcunat commented 6 years ago

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.

martingms commented 6 years ago

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

octalsrc commented 6 years ago

Encountered this issue yesterday, with same cause and fix.

stale[bot] commented 4 years ago

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.