From b31c7e527e1c1495e554ca453e129c310f6dd210 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Thu, 29 Aug 2019 04:16:34 +0200 Subject: [PATCH 1/4] nixos/fontconfig: Allow setting default emoji font MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In fontconfig’s 60-generic.conf, order of preference is estabilished for emoji font family. Because fontconfig parses the config files in lexicographic order, appending each from element to the family’s prefer list (to be prepended before the family) [1], our font family defaults stored in 52-nixos-default-fonts.conf will take precedence. That is, of course, unless the default „weak“ binding [2] is used. Emoji family binds strongly [3], so we need to set binding to “same” for our es to be considered before the ones from 60-generic.conf. By default, we will set the option to all emoji fonts supported by fontconfig, so that emoji works for user if they have at least one emoji font installed. If they have multiple emoji fonts installed, we will use the fontconfig’s order of preference [4]. [1]: https://github.com/bohoomil/fontconfig-ultimate/issues/51#issuecomment-64678322 [2]: https://www.freedesktop.org/software/fontconfig/fontconfig-user.html#AEN25 [3]: https://gitlab.freedesktop.org/fontconfig/fontconfig/commit/cc8442dec85e9d416436d19eeae1783f2d3008f0 [4]: https://gitlab.freedesktop.org/fontconfig/fontconfig/commit/c41c9220181b203d1cf1f6435f6e3735cb7c84ac --- nixos/modules/config/fonts/fontconfig.nix | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix index fe0b88cf4c26..bcb86f11ead7 100644 --- a/nixos/modules/config/fonts/fontconfig.nix +++ b/nixos/modules/config/fonts/fontconfig.nix @@ -116,7 +116,7 @@ let defaultFontsConf = let genDefault = fonts: name: optionalString (fonts != []) '' - + ${name} ${concatStringsSep "" @@ -139,6 +139,8 @@ let ${genDefault cfg.defaultFonts.monospace "monospace"} + ${genDefault cfg.defaultFonts.emoji "emoji"} + ''; @@ -344,6 +346,21 @@ in in case multiple languages must be supported. ''; }; + + emoji = mkOption { + type = types.listOf types.str; + default = ["Noto Color Emoji"]; + description = '' + System-wide default emoji font(s). Multiple fonts may be listed + in case a font does not support all emoji. + + Note that fontconfig matches color emoji fonts preferentially, + so if you want to use a black and white font while having + a color font installed (eg. Noto Color Emoji installed alongside + Noto Emoji), fontconfig will still choose the color font even + when it is later in the list. + ''; + }; }; hinting = { From ee7c590b605d07394f0f65c603bf5cf169e6caad Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Thu, 29 Aug 2019 14:02:20 +0200 Subject: [PATCH 2/4] nixos.tests.fontconfig-default-fonts: init Make sure the fonts.enableDefaultFonts option works. --- nixos/release-combined.nix | 1 + nixos/tests/all-tests.nix | 1 + nixos/tests/fontconfig-default-fonts.nix | 28 ++++++++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 nixos/tests/fontconfig-default-fonts.nix diff --git a/nixos/release-combined.nix b/nixos/release-combined.nix index ffa087bb6f28..9e2109d88b5f 100644 --- a/nixos/release-combined.nix +++ b/nixos/release-combined.nix @@ -68,6 +68,7 @@ in rec { nixos.tests.chromium.x86_64-linux or [] (all nixos.tests.firefox) (all nixos.tests.firewall) + (all nixos.tests.fontconfig-default-fonts) (all nixos.tests.gnome3-xorg) (all nixos.tests.gnome3) (all nixos.tests.pantheon) diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 557ee78df7c6..14dca7409c46 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -87,6 +87,7 @@ in flatpak = handleTest ./flatpak.nix {}; flatpak-builder = handleTest ./flatpak-builder.nix {}; fluentd = handleTest ./fluentd.nix {}; + fontconfig-default-fonts = handleTest ./fontconfig-default-fonts.nix {}; fsck = handleTest ./fsck.nix {}; fwupd = handleTestOn ["x86_64-linux"] ./fwupd.nix {}; # libsmbios is unsupported on aarch64 gdk-pixbuf = handleTest ./gdk-pixbuf.nix {}; diff --git a/nixos/tests/fontconfig-default-fonts.nix b/nixos/tests/fontconfig-default-fonts.nix new file mode 100644 index 000000000000..1991cec92189 --- /dev/null +++ b/nixos/tests/fontconfig-default-fonts.nix @@ -0,0 +1,28 @@ +import ./make-test.nix ({ lib, ... }: +{ + name = "fontconfig-default-fonts"; + + machine = { config, pkgs, ... }: { + fonts.enableDefaultFonts = true; # Background fonts + fonts.fonts = with pkgs; [ + noto-fonts-emoji + cantarell-fonts + twitter-color-emoji + source-code-pro + gentium + ]; + fonts.fontconfig.defaultFonts = { + serif = [ "Gentium Plus" ]; + sansSerif = [ "Cantarell" ]; + monospace = [ "Source Code Pro" ]; + emoji = [ "Twitter Color Emoji" ]; + }; + }; + + testScript = '' + $machine->succeed("fc-match serif | grep '\"Gentium Plus\"'"); + $machine->succeed("fc-match sans-serif | grep '\"Cantarell\"'"); + $machine->succeed("fc-match monospace | grep '\"Source Code Pro\"'"); + $machine->succeed("fc-match emoji | grep '\"Twitter Color Emoji\"'"); + ''; +}) From eafe887671627f78d85e007f0eeaf4865be87105 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Thu, 29 Aug 2019 23:03:46 +0200 Subject: [PATCH 3/4] nixos/fonts.enableDefaultFonts: add Noto Emoji These days, emoji are ubiqitous so we need to add emoji font. --- nixos/modules/config/fonts/fonts.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/modules/config/fonts/fonts.nix b/nixos/modules/config/fonts/fonts.nix index 0dd01df9da74..abb806b601a7 100644 --- a/nixos/modules/config/fonts/fonts.nix +++ b/nixos/modules/config/fonts/fonts.nix @@ -43,6 +43,7 @@ with lib; pkgs.xorg.fontmiscmisc pkgs.xorg.fontcursormisc pkgs.unifont + pkgs.noto-fonts-emoji ]; }; From fcec3ff0dcb31dec83ee863273a8b0ee6261e386 Mon Sep 17 00:00:00 2001 From: worldofpeace Date: Fri, 30 Aug 2019 20:34:45 -0400 Subject: [PATCH 4/4] rl-1909: add note about default emoji font --- nixos/doc/manual/release-notes/rl-1909.xml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/nixos/doc/manual/release-notes/rl-1909.xml b/nixos/doc/manual/release-notes/rl-1909.xml index e75543670e48..f831cfcdc574 100644 --- a/nixos/doc/manual/release-notes/rl-1909.xml +++ b/nixos/doc/manual/release-notes/rl-1909.xml @@ -600,6 +600,26 @@ removed from nixpkgs due to lack of maintainer. + + + Using adds a default emoji font noto-fonts-emoji. + + Users of the following options will have this enabled by default: + + + + + + + + + + + + + + +