about summary refs log tree commit diff
path: root/nixos/modules/config
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2019-08-29 04:16:34 +0200
committerworldofpeace <worldofpeace@protonmail.ch>2019-09-01 00:09:25 -0400
commitb31c7e527e1c1495e554ca453e129c310f6dd210 (patch)
tree598eca78541f4d966db5a8b3578819947bab51ea /nixos/modules/config
parent6bf3d68b8d11c726c3b2105c6edd4125c0a7a859 (diff)
downloadnixlib-b31c7e527e1c1495e554ca453e129c310f6dd210.tar
nixlib-b31c7e527e1c1495e554ca453e129c310f6dd210.tar.gz
nixlib-b31c7e527e1c1495e554ca453e129c310f6dd210.tar.bz2
nixlib-b31c7e527e1c1495e554ca453e129c310f6dd210.tar.lz
nixlib-b31c7e527e1c1495e554ca453e129c310f6dd210.tar.xz
nixlib-b31c7e527e1c1495e554ca453e129c310f6dd210.tar.zst
nixlib-b31c7e527e1c1495e554ca453e129c310f6dd210.zip
nixos/fontconfig: Allow setting default emoji font
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 <prefer> from <alias> 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 <alias>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
Diffstat (limited to 'nixos/modules/config')
-rw-r--r--nixos/modules/config/fonts/fontconfig.nix19
1 files changed, 18 insertions, 1 deletions
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 != []) ''
-        <alias>
+        <alias binding="same">
           <family>${name}</family>
           <prefer>
           ${concatStringsSep ""
@@ -139,6 +139,8 @@ let
 
       ${genDefault cfg.defaultFonts.monospace "monospace"}
 
+      ${genDefault cfg.defaultFonts.emoji "emoji"}
+
     </fontconfig>
   '';
 
@@ -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 = {