Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default fonts configuration not working #16026

Closed
romildo opened this issue Jun 6, 2016 · 20 comments
Closed

Default fonts configuration not working #16026

romildo opened this issue Jun 6, 2016 · 20 comments
Labels
0.kind: bug Something is broken 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS

Comments

@romildo
Copy link
Contributor

romildo commented Jun 6, 2016

Issue description

In my unstable NixOS configuration I have

  fonts = {
    fonts = with pkgs; [
      dejavu_fonts
      source-code-pro
      source-sans-pro
      source-serif-pro
    ];
    fontconfig = {
      defaultFonts = {
        monospace = [ "Source Code Pro" ];
        sansSerif = [ "Source Sans Pro" ];
        serif     = [ "Source Serif Pro" ];
      };
      ultimate = {
        enable = false;
      };
    };
  };

And it seems that the fonts.fontconfig.defaultFonts options are not being taken into account:

$ fc-match monospace
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"

$ fc-match sans-serif
DejaVuSans.ttf: "DejaVu Sans" "Book"

$ fc-match serif
DejaVuSerif.ttf: "DejaVu Serif" "Book"

Is there anything missing on the configuration or is it a bug?

Technical details

  • System: (NixOS: nixos-version, Ubuntu/Fedora: lsb_release -a, ...)

    16.09pre84674.fbde3a7 (Flounder)

  • Nix version: (run nix-env --version)

    nix-env (Nix) 1.11.2

  • Nixpkgs version: (run nix-instantiate --eval '<nixpkgs>' -A lib.nixpkgsVersion)

    "16.09pre84674.fbde3a7"

@romildo romildo changed the title Default fonts not working Default fonts configuration not working Jun 6, 2016
@ericsagnes
Copy link
Contributor

What are the contents of /etc/fonts/conf.d/60-nixos-generic-alias.conf?

@romildo
Copy link
Contributor Author

romildo commented Jun 7, 2016

The options are reflected in /etc/fonts/conf.d/60-nixos-generic-alias.conf, but somehow fontconfig is not following it.

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>

  <!-- Default fonts -->
  <alias>
  <family>sans-serif</family>
  <prefer>
    <family>Source Sans Pro</family>
  </prefer>
</alias>

  <alias>
  <family>serif</family>
  <prefer>
    <family>Source Serif Pro</family>
  </prefer>
</alias>

  <alias>
  <family>monospace</family>
  <prefer>
    <family>Source Code Pro</family>
  </prefer>
</alias>


</fontconfig>

@ericsagnes
Copy link
Contributor

So it is not a problem with the configuration files.
It could be a fontconfig cache issue, does manually clearing the cache (fc-cache -rv) improve the situation?

@romildo
Copy link
Contributor Author

romildo commented Jun 7, 2016

After running fc-cache -rv both as a normal user and as root, and rebooting the system, the default font settings are still not working.

fc-cache -rv tells something about an unwritable cache directory:

# fc-cache -rv
/nix/store/ycpxf0i8df41cd20wbv9amkk1ijjq24a-dejavu-fonts-2.35: caching, new cache contents: 0 fonts, 1 dirs
[...]
Re-scanning /nix/store/bsl0fhisfb180a9v1zrgn3la4ja2m7gv-source-serif-pro-1.017/share/fonts: caching, new cache contents: 0 fonts, 1 dirs
/root/.cache/fontconfig: cleaning cache directory
/var/cache/fontconfig: cleaning cache directory
/nix/store/a8kmvl58x4xsa2flwrz17c4nd3g0khxd-fc-cache: not cleaning unwritable cache directory
fc-cache: succeeded

Maybe this can be relevant.

@joachifm joachifm added 0.kind: bug Something is broken 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS labels Jun 7, 2016
@vcunat
Copy link
Member

vcunat commented Jun 9, 2016

I don't think so. The unwritable caches are intentional.

@romildo
Copy link
Contributor Author

romildo commented Jun 9, 2016

I have also tried disabling fontconfig-ultimate settings (by means of fonts.fontconfig.ultimate.enable), but the issue persists.

@abbradar
Copy link
Member

abbradar commented Jun 9, 2016

