From 7a78892c478be77fd53a9fdec25a4dac043e9560 Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Mon, 3 Apr 2017 08:22:03 -0500 Subject: [PATCH 1/4] nixos/fontconfig: disable autohint by default --- nixos/modules/config/fonts/fontconfig.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix index 4d3cc26365f..93c5f2df725 100644 --- a/nixos/modules/config/fonts/fontconfig.nix +++ b/nixos/modules/config/fonts/fontconfig.nix @@ -372,11 +372,11 @@ in autohint = mkOption { type = types.bool; - default = true; + default = false; description = '' - Enable the autohinter, which provides hinting for otherwise - un-hinted fonts. The results are usually lower quality than - correctly-hinted fonts. + Enable the autohinter in place of the default interpreter. + The results are usually lower quality than correctly-hinted + fonts, but better than unhinted fonts. ''; }; }; From 21c9190a5fd8387c90feff08198c47894c0a541d Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Mon, 3 Apr 2017 08:23:32 -0500 Subject: [PATCH 2/4] nixos/fontconfig: remove forceAutohint option --- nixos/modules/config/fonts/fontconfig.nix | 16 ---------------- nixos/modules/rename.nix | 1 + 2 files changed, 1 insertion(+), 16 deletions(-) diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix index 93c5f2df725..affb46c2ca0 100644 --- a/nixos/modules/config/fonts/fontconfig.nix +++ b/nixos/modules/config/fonts/fontconfig.nix @@ -104,13 +104,6 @@ let cfg = config.fonts.fontconfig; ''} - - - - ${fcBool cfg.forceAutohint} - - - ''; @@ -453,15 +446,6 @@ in description = ''Use embedded bitmaps in fonts like Calibri.''; }; - forceAutohint = mkOption { - type = types.bool; - default = false; - description = '' - Force use of the TrueType Autohinter. Useful for debugging or - free-software purists. - ''; - }; - renderMonoTTFAsBitmap = mkOption { type = types.bool; default = false; diff --git a/nixos/modules/rename.nix b/nixos/modules/rename.nix index 54433e20597..4cf48e1e2cb 100644 --- a/nixos/modules/rename.nix +++ b/nixos/modules/rename.nix @@ -202,5 +202,6 @@ with lib; (mkRemovedOptionModule [ "fonts" "fontconfig" "hinting" "style" ] "") (mkRemovedOptionModule [ "services" "xserver" "displayManager" "sddm" "themes" ] "Set the option `services.xserver.displayManager.sddm.package' instead.") + (mkRemovedOptionModule [ "fonts" "fontconfig" "forceAutohint" ] "") ]; } From 03942659ca1189ba50f9f1b86bbe6d925eba237b Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Mon, 3 Apr 2017 08:24:32 -0500 Subject: [PATCH 3/4] nixos/fontconfig: remove renderMonoTTFAsBitmap --- nixos/modules/config/fonts/fontconfig.nix | 13 ------------- nixos/modules/rename.nix | 1 + 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix index affb46c2ca0..1cf5cb6e039 100644 --- a/nixos/modules/config/fonts/fontconfig.nix +++ b/nixos/modules/config/fonts/fontconfig.nix @@ -167,13 +167,6 @@ let cfg = config.fonts.fontconfig; - - - - ${fcBool cfg.renderMonoTTFAsBitmap} - - - ''; @@ -446,12 +439,6 @@ in description = ''Use embedded bitmaps in fonts like Calibri.''; }; - renderMonoTTFAsBitmap = mkOption { - type = types.bool; - default = false; - description = ''Render some monospace TTF fonts as bitmaps.''; - }; - }; }; diff --git a/nixos/modules/rename.nix b/nixos/modules/rename.nix index 4cf48e1e2cb..0174fe544e3 100644 --- a/nixos/modules/rename.nix +++ b/nixos/modules/rename.nix @@ -203,5 +203,6 @@ with lib; (mkRemovedOptionModule [ "services" "xserver" "displayManager" "sddm" "themes" ] "Set the option `services.xserver.displayManager.sddm.package' instead.") (mkRemovedOptionModule [ "fonts" "fontconfig" "forceAutohint" ] "") + (mkRemovedOptionModule [ "fonts" "fontconfig" "renderMonoTTFAsBitmap" ] "") ]; } From 89bfa112cfd8a8b3da642169d33f1dfe3ea1e839 Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Mon, 3 Apr 2017 08:48:50 -0500 Subject: [PATCH 4/4] fontconfig-penultimate: 0.2.1 -> 0.3.2 --- .../config/fonts/fontconfig-penultimate.nix | 221 +++++++++++++++++- nixos/modules/config/fonts/fontconfig.nix | 15 +- .../fonts/fontconfig-penultimate/default.nix | 4 +- 3 files changed, 228 insertions(+), 12 deletions(-) diff --git a/nixos/modules/config/fonts/fontconfig-penultimate.nix b/nixos/modules/config/fonts/fontconfig-penultimate.nix index 8e41d342117..83d6532774e 100644 --- a/nixos/modules/config/fonts/fontconfig-penultimate.nix +++ b/nixos/modules/config/fonts/fontconfig-penultimate.nix @@ -3,23 +3,236 @@ with lib; let - cfg = config.fonts.fontconfig.penultimate; + cfg = config.fonts.fontconfig; + fcBool = x: "" + (if x then "true" else "false") + ""; + + # back-supported fontconfig version and package + # version is used for font cache generation + supportVersion = "210"; + supportPkg = pkgs."fontconfig_${supportVersion}"; + + # latest fontconfig version and package + # version is used for configuration folder name, /etc/fonts/VERSION/ + # note: format differs from supportVersion and can not be used with makeCacheConf latestVersion = pkgs.fontconfig.configVersion; + latestPkg = pkgs.fontconfig; + + # supported version fonts.conf + supportFontsConf = pkgs.makeFontsConf { fontconfig = supportPkg; fontDirectories = config.fonts.fonts; }; + + # configuration file to read fontconfig cache + # version dependent + # priority 0 + cacheConfSupport = makeCacheConf { version = supportVersion; }; + cacheConfLatest = makeCacheConf {}; + + # generate the font cache setting file for a fontconfig version + # use latest when no version is passed + makeCacheConf = { version ? null }: + let + fcPackage = if builtins.isNull version + then "fontconfig" + else "fontconfig_${version}"; + makeCache = fontconfig: pkgs.makeFontsCache { inherit fontconfig; fontDirectories = config.fonts.fonts; }; + cache = makeCache pkgs."${fcPackage}"; + cache32 = makeCache pkgs.pkgsi686Linux."${fcPackage}"; + in + pkgs.writeText "fc-00-nixos-cache.conf" '' + + + + + ${concatStringsSep "\n" (map (font: "${font}") config.fonts.fonts)} + + ${cache} + ${optionalString (pkgs.stdenv.isx86_64 && cfg.cache32Bit) '' + ${cache32} + ''} + + ''; # The configuration to be included in /etc/font/ - confPkg = pkgs.runCommand "font-penultimate-conf" {} '' + penultimateConf = pkgs.runCommand "font-penultimate-conf" {} '' support_folder=$out/etc/fonts/conf.d latest_folder=$out/etc/fonts/${latestVersion}/conf.d mkdir -p $support_folder mkdir -p $latest_folder - # fontconfig ultimate various configuration files + ln -s ${supportFontsConf} $support_folder/../fonts.conf + ln -s ${latestPkg.out}/etc/fonts/fonts.conf \ + $latest_folder/../fonts.conf + + # fontconfig-penultimate various configuration files ln -s ${pkgs.fontconfig-penultimate}/etc/fonts/conf.d/*.conf \ $support_folder ln -s ${pkgs.fontconfig-penultimate}/etc/fonts/conf.d/*.conf \ $latest_folder + + ln -s ${cacheConfSupport} $support_folder/00-nixos-cache.conf + ln -s ${cacheConfLatest} $latest_folder/00-nixos-cache.conf + + rm $support_folder/10-antialias.conf $latest_folder/10-antialias.conf + ln -s ${antialiasConf} $support_folder/10-antialias.conf + ln -s ${antialiasConf} $latest_folder/10-antialias.conf + + rm $support_folder/10-hinting.conf $latest_folder/10-hinting.conf + ln -s ${hintingConf} $support_folder/10-hinting.conf + ln -s ${hintingConf} $latest_folder/10-hinting.conf + + ${optionalString cfg.useEmbeddedBitmaps '' + rm $support_folder/10-no-embedded-bitmaps.conf + rm $latest_folder/10-no-embedded-bitmaps.conf + ''} + + rm $support_folder/10-subpixel.conf $latest_folder/10-subpixel.conf + ln -s ${subpixelConf} $support_folder/10-subpixel.conf + ln -s ${subpixelConf} $latest_folder/10-subpixel.conf + + ${optionalString (cfg.dpi != 0) '' + ln -s ${dpiConf} $support_folder/11-dpi.conf + ln -s ${dpiConf} $latest_folder/11-dpi.conf + ''} + + ${optionalString (!cfg.includeUserConf) '' + rm $support_folder/50-user.conf + rm $latest_folder/50-user.conf + ''} + + # 51-local.conf + rm $latest_folder/51-local.conf + substitute \ + ${pkgs.fontconfig-penultimate}/etc/fonts/conf.d/51-local.conf \ + $latest_folder/51-local.conf \ + --replace local.conf /etc/fonts/${latestVersion}/local.conf + + ln -s ${defaultFontsConf} $support_folder/52-default-fonts.conf + ln -s ${defaultFontsConf} $latest_folder/52-default-fonts.conf + + ${optionalString cfg.allowBitmaps '' + rm $support_folder/53-no-bitmaps.conf + rm $latest_folder/53-no-bitmaps.conf + ''} + + ${optionalString (!cfg.allowType1) '' + ln -s ${rejectType1} $support_folder/53-no-type1.conf + ln -s ${rejectType1} $latest_folder/53-no-type1.conf + ''} + ''; + + hintingConf = pkgs.writeText "fc-10-hinting.conf" '' + + + + + + + + ${fcBool cfg.hinting.enable} + + + ${fcBool cfg.hinting.autohint} + + + hintslight + + + + + ''; + + antialiasConf = pkgs.writeText "fc-10-antialias.conf" '' + + + + + + + + ${fcBool cfg.antialias} + + + + + ''; + + subpixelConf = pkgs.writeText "fc-10-subpixel.conf" '' + + + + + + + + ${cfg.subpixel.rgba} + + + lcd${cfg.subpixel.lcdfilter} + + + + + ''; + + dpiConf = pkgs.writeText "fc-11-dpi.conf" '' + + + + + + + ${toString cfg.dpi} + + + + + ''; + + defaultFontsConf = + let genDefault = fonts: name: + optionalString (fonts != []) '' + + ${name} + + ${concatStringsSep "" + (map (font: '' + ${font} + '') fonts)} + + + ''; + in + pkgs.writeText "fc-52-nixos-default-fonts.conf" '' + + + + + + ${genDefault cfg.defaultFonts.sansSerif "sans-serif"} + + ${genDefault cfg.defaultFonts.serif "serif"} + + ${genDefault cfg.defaultFonts.monospace "monospace"} + + + ''; + + rejectType1 = pkgs.writeText "fc-53-no-type1.conf" '' + + + + + + + + + Type 1 + + + + + ''; in @@ -50,7 +263,7 @@ in config = mkIf (config.fonts.fontconfig.enable && cfg.enable) { - fonts.fontconfig.confPackages = [ confPkg ]; + fonts.fontconfig.confPackages = [ penultimateConf ]; }; diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix index 1cf5cb6e039..d44b583447a 100644 --- a/nixos/modules/config/fonts/fontconfig.nix +++ b/nixos/modules/config/fonts/fontconfig.nix @@ -444,11 +444,14 @@ in }; }; - config = mkIf cfg.enable { - fonts.fontconfig.confPackages = [ confPkg ]; - - environment.systemPackages = [ pkgs.fontconfig ]; - environment.etc.fonts.source = "${fontconfigEtc}/etc/fonts/"; - }; + config = mkMerge [ + (mkIf cfg.enable { + environment.systemPackages = [ pkgs.fontconfig ]; + environment.etc.fonts.source = "${fontconfigEtc}/etc/fonts/"; + }) + (mkIf (cfg.enable && !cfg.penultimate.enable) { + fonts.fontconfig.confPackages = [ confPkg ]; + }) + ]; } diff --git a/pkgs/data/fonts/fontconfig-penultimate/default.nix b/pkgs/data/fonts/fontconfig-penultimate/default.nix index f9d60d6600d..a42e5d9109b 100644 --- a/pkgs/data/fonts/fontconfig-penultimate/default.nix +++ b/pkgs/data/fonts/fontconfig-penultimate/default.nix @@ -1,6 +1,6 @@ { stdenv, fetchFromGitHub }: -let version = "0.2.1"; in +let version = "0.3.2"; in stdenv.mkDerivation { name = "fontconfig-penultimate-${version}"; @@ -8,7 +8,7 @@ stdenv.mkDerivation { owner = "ttuegel"; repo = "fontconfig-penultimate"; rev = version; - sha256 = "14arpalmpn7ig2myxslk4jdg6lm0cnmwsxy7zl0j7yr417k1kprf"; + sha256 = "01cgqdmgpqahkg71lnvr3yzsmka9q1kgkbiz6w5ds1fhrpcswj7p"; }; installPhase = ''