···
1
+
{ config, pkgs, ... }:
5
+
let fcBool = x: if x then "<bool>true</bool>" else "<bool>false</bool>";
20
+
Enable fontconfig-ultimate settings (formerly known as
21
+
Infinality). Besides the customizable settings in this NixOS
22
+
module, fontconfig-ultimate also provides many font-specific
27
+
allowBitmaps = mkOption {
31
+
Allow bitmap fonts. Set to <literal>false</literal> to ban all
36
+
allowType1 = mkOption {
40
+
Allow Type-1 fonts. Default is <literal>false</literal> because of
45
+
useEmbeddedBitmaps = mkOption {
48
+
description = ''Use embedded bitmaps in fonts like Calibri.'';
51
+
forceAutohint = mkOption {
55
+
Force use of the TrueType Autohinter. Useful for debugging or
56
+
free-software purists.
60
+
renderMonoTTFAsBitmap = mkOption {
63
+
description = ''Render some monospace TTF fonts as bitmaps.'';
66
+
substitutions = mkOption {
67
+
type = types.str // {
68
+
check = flip elem ["none" "free" "combi" "ms"];
72
+
Font substitutions to replace common Type 1 fonts with nicer
73
+
TrueType fonts. <literal>free</literal> uses free fonts,
74
+
<literal>ms</literal> uses Microsoft fonts,
75
+
<literal>combi</literal> uses a combination, and
76
+
<literal>none</literal> disables the substitutions.
80
+
rendering = mkOption {
82
+
default = pkgs.fontconfig-ultimate.rendering.ultimate;
84
+
FreeType rendering settings presets. The default is
85
+
<literal>pkgs.fontconfig-ultimate.rendering.ultimate</literal>.
86
+
The other available styles are:
87
+
<literal>ultimate-lighter</literal>,
88
+
<literal>ultimate-darker</literal>,
89
+
<literal>ultimate-lightest</literal>,
90
+
<literal>ultimate-darkest</literal>,
91
+
<literal>default</literal> (the original Infinality default),
92
+
<literal>osx</literal>,
93
+
<literal>ipad</literal>,
94
+
<literal>ubuntu</literal>,
95
+
<literal>linux</literal>,
96
+
<literal>winxplight</literal>,
97
+
<literal>win7light</literal>,
98
+
<literal>winxp</literal>,
99
+
<literal>win7</literal>,
100
+
<literal>vanilla</literal>,
101
+
<literal>classic</literal>,
102
+
<literal>nudge</literal>,
103
+
<literal>push</literal>,
104
+
<literal>shove</literal>,
105
+
<literal>sharpened</literal>,
106
+
<literal>infinality</literal>. Any of the presets may be
107
+
customized by editing the attributes. To disable, set this option
108
+
to the empty attribute set <literal>{}</literal>.
119
+
let ultimate = config.fonts.fontconfig.ultimate;
120
+
fontconfigUltimateConf = ''
121
+
<?xml version="1.0"?>
122
+
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
125
+
${optionalString ultimate.allowBitmaps ''
126
+
<!-- Reject bitmap fonts -->
130
+
<patelt name="scalable"><bool>false</bool></patelt>
136
+
${optionalString ultimate.allowType1 ''
137
+
<!-- Reject Type 1 fonts -->
141
+
<patelt name="fontformat">
142
+
<string>Type 1</string>
149
+
<!-- Use embedded bitmaps in fonts like Calibri? -->
150
+
<match target="font">
151
+
<edit name="embeddedbitmap" mode="assign">
152
+
${fcBool ultimate.useEmbeddedBitmaps}
156
+
<!-- Force autohint always -->
157
+
<match target="font">
158
+
<edit name="force_autohint" mode="assign">
159
+
${fcBool ultimate.forceAutohint}
163
+
<!-- Render some monospace TTF fonts as bitmaps -->
164
+
<match target="pattern">
165
+
<edit name="bitmap_monospace" mode="assign">
166
+
${fcBool ultimate.renderMonoTTFAsBitmap}
170
+
${optionalString (ultimate.substitutions != "none") ''
171
+
<!-- Type 1 font substitutions -->
172
+
<include ignore_missing="yes">${pkgs.fontconfig-ultimate.confd}/etc/fonts/presets/${ultimate.substitutions}</include>
175
+
<include ignore_missing="yes">${pkgs.fontconfig-ultimate.confd}/etc/fonts/conf.d</include>
179
+
in mkIf (config.fonts.fontconfig.enable && ultimate.enable) {
181
+
environment.etc."fonts/conf.d/52-fontconfig-ultimate.conf" = {
182
+
text = fontconfigUltimateConf;
185
+
environment.etc."fonts/${pkgs.fontconfig.configVersion}/conf.d/52-fontconfig-ultimate.conf" = {
186
+
text = fontconfigUltimateConf;
189
+
environment.variables = ultimate.rendering;