diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix
index 5781679241ef..a49595c58e1c 100644
--- a/nixos/modules/config/fonts/fontconfig.nix
+++ b/nixos/modules/config/fonts/fontconfig.nix
@@ -77,18 +77,6 @@ let
${fcBool cfg.hinting.autohint}
-
- ${cfg.hinting.style}
-
-
- ${fcBool cfg.antialias}
-
-
- ${cfg.subpixel.rgba}
-
-
- lcd${cfg.subpixel.lcdfilter}
-
@@ -177,6 +165,13 @@ let
'';
+ # Replace default linked config with a different variant
+ replaceDefaultConfig = defaultConfig: newConfig: ''
+ rm $dst/${defaultConfig}
+ ln -s ${pkg.out}/share/fontconfig/conf.avail/${newConfig} \
+ dst/
+ '';
+
# fontconfig configuration package
confPkg = pkgs.runCommand "fontconfig-conf" {
preferLocalBuild = true;
@@ -196,6 +191,26 @@ let
ln -s ${pkg.out}/etc/fonts/conf.d/*.conf \
$dst/
+ ${optionalString (!cfg.antialias)
+ (replaceDefaultConfig "10-yes-antialias.conf"
+ "10-no-antialias.conf")
+ }
+
+ ${optionalString (cfg.hinting.style != "slight")
+ (replaceDefaultConfig "10-hinting-slight.conf"
+ "10-hinting-${cfg.hinting.style}.conf")
+ }
+
+ ${optionalString (cfg.subpixel.rgba != "none")
+ (replaceDefaultConfig "10-sub-pixel-none.conf"
+ "10-sub-pixel-${cfg.subpixel.rgba}.conf")
+ }
+
+ ${optionalString (cfg.subpixel.lcdfilter != "default")
+ (replaceDefaultConfig "11-lcdfilter-default.conf"
+ "11-lcdfilter-${cfg.subpixel.lcdfilter}.conf")
+ }
+
# 00-nixos-cache.conf
ln -s ${cacheConf} $dst/00-nixos-cache.conf
@@ -367,17 +382,25 @@ in
};
style = mkOption {
- type = types.enum [ "hintnone" "hintslight" "hintmedium" "hintfull" ];
- default = "hintslight";
+ type = types.enum ["none" "slight" "medium" "full"];
+ default = "slight";
description = lib.mdDoc ''
Hintstyle is the amount of font reshaping done to line up
to the grid.
- hintslight will make the font more fuzzy to line up to the grid
- but will be better in retaining font shape, while hintfull will
- be a crisp font that aligns well to the pixel grid but will lose
- a greater amount of font shape.
+ slight will make the font more fuzzy to line up to the grid but
+ will be better in retaining font shape, while full will be a
+ crisp font that aligns well to the pixel grid but will lose a
+ greater amount of font shape.
'';
+ apply =
+ val:
+ let
+ from = "fonts.fontconfig.hinting.style";
+ val' = lib.removePrefix "hint" val;
+ warning = "The option `${from}` contains a deprecated value `${val}`. Use `${val'}` instead.";
+ in
+ lib.warnIf (lib.hasPrefix "hint" val) warning val';
};
};