From c00c563c666465e4adea1c867b82e77b65f4c112 Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Sun, 30 Nov 2014 13:49:34 -0600 Subject: 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. --- nixos/modules/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 (limited to 'nixos') diff --git a/nixos/modules/config/fonts/fontconfig-ultimate.nix b/nixos/modules/config/fonts/fontconfig-ultimate.nix new file mode 100644 index 000000000000..408d49053dde --- /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 177eb6d0e19a..36e56a1d1527 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 -- cgit 1.4.1