Hm, maybe we have the configuration wrong? Try making it work with $XDG_CONFIG_HOME/fontconfig/fonts.conf (it's a user-wise configuration file which should have higher priority than system ones).

@ericsagnes
Copy link
Contributor

You can check which settings files are loaded by using FC_DEBUG=1024, for example:

$ FC_DEBUG=1024 fc-match serif | less

maybe that can give you a hint of what is going wrong, the last files loaded should the ones generated by nix:

        Loading config file /etc/fonts/2.11/conf.d/60-nixos-generic-alias.conf
        Loading config file /etc/fonts/2.11/conf.d/99-user.conf

@romildo
Copy link
Contributor Author

romildo commented Jun 9, 2016

$XDG_CONFIG_HOME is not set on my system. Should it be?

After setting $XDG_CONFIG_HOME:

$ export XDG_CONFIG_HOME=~/.config

And saving $XDG_CONFIG_HOME/fontconfig/fonts.conf with the contents:

<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>

  <!-- Default fonts -->
  <alias>
    <family>sans-serif</family>
    <prefer>
      <family>Source Sans Pro</family>
    </prefer>
  </alias>

  <alias>
    <family>serif</family>
    <prefer>
      <family>Source Serif Pro</family>
    </prefer>
  </alias>

  <alias>
    <family>monospace</family>
    <prefer>
      <family>Ubuntu Mono</family>
    </prefer>
  </alias>

</fontconfig>

And rebuilding the font information caches (as a normal user) with the command:

$ fc-cache -rv

The default fonts are not changed:

$ fc-match monospace
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"

$ fc-match sans-serif
DejaVuSans.ttf: "DejaVu Sans" "Book"

$ fc-match serif
DejaVuSerif.ttf: "DejaVu Serif" "Book"

@romildo
Copy link
Contributor Author

romildo commented Jun 9, 2016

$ FC_DEBUG=1024 fc-match monospace
FC_DEBUG=1024
    Loading config file /etc/fonts/2.11/fonts.conf
    Scanning config dir /nix/store/s7ik4lhwl0r8kx83x9gly2bb8h52z8r9-fontconfig-2.11.1/etc/fonts/conf.d
    Loading config file /nix/store/s7ik4lhwl0r8kx83x9gly2bb8h52z8r9-fontconfig-2.11.1/etc/fonts/conf.d/10-scale-bitmap-fonts.conf
    Loading config file /nix/store/s7ik4lhwl0r8kx83x9gly2bb8h52z8r9-fontconfig-2.11.1/etc/fonts/conf.d/20-unhint-small-vera.conf
    Loading config file /nix/store/s7ik4lhwl0r8kx83x9gly2bb8h52z8r9-fontconfig-2.11.1/etc/fonts/conf.d/30-metric-aliases.conf
    Loading config file /nix/store/s7ik4lhwl0r8kx83x9gly2bb8h52z8r9-fontconfig-2.11.1/etc/fonts/conf.d/30-urw-aliases.conf
    Loading config file /nix/store/s7ik4lhwl0r8kx83x9gly2bb8h52z8r9-fontconfig-2.11.1/etc/fonts/conf.d/40-nonlatin.conf
    Loading config file /nix/store/s7ik4lhwl0r8kx83x9gly2bb8h52z8r9-fontconfig-2.11.1/etc/fonts/conf.d/45-latin.conf
    Loading config file /nix/store/s7ik4lhwl0r8kx83x9gly2bb8h52z8r9-fontconfig-2.11.1/etc/fonts/conf.d/49-sansserif.conf
    Loading config file /nix/store/s7ik4lhwl0r8kx83x9gly2bb8h52z8r9-fontconfig-2.11.1/etc/fonts/conf.d/60-latin.conf
    Loading config file /nix/store/s7ik4lhwl0r8kx83x9gly2bb8h52z8r9-fontconfig-2.11.1/etc/fonts/conf.d/65-fonts-persian.conf
    Loading config file /nix/store/s7ik4lhwl0r8kx83x9gly2bb8h52z8r9-fontconfig-2.11.1/etc/fonts/conf.d/65-nonlatin.conf
    Loading config file /nix/store/s7ik4lhwl0r8kx83x9gly2bb8h52z8r9-fontconfig-2.11.1/etc/fonts/conf.d/69-unifont.conf
    Loading config file /nix/store/s7ik4lhwl0r8kx83x9gly2bb8h52z8r9-fontconfig-2.11.1/etc/fonts/conf.d/80-delicious.conf
    Loading config file /nix/store/s7ik4lhwl0r8kx83x9gly2bb8h52z8r9-fontconfig-2.11.1/etc/fonts/conf.d/90-synthetic.conf
    Scanning config dir /etc/fonts/2.11/conf.d
    Loading config file /etc/fonts/2.11/conf.d/00-nixos.conf
    Loading config file /etc/fonts/2.11/conf.d/10-nixos-rendering.conf
    Loading config file /etc/fonts/2.11/conf.d/60-nixos-generic-alias.conf
    Loading config file /etc/fonts/2.11/conf.d/99-user.conf
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"

It looks normal to me.

@vcunat
Copy link
Member

vcunat commented Jun 9, 2016

$XDG_CONFIG_HOME is not set on my system. Should it be?

No, it's defined in standards that $HOME/.config is the default value.

@ericsagnes
Copy link
Contributor

ericsagnes commented Jun 9, 2016

@romildo Can you try to set the <alias> tag in your ~/.config/fontconfig/fonts.conf to <alias binding="strong"> and check if it improves the situation?

@romildo
Copy link
Contributor Author

romildo commented Jun 9, 2016

@ericsagnes With <alias binding="strong"> it works.

@ericsagnes
Copy link
Contributor

With it works.

So this should be a priority issue.
This might be due to the setting files not being interleaved, so default and font-ultimate settings over 60 take precedence on 60-nixos-generic-alias.conf.

My guess is that the <prefer> declaration in 65-wqy-zenhei.conf is setting deja vu fonts as the most preferred font and the configuration.nix settings get a lower priority.

You can try to use -s flag to fc-match to see where the fonts set in configuration.nix appears in the sorted list of matched fonts.

Maybe we should use lndir or buildEnv as suggested in #9110 to have interleaved font settings directory.

@romildo
Copy link
Contributor Author

romildo commented Jun 10, 2016

I have edited some of my prior comments to use a more simple font configuration, in the hope it would make it easier to fix this issue. Basically I have disabled fontconfig ultimate and reduced the list of installed fonts

@romildo
Copy link
Contributor Author

romildo commented Jun 10, 2016

Looking at each one of the config files reported by the command FC_DEBUG=1024 fc-match monospace I can find just two files that mention both the monospace and the DejaVu Sans Mono families:

$ grep -i 'DejaVu Sans Mono' $(grep -lir monospace /nix/store/s7ik4lhwl0r8kx83x9gly2bb8h52z8r9-fontconfig-2.11.1/etc/fonts/conf.d/* /etc/fonts/2.11/conf.d/*)
/nix/store/s7ik4lhwl0r8kx83x9gly2bb8h52z8r9-fontconfig-2.11.1/etc/fonts/conf.d/45-latin.conf:       <family>DejaVu Sans Mono</family>
/nix/store/s7ik4lhwl0r8kx83x9gly2bb8h52z8r9-fontconfig-2.11.1/etc/fonts/conf.d/60-latin.conf:           <family>DejaVu Sans Mono</family>
  • 45-latin.conf, that sets a default alias:
    <alias>
        <family>DejaVu Sans Mono</family>
        <default><family>monospace</family></default>
    </alias>
  • 60-latin.conf, that sets a prefer alias:
    <alias>
        <family>monospace</family>
        <prefer>
            <family>Bitstream Vera Sans Mono</family>
            <family>DejaVu Sans Mono</family>
            <family>Inconsolata</family>
            <family>Andale Mono</family>
            <family>Courier New</family>
            <family>Cumberland AMT</family>
            <family>Luxi Mono</family>
            <family>Nimbus Mono L</family>
            <family>Courier</family>
        </prefer>
    </alias>

Maybe this information can help to find a fix.

@romildo
Copy link
Contributor Author

romildo commented Jun 10, 2016

Using -s flag to fc-match to see where the fonts set in configuration.nix appears in the sorted list of matched fonts:

$ fc-match -s monospace
DejaVuSansMono.ttf: "DejaVu Sans Mono" "Book"
DejaVuSansMono-Bold.ttf: "DejaVu Sans Mono" "Bold"
luximr.ttf: "Luxi Mono" "Regular"
FreeMono.ttf: "FreeMono" "нормален"
SourceCodePro-Regular.otf: "Source Code Pro" "Regular"
FreeSans.ttf: "FreeSans" "нормален"
FreeSerif.ttf: "FreeSerif" "нормален"
DejaVuSans.ttf: "DejaVu Sans" "Book"
DejaVuSerif.ttf: "DejaVu Serif" "Book"
SourceSansPro-Regular.otf: "Source Sans Pro" "Regular"
LiberationMono-Regular.ttf: "Liberation Mono" "Regular"
Ubuntu-C.ttf: "Ubuntu Condensed" "Regular"
Ubuntu-R.ttf: "Ubuntu" "Regular"
unifont.ttf: "Unifont" "Medium"
DejaVuSerif-Italic.ttf: "DejaVu Serif" "Italic"
LiberationSerif-Italic.ttf: "Liberation Serif" "Italic"
DejaVuSans-BoldOblique.ttf: "DejaVu Sans" "Bold Oblique"
6x13.pcf.gz: "Fixed" "SemiCondensed"
9x15.pcf.gz: "Fixed" "Regular"

@alecmev
Copy link
Contributor

alecmev commented Apr 15, 2017

@ericsagnes This should be closed, right?

@romildo
Copy link
Contributor Author

romildo commented May 11, 2017

I am seeing this bug again on NixOS unstable 17.09pre107265.0afb6d789c (Hummingbird).

I have in configuration.nix:

  fonts = {
    fonts = with pkgs; [
      dejavu_fonts
      source-code-pro
      source-sans-pro
      source-serif-pro
    ];
    fontconfig = {
      penultimate.enable = false;
      defaultFonts = {
        monospace = [ "Source Code Pro" ];
        sansSerif = [ "Source Sans Pro" ];
        serif     = [ "Source Serif Pro" ];
      };
    };
  };

But sanserif and serif default fonts are not being obeyed:

$ for f in mono sans serif; do fc-match $f; done
SourceCodePro-Regular.otf: "Source Code Pro" "Regular"
DejaVuSans.ttf: "DejaVu Sans" "Book"
DejaVuSerif.ttf: "DejaVu Serif" "Book"

cc @ericsagnes @vcunat

@ericsagnes
Copy link
Contributor

Should be fixed by #25720.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants