git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #67667 from jtojnar/default-emoji

nixos/fontconfig: Allow setting default emoji font

commit83d60f72ae5a0f45da8d3bde0e3273f91dcffbf7 authorworldofpeace <worldofpeace@protonmail.ch> dateSun 1 Sep 2019, 03:58 (7 years ago) parent7d5375efcec3ff
6 files changed+69−1
nixos/doc/manual/release-notes/rl-1909.xml+20 nixos/modules/config/fonts/fontconfig.nix+18−1 nixos/modules/config/fonts/fonts.nix+1 nixos/release-combined.nix+1 nixos/tests/all-tests.nix+1 nixos/tests/fontconfig-default-fonts.nix+28
nixos/doc/manual/release-notes/rl-1909.xml+20
@@ -600,6 +600,26 @@
600600 removed from nixpkgs due to lack of maintainer.
601601 </para>
602602 </listitem>
603+ <listitem>
604+ <para>
605+ Using <option>fonts.enableDefaultFonts</option> adds a default emoji font <literal>noto-fonts-emoji</literal>.
606+ <itemizedlist>
607+ <para>Users of the following options will have this enabled by default:</para>
608+ <listitem>
609+ <para><option>services.xserver.enable</option></para>
610+ </listitem>
611+ <listitem>
612+ <para><option>programs.sway.enable</option></para>
613+ </listitem>
614+ <listitem>
615+ <para><option>programs.way-cooler.enable</option></para>
616+ </listitem>
617+ <listitem>
618+ <para><option>services.xrdp.enable</option></para>
619+ </listitem>
620+ </itemizedlist>
621+ </para>
622+ </listitem>
603623 </itemizedlist>
604624 </section>
605625</section>
nixos/modules/config/fonts/fontconfig.nix+18−1
@@ -116,7 +116,7 @@ let
116116 defaultFontsConf =
117117 let genDefault = fonts: name:
118118 optionalString (fonts != []) ''
119− <alias>
119+ <alias binding="same">
120120 <family>${name}</family>
121121 <prefer>
122122 ${concatStringsSep ""
@@ -139,6 +139,8 @@ let
139139
140140 ${genDefault cfg.defaultFonts.monospace "monospace"}
141141
142+ ${genDefault cfg.defaultFonts.emoji "emoji"}
143+
142144 </fontconfig>
143145 '';
144146
@@ -344,6 +346,21 @@ in
344346 in case multiple languages must be supported.
345347 '';
346348 };
349+
350+ emoji = mkOption {
351+ type = types.listOf types.str;
352+ default = ["Noto Color Emoji"];
353+ description = ''
354+ System-wide default emoji font(s). Multiple fonts may be listed
355+ in case a font does not support all emoji.
356+
357+ Note that fontconfig matches color emoji fonts preferentially,
358+ so if you want to use a black and white font while having
359+ a color font installed (eg. Noto Color Emoji installed alongside
360+ Noto Emoji), fontconfig will still choose the color font even
361+ when it is later in the list.
362+ '';
363+ };
347364 };
348365
349366 hinting = {
nixos/modules/config/fonts/fonts.nix+1
@@ -43,6 +43,7 @@ with lib;
4343 pkgs.xorg.fontmiscmisc
4444 pkgs.xorg.fontcursormisc
4545 pkgs.unifont
46+ pkgs.noto-fonts-emoji
4647 ];
4748
4849 };
nixos/release-combined.nix+1
@@ -68,6 +68,7 @@ in rec {
6868 nixos.tests.chromium.x86_64-linux or []
6969 (all nixos.tests.firefox)
7070 (all nixos.tests.firewall)
71+ (all nixos.tests.fontconfig-default-fonts)
7172 (all nixos.tests.gnome3-xorg)
7273 (all nixos.tests.gnome3)
7374 (all nixos.tests.pantheon)
nixos/tests/all-tests.nix+1
@@ -87,6 +87,7 @@ in
8787 flatpak = handleTest ./flatpak.nix {};
8888 flatpak-builder = handleTest ./flatpak-builder.nix {};
8989 fluentd = handleTest ./fluentd.nix {};
90+ fontconfig-default-fonts = handleTest ./fontconfig-default-fonts.nix {};
9091 fsck = handleTest ./fsck.nix {};
9192 fwupd = handleTestOn ["x86_64-linux"] ./fwupd.nix {}; # libsmbios is unsupported on aarch64
9293 gdk-pixbuf = handleTest ./gdk-pixbuf.nix {};
nixos/tests/fontconfig-default-fonts.nixnew file+28
@@ -0,0 +1,28 @@
1+import ./make-test.nix ({ lib, ... }:
2+{
3+ name = "fontconfig-default-fonts";
4+
5+ machine = { config, pkgs, ... }: {
6+ fonts.enableDefaultFonts = true; # Background fonts
7+ fonts.fonts = with pkgs; [
8+ noto-fonts-emoji
9+ cantarell-fonts
10+ twitter-color-emoji
11+ source-code-pro
12+ gentium
13+ ];
14+ fonts.fontconfig.defaultFonts = {
15+ serif = [ "Gentium Plus" ];
16+ sansSerif = [ "Cantarell" ];
17+ monospace = [ "Source Code Pro" ];
18+ emoji = [ "Twitter Color Emoji" ];
19+ };
20+ };
21+
22+ testScript = ''
23+ $machine->succeed("fc-match serif | grep '\"Gentium Plus\"'");
24+ $machine->succeed("fc-match sans-serif | grep '\"Cantarell\"'");
25+ $machine->succeed("fc-match monospace | grep '\"Source Code Pro\"'");
26+ $machine->succeed("fc-match emoji | grep '\"Twitter Color Emoji\"'");
27+ '';
28+})