From d75485c945f1424f8d69716c8519a4a7d62f22ad Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Sun, 30 Nov 2014 13:36:11 -0600 Subject: [PATCH 1/8] Add fontconfig-ultimate-20141123 --- .../libraries/fontconfig-ultimate/confd.nix | 33 +++ .../libraries/fontconfig-ultimate/default.nix | 6 + .../fontconfig-ultimate/rendering.nix | 212 ++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 4 files changed, 253 insertions(+) create mode 100644 pkgs/development/libraries/fontconfig-ultimate/confd.nix create mode 100644 pkgs/development/libraries/fontconfig-ultimate/default.nix create mode 100644 pkgs/development/libraries/fontconfig-ultimate/rendering.nix diff --git a/pkgs/development/libraries/fontconfig-ultimate/confd.nix b/pkgs/development/libraries/fontconfig-ultimate/confd.nix new file mode 100644 index 00000000000..ce734527162 --- /dev/null +++ b/pkgs/development/libraries/fontconfig-ultimate/confd.nix @@ -0,0 +1,33 @@ +{ stdenv, fetchurl }: + +stdenv.mkDerivation { + name = "fontconfig-ultimate-20141123"; + src = fetchurl { + url = "https://github.com/bohoomil/fontconfig-ultimate/archive/2014-11-23.tar.gz"; + sha256 = "0czfm3hxc41x5mscwrba7p1vhm2w62j1qg7z8kfdrf21z8fvgznw"; + }; + + phases = "$prePhases unpackPhase installPhase $postPhases"; + installPhase = '' + mkdir -p $out/etc/fonts/conf.d + cp conf.d.infinality/*.conf $out/etc/fonts/conf.d + + # Base rendering settings will be determined by NixOS module + rm $out/etc/fonts/conf.d/10-base-rendering.conf + + # Options controlled by NixOS module + rm $out/etc/fonts/conf.d/82-*.conf + rm $out/etc/fonts/conf.d/83-*.conf + + # Inclusion of local and user configs handled by global configuration + rm $out/etc/fonts/conf.d/97-local.conf + rm $out/etc/fonts/conf.d/98-user.conf + + cp fontconfig_patches/fonts-settings/*.conf $out/etc/fonts/conf.d + + mkdir -p $out/etc/fonts/presets/{combi,free,ms} + cp fontconfig_patches/combi/*.conf $out/etc/fonts/presets/combi + cp fontconfig_patches/free/*.conf $out/etc/fonts/presets/free + cp fontconfig_patches/ms/*.conf $out/etc/fonts/presets/ms + ''; +} diff --git a/pkgs/development/libraries/fontconfig-ultimate/default.nix b/pkgs/development/libraries/fontconfig-ultimate/default.nix new file mode 100644 index 00000000000..aa799d850d7 --- /dev/null +++ b/pkgs/development/libraries/fontconfig-ultimate/default.nix @@ -0,0 +1,6 @@ +{ callPackage }: + +{ + confd = callPackage ./confd.nix {}; + rendering = callPackage ./rendering.nix {}; +} diff --git a/pkgs/development/libraries/fontconfig-ultimate/rendering.nix b/pkgs/development/libraries/fontconfig-ultimate/rendering.nix new file mode 100644 index 00000000000..435716b8c8d --- /dev/null +++ b/pkgs/development/libraries/fontconfig-ultimate/rendering.nix @@ -0,0 +1,212 @@ +{}: + +rec { + default = { + INFINALITY_FT_FILTER_PARAMS="11 22 38 22 11"; + INFINALITY_FT_GRAYSCALE_FILTER_STRENGTH="0"; + INFINALITY_FT_FRINGE_FILTER_STRENGTH="0"; + INFINALITY_FT_AUTOHINT_HORIZONTAL_STEM_DARKEN_STRENGTH="10"; + INFINALITY_FT_AUTOHINT_VERTICAL_STEM_DARKEN_STRENGTH="25"; + INFINALITY_FT_WINDOWS_STYLE_SHARPENING_STRENGTH="10"; + INFINALITY_FT_CHROMEOS_STYLE_SHARPENING_STRENGTH="0"; + INFINALITY_FT_STEM_ALIGNMENT_STRENGTH="25"; + INFINALITY_FT_STEM_FITTING_STRENGTH="25"; + INFINALITY_FT_GAMMA_CORRECTION="0 100"; + INFINALITY_FT_BRIGHTNESS="0"; + INFINALITY_FT_CONTRAST="0"; + INFINALITY_FT_USE_VARIOUS_TWEAKS="true"; + INFINALITY_FT_AUTOHINT_INCREASE_GLYPH_HEIGHTS="true"; + INFINALITY_FT_AUTOHINT_SNAP_STEM_HEIGHT="100"; + INFINALITY_FT_STEM_SNAPPING_SLIDING_SCALE="40"; + INFINALITY_FT_USE_KNOWN_SETTINGS_ON_SELECTED_FONTS="true"; + INFINALITY_FT_GLOBAL_EMBOLDEN_X_VALUE="0"; + INFINALITY_FT_GLOBAL_EMBOLDEN_Y_VALUE="0"; + INFINALITY_FT_BOLD_EMBOLDEN_X_VALUE="0"; + INFINALITY_FT_BOLD_EMBOLDEN_Y_VALUE="0"; + }; + + osx = default // { + INFINALITY_FT_FILTER_PARAMS="03 32 38 32 03"; + INFINALITY_FT_GRAYSCALE_FILTER_STRENGTH="25"; + INFINALITY_FT_WINDOWS_STYLE_SHARPENING_STRENGTH="0"; + INFINALITY_FT_STEM_ALIGNMENT_STRENGTH="0"; + INFINALITY_FT_STEM_FITTING_STRENGTH="0"; + INFINALITY_FT_GAMMA_CORRECTION="1000 80"; + INFINALITY_FT_BRIGHTNESS="10"; + INFINALITY_FT_CONTRAST="20"; + INFINALITY_FT_USE_VARIOUS_TWEAKS="false"; + INFINALITY_FT_AUTOHINT_INCREASE_GLYPH_HEIGHTS="false"; + INFINALITY_FT_AUTOHINT_SNAP_STEM_HEIGHT="0"; + INFINALITY_FT_STEM_SNAPPING_SLIDING_SCALE="0"; + INFINALITY_FT_USE_KNOWN_SETTINGS_ON_SELECTED_FONTS="false"; + INFINALITY_FT_GLOBAL_EMBOLDEN_Y_VALUE="8"; + INFINALITY_FT_BOLD_EMBOLDEN_X_VALUE="16"; + }; + + ipad = default // { + INFINALITY_FT_FILTER_PARAMS="00 00 100 00 00"; + INFINALITY_FT_GRAYSCALE_FILTER_STRENGTH="100"; + INFINALITY_FT_AUTOHINT_HORIZONTAL_STEM_DARKEN_STRENGTH="0"; + INFINALITY_FT_AUTOHINT_VERTICAL_STEM_DARKEN_STRENGTH="0"; + INFINALITY_FT_WINDOWS_STYLE_SHARPENING_STRENGTH="0"; + INFINALITY_FT_STEM_ALIGNMENT_STRENGTH="0"; + INFINALITY_FT_STEM_FITTING_STRENGTH="0"; + INFINALITY_FT_GAMMA_CORRECTION="1000 80"; + INFINALITY_FT_USE_VARIOUS_TWEAKS="false"; + INFINALITY_FT_AUTOHINT_INCREASE_GLYPH_HEIGHTS="false"; + INFINALITY_FT_AUTOHINT_SNAP_STEM_HEIGHT="0"; + INFINALITY_FT_STEM_SNAPPING_SLIDING_SCALE="0"; + INFINALITY_FT_USE_KNOWN_SETTINGS_ON_SELECTED_FONTS="false"; + }; + + ubuntu = default // { + INFINALITY_FT_WINDOWS_STYLE_SHARPENING_STRENGTH="0"; + INFINALITY_FT_STEM_ALIGNMENT_STRENGTH="0"; + INFINALITY_FT_STEM_FITTING_STRENGTH="0"; + INFINALITY_FT_GAMMA_CORRECTION="1000 80"; + INFINALITY_FT_BRIGHTNESS="-10"; + INFINALITY_FT_CONTRAST="15"; + INFINALITY_FT_USE_VARIOUS_TWEAKS="false"; + INFINALITY_FT_AUTOHINT_INCREASE_GLYPH_HEIGHTS="false"; + INFINALITY_FT_AUTOHINT_SNAP_STEM_HEIGHT="0"; + INFINALITY_FT_STEM_SNAPPING_SLIDING_SCALE="0"; + INFINALITY_FT_USE_KNOWN_SETTINGS_ON_SELECTED_FONTS="false"; + }; + + linux = default // { + INFINALITY_FT_FILTER_PARAMS="06 25 44 25 06"; + INFINALITY_FT_WINDOWS_STYLE_SHARPENING_STRENGTH="0"; + INFINALITY_FT_STEM_ALIGNMENT_STRENGTH="0"; + INFINALITY_FT_STEM_FITTING_STRENGTH="0"; + INFINALITY_FT_AUTOHINT_INCREASE_GLYPH_HEIGHTS="false"; + INFINALITY_FT_AUTOHINT_SNAP_STEM_HEIGHT="100"; + INFINALITY_FT_USE_KNOWN_SETTINGS_ON_SELECTED_FONTS="false"; + }; + + winxplight = default // { + INFINALITY_FT_FILTER_PARAMS="06 25 44 25 06"; + INFINALITY_FT_FRINGE_FILTER_STRENGTH="100"; + INFINALITY_FT_WINDOWS_STYLE_SHARPENING_STRENGTH="65"; + INFINALITY_FT_STEM_ALIGNMENT_STRENGTH="15"; + INFINALITY_FT_STEM_FITTING_STRENGTH="15"; + INFINALITY_FT_GAMMA_CORRECTION="1000 120"; + INFINALITY_FT_BRIGHTNESS="20"; + INFINALITY_FT_CONTRAST="30"; + INFINALITY_FT_AUTOHINT_INCREASE_GLYPH_HEIGHTS="false"; + INFINALITY_FT_STEM_SNAPPING_SLIDING_SCALE="30"; + }; + + win7light = default // { + INFINALITY_FT_FILTER_PARAMS="20 25 38 25 05"; + INFINALITY_FT_FRINGE_FILTER_STRENGTH="100"; + INFINALITY_FT_WINDOWS_STYLE_SHARPENING_STRENGTH="100"; + INFINALITY_FT_STEM_ALIGNMENT_STRENGTH="0"; + INFINALITY_FT_STEM_FITTING_STRENGTH="0"; + INFINALITY_FT_GAMMA_CORRECTION="1000 160"; + INFINALITY_FT_CONTRAST="20"; + INFINALITY_FT_AUTOHINT_INCREASE_GLYPH_HEIGHTS="false"; + INFINALITY_FT_STEM_SNAPPING_SLIDING_SCALE="30"; + }; + + winxp = default // { + INFINALITY_FT_FILTER_PARAMS="06 25 44 25 06"; + INFINALITY_FT_FRINGE_FILTER_STRENGTH="100"; + INFINALITY_FT_WINDOWS_STYLE_SHARPENING_STRENGTH="65"; + INFINALITY_FT_STEM_ALIGNMENT_STRENGTH="15"; + INFINALITY_FT_STEM_FITTING_STRENGTH="15"; + INFINALITY_FT_GAMMA_CORRECTION="1000 120"; + INFINALITY_FT_BRIGHTNESS="10"; + INFINALITY_FT_CONTRAST="20"; + INFINALITY_FT_AUTOHINT_INCREASE_GLYPH_HEIGHTS="false"; + INFINALITY_FT_STEM_SNAPPING_SLIDING_SCALE="30"; + }; + + win7 = default // { + INFINALITY_FT_FILTER_PARAMS="20 25 42 25 06"; + INFINALITY_FT_FRINGE_FILTER_STRENGTH="100"; + INFINALITY_FT_WINDOWS_STYLE_SHARPENING_STRENGTH="65"; + INFINALITY_FT_STEM_ALIGNMENT_STRENGTH="0"; + INFINALITY_FT_STEM_FITTING_STRENGTH="0"; + INFINALITY_FT_GAMMA_CORRECTION="1000 120"; + INFINALITY_FT_BRIGHTNESS="10"; + INFINALITY_FT_CONTRAST="20"; + INFINALITY_FT_AUTOHINT_INCREASE_GLYPH_HEIGHTS="false"; + INFINALITY_FT_STEM_SNAPPING_SLIDING_SCALE="0"; + }; + + vanilla = default // { + INFINALITY_FT_FILTER_PARAMS="06 25 38 25 06"; + INFINALITY_FT_AUTOHINT_HORIZONTAL_STEM_DARKEN_STRENGTH="0"; + INFINALITY_FT_AUTOHINT_VERTICAL_STEM_DARKEN_STRENGTH="0"; + INFINALITY_FT_WINDOWS_STYLE_SHARPENING_STRENGTH="0"; + INFINALITY_FT_STEM_ALIGNMENT_STRENGTH="0"; + INFINALITY_FT_STEM_FITTING_STRENGTH="0"; + INFINALITY_FT_USE_VARIOUS_TWEAKS="false"; + INFINALITY_FT_AUTOHINT_INCREASE_GLYPH_HEIGHTS="false"; + INFINALITY_FT_AUTOHINT_SNAP_STEM_HEIGHT="0"; + INFINALITY_FT_STEM_SNAPPING_SLIDING_SCALE="0"; + INFINALITY_FT_USE_KNOWN_SETTINGS_ON_SELECTED_FONTS="false"; + }; + + classic = default // { + INFINALITY_FT_FILTER_PARAMS="06 25 38 25 06"; + INFINALITY_FT_AUTOHINT_HORIZONTAL_STEM_DARKEN_STRENGTH="0"; + INFINALITY_FT_AUTOHINT_VERTICAL_STEM_DARKEN_STRENGTH="0"; + INFINALITY_FT_WINDOWS_STYLE_SHARPENING_STRENGTH="0"; + INFINALITY_FT_STEM_ALIGNMENT_STRENGTH="0"; + INFINALITY_FT_STEM_FITTING_STRENGTH="0"; + INFINALITY_FT_STEM_SNAPPING_SLIDING_SCALE="0"; + INFINALITY_FT_USE_KNOWN_SETTINGS_ON_SELECTED_FONTS="false"; + }; + + nudge = default // { + INFINALITY_FT_WINDOWS_STYLE_SHARPENING_STRENGTH="0"; + INFINALITY_FT_STEM_SNAPPING_SLIDING_SCALE="30"; + INFINALITY_FT_USE_KNOWN_SETTINGS_ON_SELECTED_FONTS="false"; + }; + + push = default // { + INFINALITY_FT_WINDOWS_STYLE_SHARPENING_STRENGTH="0"; + INFINALITY_FT_STEM_ALIGNMENT_STRENGTH="75"; + INFINALITY_FT_STEM_FITTING_STRENGTH="50"; + INFINALITY_FT_STEM_SNAPPING_SLIDING_SCALE="30"; + }; + + infinality = default // { + INFINALITY_FT_WINDOWS_STYLE_SHARPENING_STRENGTH="5"; + }; + + shove = default // { + INFINALITY_FT_WINDOWS_STYLE_SHARPENING_STRENGTH="0"; + INFINALITY_FT_STEM_ALIGNMENT_STRENGTH="100"; + INFINALITY_FT_STEM_FITTING_STRENGTH="100"; + INFINALITY_FT_STEM_SNAPPING_SLIDING_SCALE="0"; + }; + + sharpened = default // { + INFINALITY_FT_WINDOWS_STYLE_SHARPENING_STRENGTH="65"; + }; + + ultimate = { + INFINALITY_FT_FILTER_PARAMS="08 24 36 24 08"; + INFINALITY_FT_FRINGE_FILTER_STRENGTH="50"; + INFINALITY_FT_USE_VARIOUS_TWEAKS="true"; + INFINALITY_FT_CHROMEOS_STYLE_SHARPENING_STRENGTH="20"; + }; + + ultimate-lighter = ultimate // { + INFINALITY_FT_FILTER_PARAMS="06 22 36 22 06"; + }; + + ultimate-lightest = ultimate // { + INFINALITY_FT_FILTER_PARAMS="06 22 36 22 06"; + }; + + ultimate-darker = ultimate // { + INFINALITY_FT_FILTER_PARAMS="10 25 37 25 10"; + }; + + ultimate-darkest = ultimate // { + INFINALITY_FT_FILTER_PARAMS="12 28 42 28 12"; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 15a3e9fcd2c..4fd5b9dc3e0 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -5168,6 +5168,8 @@ let fontconfig = callPackage ../development/libraries/fontconfig { }; + fontconfig-ultimate = callPackage ../development/libraries/fontconfig-ultimate {}; + folly = callPackage ../development/libraries/folly { }; makeFontsConf = let fontconfig_ = fontconfig; in {fontconfig ? fontconfig_, fontDirectories}: From 1df1305a8a313120219e70ed1f50618b1047963d Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Sun, 30 Nov 2014 13:36:49 -0600 Subject: [PATCH 2/8] Rewrite Fontconfig NixOS module Details: * The option `fonts.enableFontConfig` has (finally) been renamed `fonts.fontconfig.enable`. * Configurations are loaded in this order: first the Fontconfig-upstream configuration is loaded, then the NixOS-specific font directories are set, the system-wide default configuration is loaded, and finally the user configuration is loaded (if enabled). * The NixOS options `fonts.fontconfig.defaultFonts.monospace`, `fonts.fontconfig.defaultFonts.sansSerif` and `fonts.fontconfig.defaultFonts.serif` are added to allow setting the default system-wide font used for these generic faces. The defaults are the appropriate faces from the DejaVu collection because of their comprehensive Unicode coverage, clean rendering, and excellent legibility. * The NixOS option `fonts.fontconfig.antialias` can be used to disable antialiasing (it is enabled by default). * The options `fonts.fontconfig.subpixel.rgba` and `fonts.fontconfig.subpixel.lcdfilter` control the system-wide default settings for subpixel order and LCD filtering algorithm, respectively. * `fonts.fontconfig.hinting.enable` can be used to disable TrueType font hinting (it is enabled by default). `fonts.fontconfig.hinting.autohint` controls the FreeType autohinter. `fonts.fontconfig.hinting.style` controls the hint style; it is "full" by default. * User configurations can be disabled system-wide by setting `fonts.fontconfig.includeUserConf = false`. They are enabled by default so users can set Fontconfig options in the desktop environment of their choice. --- nixos/modules/config/fonts/fontconfig.nix | 327 ++++++++++++++++++---- nixos/modules/config/no-x-libs.nix | 2 +- nixos/modules/rename.nix | 1 + 3 files changed, 280 insertions(+), 50 deletions(-) diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix index 4b6f9325fda..ca8313e017b 100644 --- a/nixos/modules/config/fonts/fontconfig.nix +++ b/nixos/modules/config/fonts/fontconfig.nix @@ -8,72 +8,301 @@ with lib; fonts = { - enableFontConfig = mkOption { # !!! should be enableFontconfig - type = types.bool; - default = true; - description = '' - If enabled, a Fontconfig configuration file will be built - pointing to a set of default fonts. If you don't care about - running X11 applications or any other program that uses - Fontconfig, you can turn this option off and prevent a - dependency on all those fonts. - ''; + fontconfig = { + enable = mkOption { + type = types.bool; + default = true; + description = '' + If enabled, a Fontconfig configuration file will be built + pointing to a set of default fonts. If you don't care about + running X11 applications or any other program that uses + Fontconfig, you can turn this option off and prevent a + dependency on all those fonts. + ''; + }; + + antialias = mkOption { + type = types.bool; + default = true; + description = "Enable font antialiasing."; + }; + + dpi = mkOption { + type = types.int; + default = 0; + description = '' + Force DPI setting. Setting to 0 disables DPI + forcing; the DPI detected for the display will be used. + ''; + }; + + defaultFonts = { + monospace = mkOption { + type = types.str; + default = "DejaVu Sans Mono"; + description = '' + System-wide default monospace font. The default is not set if the + option is set to "". + ''; + }; + + sansSerif = mkOption { + type = types.str; + default = "DejaVu Sans"; + description = '' + System-wide default sans serif font. The default is not set if the + option is set to "". + ''; + }; + + serif = mkOption { + type = types.str; + default = "DejaVu Serif"; + description = '' + System-wide default serif font. The default is not set if the + option is set to "". + ''; + }; + }; + + hinting = { + enable = mkOption { + type = types.bool; + default = true; + description = "Enable TrueType hinting."; + }; + + autohint = mkOption { + type = types.bool; + default = true; + description = '' + Enable the autohinter, which provides hinting for otherwise + un-hinted fonts. The results are usually lower quality than + correctly-hinted fonts. + ''; + }; + + style = mkOption { + type = types.str // { + check = flip elem ["none" "slight" "medium" "full"]; + }; + default = "full"; + description = '' + TrueType hinting style, one of none, + slight, medium, or + full. + ''; + }; + }; + + includeUserConf = mkOption { + type = types.bool; + default = true; + description = '' + Include the user configuration from + ~/.config/fontconfig/fonts.conf or + ~/.config/fontconfig/conf.d. + ''; + }; + + subpixel = { + + rgba = mkOption { + type = types.string // { + check = flip elem ["rgb" "bgr" "vrgb" "vbgr" "none"]; + }; + default = "rgb"; + description = '' + Subpixel order, one of none, + rgb, bgr, + vrgb, or vbgr. + ''; + }; + + lcdfilter = mkOption { + type = types.str // { + check = flip elem ["none" "default" "light" "legacy"]; + }; + default = "default"; + description = '' + FreeType LCD filter, one of none, + default, light, or + legacy. + ''; + }; + + }; + }; }; }; + config = + let fontconfig = config.fonts.fontconfig; + fcBool = x: "" + (if x then "true" else "false") + ""; + in mkIf fontconfig.enable { - config = mkIf config.fonts.enableFontConfig { + # Fontconfig 2.10 backward compatibility - # Fontconfig 2.10 backward compatibility + # Bring in the default (upstream) fontconfig configuration, only for fontconfig 2.10 + environment.etc."fonts/fonts.conf".source = + pkgs.makeFontsConf { fontconfig = pkgs.fontconfig_210; fontDirectories = config.fonts.fonts; }; - # Bring in the default (upstream) fontconfig configuration, only for fontconfig 2.10 - environment.etc."fonts/fonts.conf".source = - pkgs.makeFontsConf { fontconfig = pkgs.fontconfig_210; fontDirectories = config.fonts.fonts; }; + environment.etc."fonts/conf.d/98-nixos.conf".text = + '' + + + - environment.etc."fonts/conf.d/00-nixos.conf".text = - '' - - - + + + + ${fcBool fontconfig.hinting.enable} + + + ${fcBool fontconfig.hinting.autohint} + + + hint${fontconfig.hinting.style} + + + ${fcBool fontconfig.antialias} + + + ${fontconfig.subpixel.rgba} + + + lcd${fontconfig.subpixel.lcdfilter} + + - - - - hintslight - - + + ${optionalString (fontconfig.defaultFonts.sansSerif != "") '' + + sans-serif + + ${fontconfig.defaultFonts.sansSerif} + + + ''} + ${optionalString (fontconfig.defaultFonts.serif != "") '' + + serif + + ${fontconfig.defaultFonts.serif} + + + ''} + ${optionalString (fontconfig.defaultFonts.monospace != "") '' + + monospace + + ${fontconfig.defaultFonts.monospace} + + + ''} - - ''; + ${optionalString (fontconfig.dpi != 0) '' + + + ${fontconfig.dpi} + + + ''} - # Versioned fontconfig > 2.10. Take shared fonts.conf from fontconfig. - # Otherwise specify only font directories. - environment.etc."fonts/${pkgs.fontconfig.configVersion}/fonts.conf".source = - "${pkgs.fontconfig}/etc/fonts/fonts.conf"; - environment.etc."fonts/${pkgs.fontconfig.configVersion}/conf.d/00-nixos.conf".text = - '' - - - + + ''; - - - - hintslight - - + # Versioned fontconfig > 2.10. Take shared fonts.conf from fontconfig. + # Otherwise specify only font directories. + environment.etc."fonts/${pkgs.fontconfig.configVersion}/fonts.conf".source = + "${pkgs.fontconfig}/etc/fonts/fonts.conf"; - - ${concatStringsSep "\n" (map (font: "${font}") config.fonts.fonts)} + environment.etc."fonts/${pkgs.fontconfig.configVersion}/conf.d/00-nixos.conf".text = + '' + + + + + ${concatStringsSep "\n" (map (font: "${font}") config.fonts.fonts)} + + ''; - - ''; + environment.etc."fonts/${pkgs.fontconfig.configVersion}/conf.d/98-nixos.conf".text = + '' + + + - environment.systemPackages = [ pkgs.fontconfig ]; + + + + ${fcBool fontconfig.hinting.enable} + + + ${fcBool fontconfig.hinting.autohint} + + + hint${fontconfig.hinting.style} + + + ${fcBool fontconfig.antialias} + + + ${fontconfig.subpixel.rgba} + + + lcd${fontconfig.subpixel.lcdfilter} + + - }; + + + sans-serif + + ${fontconfig.defaultFonts.sansSerif} + + + + serif + + ${fontconfig.defaultFonts.serif} + + + + monospace + + ${fontconfig.defaultFonts.monospace} + + + + ${optionalString (fontconfig.dpi != 0) '' + + + ${fontconfig.dpi} + + + ''} + + + ''; + + environment.etc."fonts/${pkgs.fontconfig.configVersion}/conf.d/99-user.conf" = { + enable = fontconfig.includeUserConf; + text = '' + + + + fontconfig/conf.d + fontconfig/fonts.conf + + ''; + }; + + environment.systemPackages = [ pkgs.fontconfig ]; + + }; } diff --git a/nixos/modules/config/no-x-libs.nix b/nixos/modules/config/no-x-libs.nix index f91dbb4cc28..47393c9d3f5 100644 --- a/nixos/modules/config/no-x-libs.nix +++ b/nixos/modules/config/no-x-libs.nix @@ -24,7 +24,7 @@ with lib; programs.ssh.setXAuthLocation = false; security.pam.services.su.forwardXAuth = lib.mkForce false; - fonts.enableFontConfig = false; + fonts.fontconfig.enable = false; nixpkgs.config.packageOverrides = pkgs: { dbus = pkgs.dbus.override { useX11 = false; }; }; diff --git a/nixos/modules/rename.nix b/nixos/modules/rename.nix index b29a3d0354c..cb1b92e78d6 100644 --- a/nixos/modules/rename.nix +++ b/nixos/modules/rename.nix @@ -74,6 +74,7 @@ in zipModules ([] ++ obsolete [ "environment" "x11Packages" ] [ "environment" "systemPackages" ] ++ obsolete [ "environment" "enableBashCompletion" ] [ "programs" "bash" "enableCompletion" ] ++ obsolete [ "environment" "nix" ] [ "nix" "package" ] +++ obsolete [ "fonts" "enableFontConfig" ] [ "fonts" "fontconfig" "enable" ] ++ obsolete [ "fonts" "extraFonts" ] [ "fonts" "fonts" ] ++ obsolete [ "security" "extraSetuidPrograms" ] [ "security" "setuidPrograms" ] From 8991ff7ceb1019751b00d97bd343ad6797177101 Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Sun, 30 Nov 2014 13:49:19 -0600 Subject: [PATCH 3/8] Load default Fontconfig settings into Xresources for Xft --- .../services/x11/display-managers/default.nix | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nixos/modules/services/x11/display-managers/default.nix b/nixos/modules/services/x11/display-managers/default.nix index 6b01cde9e2b..8bc8175f88f 100644 --- a/nixos/modules/services/x11/display-managers/default.nix +++ b/nixos/modules/services/x11/display-managers/default.nix @@ -23,6 +23,17 @@ let pathsToLink = [ "/" ]; }; + fontconfig = config.fonts.fontconfig; + xresourcesXft = pkgs.writeText "Xresources-Xft" '' + ${optionalString (fontconfig.dpi != 0) ''Xft.dpi: ${fontconfig.dpi}''} + Xft.antialias: ${if fontconfig.antialias then "1" else "0"} + Xft.rgba: ${fontconfig.subpixel.rgba} + Xft.lcdfilter: lcd${fontconfig.subpixel.lcdfilter} + Xft.hinting: ${if fontconfig.hinting.enable then "1" else "0"} + Xft.autohint: ${if fontconfig.hinting.autohint then "1" else "0"} + Xft.hintstyle: hint${fontconfig.hinting.style} + ''; + # file provided by services.xserver.displayManager.session.script xsession = wm: dm: pkgs.writeScript "xsession" '' @@ -79,6 +90,7 @@ let ''} # Load X defaults. + ${xorg.xrdb}/bin/xrdb -merge ${xresourcesXft} if test -e ~/.Xresources; then ${xorg.xrdb}/bin/xrdb -merge ~/.Xresources elif test -e ~/.Xdefaults; then From c00c563c666465e4adea1c867b82e77b65f4c112 Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Sun, 30 Nov 2014 13:49:34 -0600 Subject: [PATCH 4/8] Add NixOS module for fontconfig-ultimate Details: * The option `fonts.fontconfig.ultimate.enable` can be used to disable the fontconfig-ultimate configuration. * The user-configurable options provided by fontconfig-ultimate are exposed in the NixOS module: `allowBitmaps` (default: true), `allowType1` (default: false), `useEmbeddedBitmaps` (default: false), `forceAutohint` (default: false), `renderMonoTTFAsBitmap` (default: false). * Upstream provides three substitution modes for substituting TrueType fonts for Type 1 fonts (which do not render well). The default, "free", substitutes free fonts for Type 1 fonts. The option "ms" substitutions Microsoft fonts for Type 1 fonts. The option "combi" uses a combination of Microsoft and free fonts. Substitutions can also be disabled. * All 21 of the Infinality rendering modes supported by fontconfig-ultimate or by the original Infinality distribution can be selected through `fonts.fontconfig.ultimate.rendering`. The default is the medium style provided by fontconfig-ultimate. Any of the modes may be customized, or Infinality rendering can be disabled entirely. --- .../config/fonts/fontconfig-ultimate.nix | 193 ++++++++++++++++++ nixos/modules/module-list.nix | 1 + 2 files changed, 194 insertions(+) create mode 100644 nixos/modules/config/fonts/fontconfig-ultimate.nix diff --git a/nixos/modules/config/fonts/fontconfig-ultimate.nix b/nixos/modules/config/fonts/fontconfig-ultimate.nix new file mode 100644 index 00000000000..408d49053dd --- /dev/null +++ b/nixos/modules/config/fonts/fontconfig-ultimate.nix @@ -0,0 +1,193 @@ +{ config, pkgs, ... }: + +with pkgs.lib; + +let fcBool = x: if x then "true" else "false"; +in +{ + + options = { + + fonts = { + + fontconfig = { + + ultimate = { + enable = mkOption { + type = types.bool; + default = true; + description = '' + Enable fontconfig-ultimate settings (formerly known as + Infinality). Besides the customizable settings in this NixOS + module, fontconfig-ultimate also provides many font-specific + rendering tweaks. + ''; + }; + + allowBitmaps = mkOption { + type = types.bool; + default = true; + description = '' + Allow bitmap fonts. Set to false to ban all + bitmap fonts. + ''; + }; + + allowType1 = mkOption { + type = types.bool; + default = false; + description = '' + Allow Type-1 fonts. Default is false because of + poor rendering. + ''; + }; + + useEmbeddedBitmaps = mkOption { + type = types.bool; + default = false; + 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; + description = ''Render some monospace TTF fonts as bitmaps.''; + }; + + substitutions = mkOption { + type = types.str // { + check = flip elem ["none" "free" "combi" "ms"]; + }; + default = "free"; + description = '' + Font substitutions to replace common Type 1 fonts with nicer + TrueType fonts. free uses free fonts, + ms uses Microsoft fonts, + combi uses a combination, and + none disables the substitutions. + ''; + }; + + rendering = mkOption { + type = types.attrs; + default = pkgs.fontconfig-ultimate.rendering.ultimate; + description = '' + FreeType rendering settings presets. The default is + pkgs.fontconfig-ultimate.rendering.ultimate. + The other available styles are: + ultimate-lighter, + ultimate-darker, + ultimate-lightest, + ultimate-darkest, + default (the original Infinality default), + osx, + ipad, + ubuntu, + linux, + winxplight, + win7light, + winxp, + win7, + vanilla, + classic, + nudge, + push, + shove, + sharpened, + infinality. Any of the presets may be + customized by editing the attributes. To disable, set this option + to the empty attribute set {}. + ''; + }; + }; + }; + }; + + }; + + + config = + let ultimate = config.fonts.fontconfig.ultimate; + fontconfigUltimateConf = '' + + + + + ${optionalString ultimate.allowBitmaps '' + + + + + false + + + + ''} + + ${optionalString ultimate.allowType1 '' + + + + + + Type 1 + + + + + ''} + + + + + ${fcBool ultimate.useEmbeddedBitmaps} + + + + + + + ${fcBool ultimate.forceAutohint} + + + + + + + ${fcBool ultimate.renderMonoTTFAsBitmap} + + + + ${optionalString (ultimate.substitutions != "none") '' + + ${pkgs.fontconfig-ultimate.confd}/etc/fonts/presets/${ultimate.substitutions} + ''} + + ${pkgs.fontconfig-ultimate.confd}/etc/fonts/conf.d + + + ''; + in mkIf (config.fonts.fontconfig.enable && ultimate.enable) { + + environment.etc."fonts/conf.d/52-fontconfig-ultimate.conf" = { + text = fontconfigUltimateConf; + }; + + environment.etc."fonts/${pkgs.fontconfig.configVersion}/conf.d/52-fontconfig-ultimate.conf" = { + text = fontconfigUltimateConf; + }; + + environment.variables = ultimate.rendering; + + }; + +} diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 177eb6d0e19..36e56a1d152 100755 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -1,6 +1,7 @@ [ ./config/fonts/corefonts.nix ./config/fonts/fontconfig.nix + ./config/fonts/fontconfig-ultimate.nix ./config/fonts/fontdir.nix ./config/fonts/fonts.nix ./config/fonts/ghostscript.nix From 57ba2093bf88720bc3bc3a8e3ac65260404df714 Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Sun, 30 Nov 2014 14:00:33 -0600 Subject: [PATCH 5/8] Replace Bitstream Vera fonts by DejaVu in defaults The default configuration installed the Bitstream Vera fonts, but DejaVu is a superior replacement, and the default Fontconfig settings need it now for the generic faces monospace, sans-serif, and serif. --- nixos/modules/config/fonts/fonts.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/modules/config/fonts/fonts.nix b/nixos/modules/config/fonts/fonts.nix index baf5b7713f5..a3fa4bd9778 100644 --- a/nixos/modules/config/fonts/fonts.nix +++ b/nixos/modules/config/fonts/fonts.nix @@ -25,7 +25,7 @@ with lib; [ pkgs.xorg.fontbhttf pkgs.xorg.fontbhlucidatypewriter100dpi pkgs.xorg.fontbhlucidatypewriter75dpi - pkgs.ttf_bitstream_vera + pkgs.dejavu_fonts pkgs.freefont_ttf pkgs.liberation_ttf pkgs.xorg.fontbh100dpi From 9707ffd97302bc3f4426745e9c053ce44b8be20b Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Fri, 5 Dec 2014 10:30:10 -0600 Subject: [PATCH 6/8] nixos: let fontconfig default fonts be lists of fonts --- nixos/modules/config/fonts/fontconfig.nix | 121 +++++++--------------- 1 file changed, 35 insertions(+), 86 deletions(-) diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix index ca8313e017b..793b0a250ac 100644 --- a/nixos/modules/config/fonts/fontconfig.nix +++ b/nixos/modules/config/fonts/fontconfig.nix @@ -38,29 +38,29 @@ with lib; defaultFonts = { monospace = mkOption { - type = types.str; - default = "DejaVu Sans Mono"; + type = types.listOf types.str; + default = ["DejaVu Sans Mono"]; description = '' - System-wide default monospace font. The default is not set if the - option is set to "". + System-wide default monospace font(s). Multiple fonts may be + listed in case multiple languages must be supported. ''; }; sansSerif = mkOption { - type = types.str; - default = "DejaVu Sans"; + type = types.listOf types.str; + default = ["DejaVu Sans"]; description = '' - System-wide default sans serif font. The default is not set if the - option is set to "". + System-wide default sans serif font(s). Multiple fonts may be + listed in case multiple languages must be supported. ''; }; serif = mkOption { - type = types.str; - default = "DejaVu Serif"; + type = types.listOf types.str; + default = ["DejaVu Serif"]; description = '' - System-wide default serif font. The default is not set if the - option is set to "". + System-wide default serif font(s). Multiple fonts may be listed + in case multiple languages must be supported. ''; }; }; @@ -142,16 +142,7 @@ with lib; config = let fontconfig = config.fonts.fontconfig; fcBool = x: "" + (if x then "true" else "false") + ""; - in mkIf fontconfig.enable { - - # Fontconfig 2.10 backward compatibility - - # Bring in the default (upstream) fontconfig configuration, only for fontconfig 2.10 - environment.etc."fonts/fonts.conf".source = - pkgs.makeFontsConf { fontconfig = pkgs.fontconfig_210; fontDirectories = config.fonts.fonts; }; - - environment.etc."fonts/conf.d/98-nixos.conf".text = - '' + nixosConf = '' @@ -179,27 +170,33 @@ with lib; - ${optionalString (fontconfig.defaultFonts.sansSerif != "") '' + ${optionalString (fontconfig.defaultFonts.sansSerif != []) '' sans-serif - ${fontconfig.defaultFonts.sansSerif} + ${concatStringsSep "\n" + (map (font: "${font}") + fontconfig.defaultFonts.sansSerif)} ''} - ${optionalString (fontconfig.defaultFonts.serif != "") '' + ${optionalString (fontconfig.defaultFonts.serif != []) '' serif - ${fontconfig.defaultFonts.serif} + ${concatStringsSep "\n" + (map (font: "${font}") + fontconfig.defaultFonts.serif)} ''} - ${optionalString (fontconfig.defaultFonts.monospace != "") '' + ${optionalString (fontconfig.defaultFonts.monospace != []) '' monospace - ${fontconfig.defaultFonts.monospace} + ${concatStringsSep "\n" + (map (font: "${font}") + fontconfig.defaultFonts.monospace)} ''} @@ -214,6 +211,15 @@ with lib; ''; + in mkIf fontconfig.enable { + + # Fontconfig 2.10 backward compatibility + + # Bring in the default (upstream) fontconfig configuration, only for fontconfig 2.10 + environment.etc."fonts/fonts.conf".source = + pkgs.makeFontsConf { fontconfig = pkgs.fontconfig_210; fontDirectories = config.fonts.fonts; }; + + environment.etc."fonts/conf.d/98-nixos.conf".text = nixosConf; # Versioned fontconfig > 2.10. Take shared fonts.conf from fontconfig. # Otherwise specify only font directories. @@ -230,64 +236,7 @@ with lib; ''; - environment.etc."fonts/${pkgs.fontconfig.configVersion}/conf.d/98-nixos.conf".text = - '' - - - - - - - - ${fcBool fontconfig.hinting.enable} - - - ${fcBool fontconfig.hinting.autohint} - - - hint${fontconfig.hinting.style} - - - ${fcBool fontconfig.antialias} - - - ${fontconfig.subpixel.rgba} - - - lcd${fontconfig.subpixel.lcdfilter} - - - - - - sans-serif - - ${fontconfig.defaultFonts.sansSerif} - - - - serif - - ${fontconfig.defaultFonts.serif} - - - - monospace - - ${fontconfig.defaultFonts.monospace} - - - - ${optionalString (fontconfig.dpi != 0) '' - - - ${fontconfig.dpi} - - - ''} - - - ''; + environment.etc."fonts/${pkgs.fontconfig.configVersion}/conf.d/98-nixos.conf".text = nixosConf; environment.etc."fonts/${pkgs.fontconfig.configVersion}/conf.d/99-user.conf" = { enable = fontconfig.includeUserConf; From 322bb7a67b273154c4d5a4d264d9784960698b74 Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Mon, 8 Dec 2014 10:54:24 -0600 Subject: [PATCH 7/8] fontconfig: include user config through NixOS module --- pkgs/development/libraries/fontconfig/make-fonts-conf.xsl | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl b/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl index 03f7815e38a..1b79834c894 100644 --- a/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl +++ b/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl @@ -27,8 +27,6 @@ /etc/fonts/conf.d /etc/fonts//conf.d - - fontconfig/conf.d fontconfig From efe278acfce919c7c050c1d51f10d8857d71cb28 Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Mon, 8 Dec 2014 10:57:25 -0600 Subject: [PATCH 8/8] fontconfig-ultimate.rendering: correct typo in ultimate-lightest --- pkgs/development/libraries/fontconfig-ultimate/rendering.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/libraries/fontconfig-ultimate/rendering.nix b/pkgs/development/libraries/fontconfig-ultimate/rendering.nix index 435716b8c8d..b1de43b49b2 100644 --- a/pkgs/development/libraries/fontconfig-ultimate/rendering.nix +++ b/pkgs/development/libraries/fontconfig-ultimate/rendering.nix @@ -199,7 +199,7 @@ rec { }; ultimate-lightest = ultimate // { - INFINALITY_FT_FILTER_PARAMS="06 22 36 22 06"; + INFINALITY_FT_FILTER_PARAMS="04 22 38 22 04"; }; ultimate-darker = ultimate // {