diff options
author | Thomas Tuegel <ttuegel@mailbox.org> | 2017-03-05 17:39:38 -0600 |
---|---|---|
committer | Thomas Tuegel <ttuegel@mailbox.org> | 2017-03-12 17:31:33 -0500 |
commit | 65592837b6e62fb555d6e8c891f347428886c4f2 (patch) | |
tree | 68000b9e98691df13fa64200c8ff5797b75a9a22 /nixos/modules/config/fonts | |
parent | 45115b19377d17ae7138f2f0a1eef2db336f59d8 (diff) |
freetype: 2.6.5 -> 2.7.1
The Infinality bytecode interpreter is removed in favor of the new v40 TrueType
interpreter. In the past, the Infinality interpreter provided support for
ClearType-style hinting instructions while the default interpreter (then v35)
provided support only for original TrueType-style instructions. The v40
interpreter corrects this deficiency, so the Infinality interpreter is no longer
necessary.
To understand why the Infinality interpreter is no longer necessary, we should
understand how ClearType differs from TrueType and how the v40 interpreter
works. The following is a summary of information available on the FreeType
website [1] mixed with my own editorializing.
TrueType instructions use horizontal and vertical hints to improve glyph
rendering. Before TrueType, fonts were only vertically hinted; horizontal hints
improved rendering by snapping stems to pixel boundaries. Horizontal hinting is
a risk because it can significantly distort glyph shapes and kerning. Extensive
testing at different resolutions is needed to perfect the TrueType
hints. Microsoft invested significant effort to do this with its "Core fonts for
the Web" project, but few other typefaces have seen this level of attention.
With the advent of subpixel rendering, the effective horizontal resolution of
most displays increased significantly. ClearType eschews horizontal hinting in
favor of horizontal supersampling. Most fonts are designed for the Microsoft
bytecode interpreter, which implements a compatibility mode with
TrueType-style (horizontal and vertical) instructions. However, applying the
full horizontal hints to subpixel-rendered fonts leads to color fringes and
inconsistent stem widths. The Infinality interpreter implements several
techniques to mitigate these problems, going so far as to embed font- and
glyph-specific hacks in the interpreter. On the other hand, the v40 interpreter
ignores the horizontal hinting instructions so that glyphs render as they are
intended to on the Microsoft interpreter. Without the horizontal hints, the
problems of glyph and kerning distortion, color fringes, and inconsistent stem
widths--the problems the Infinality interpreter was created to solve--simply
don't occur in the first place.
There are also security concerns which motivate removing the Infinality patches.
Although there is an updated version of the Infinality interpreter for FreeType
2.7, the lack of a consistent upstream maintainer is a security concern. The
interpreter is a Turing-complete virtual machine which has had security
vulnerabilities in the past. While the default interpreter is used in billions
of devices and is maintained by an active developer, the Infinality interpreter
is neither scrutinized nor maintained. We will probably never know if there are
defects in the Infinality interpreter, and if they were discovered they would
likely never be fixed. I do not think that is an acceptable situtation for a
core library like FreeType.
Dropping the Infinality patches means that font rendering will be less
customizable. I think this is an acceptable trade-off. The Infinality
interpreter made many compromises to mitigate the problems with horizontal
hinting; the main purpose of customization is to tailor these compromises to the
user's preferences. The new interpreter does not have to make these compromises
because it renders fonts as their designers intended, so this level of
customization is not necessary.
The Infinality-associated patches are also removed from cairo. These patches
only set the default rendering options in case they aren't set though
Fontconfig. On NixOS, the rendering options are always set in Fontconfig, so
these patches never actually did anything for us!
The Fontconfig test suite is patched to account for a quirk in the way PCF fonts
are named.
The fontconfig option `hintstyle` is no longer configurable in NixOS. This
option selects the TrueType interpreter; the v40 interpreter is `hintslight` and
the older v35 interpreter is `hintmedium` or `hintfull` (which have actually
always been the same thing). The setting may still be changed through the
`localConf` option or by creating a user Fontconfig file.
Users with HiDPI displays should probably disable hinting and antialiasing: at
best they have no visible effect.
The fontconfig-ultimate settings are still available in NixOS, but they are no
longer the default. They still work, but their main purpose is to set rendering
quirks which are no longer necessary and may actually be
detrimental (e.g. setting `hintfull` for some fonts). Also, the vast array of
font substitutions provided is not an appropriate default; the default setting
should be to give the user the font they asked for.
[1]. https://www.freetype.org/freetype2/docs/subpixel-hinting.html
Diffstat (limited to 'nixos/modules/config/fonts')
-rw-r--r-- | nixos/modules/config/fonts/fontconfig-ultimate.nix | 12 | ||||
-rw-r--r-- | nixos/modules/config/fonts/fontconfig.nix | 41 |
2 files changed, 26 insertions, 27 deletions
diff --git a/nixos/modules/config/fonts/fontconfig-ultimate.nix b/nixos/modules/config/fonts/fontconfig-ultimate.nix index a3f52fbd9199..acfdcbd26574 100644 --- a/nixos/modules/config/fonts/fontconfig-ultimate.nix +++ b/nixos/modules/config/fonts/fontconfig-ultimate.nix @@ -104,7 +104,7 @@ in ultimate = { enable = mkOption { type = types.bool; - default = true; + default = false; description = '' Enable fontconfig-ultimate settings (formerly known as Infinality). Besides the customizable settings in this NixOS @@ -163,15 +163,6 @@ in <literal>none</literal> disables the substitutions. ''; }; - - preset = mkOption { - type = types.enum ["ultimate1" "ultimate2" "ultimate3" "ultimate4" "ultimate5" "osx" "windowsxp"]; - default = "ultimate3"; - description = '' - FreeType rendering settings preset. Any of the presets may be - customized by setting environment variables. - ''; - }; }; }; }; @@ -181,7 +172,6 @@ in config = mkIf (config.fonts.fontconfig.enable && cfg.enable) { fonts.fontconfig.confPackages = [ confPkg ]; - environment.variables."INFINALITY_FT" = cfg.preset; }; diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix index 52ad1e714fb9..aa9c59ec551b 100644 --- a/nixos/modules/config/fonts/fontconfig.nix +++ b/nixos/modules/config/fonts/fontconfig.nix @@ -83,7 +83,7 @@ let cfg = config.fonts.fontconfig; ${fcBool cfg.hinting.autohint} </edit> <edit mode="assign" name="hintstyle"> - <const>hint${cfg.hinting.style}</const> + <const>hintslight</const> </edit> <edit mode="assign" name="antialias"> ${fcBool cfg.antialias} @@ -233,7 +233,11 @@ in antialias = mkOption { type = types.bool; default = true; - description = "Enable font antialiasing."; + description = '' + Enable font antialiasing. At high resolution (> 200 DPI), + antialiasing has no visible effect; users of such displays may want + to disable this option. + ''; }; dpi = mkOption { @@ -249,7 +253,7 @@ in type = types.lines; default = ""; description = '' - System-wide customization file contents, has higher priority than + System-wide customization file contents, has higher priority than <literal>defaultFonts</literal> settings. ''; }; @@ -287,7 +291,12 @@ in enable = mkOption { type = types.bool; default = true; - description = "Enable TrueType hinting."; + description = '' + Enable font hinting. Hinting aligns glyphs to pixel boundaries to + improve rendering sharpness at low resolution. At high resolution + (> 200 dpi) hinting will do nothing (at best); users of such + displays may want to disable this option. + ''; }; autohint = mkOption { @@ -299,16 +308,6 @@ in correctly-hinted fonts. ''; }; - - style = mkOption { - type = types.enum ["none" "slight" "medium" "full"]; - default = "full"; - description = '' - TrueType hinting style, one of <literal>none</literal>, - <literal>slight</literal>, <literal>medium</literal>, or - <literal>full</literal>. - ''; - }; }; includeUserConf = mkOption { @@ -327,7 +326,15 @@ in default = "rgb"; type = types.enum ["rgb" "bgr" "vrgb" "vbgr" "none"]; description = '' - Subpixel order. + Subpixel order. The overwhelming majority of displays are + <literal>rgb</literal> in their normal orientation. Select + <literal>vrgb</literal> for mounting such a display 90 degrees + clockwise from its normal orientation or <literal>vbgr</literal> + for mounting 90 degrees counter-clockwise. Select + <literal>bgr</literal> in the unlikely event of mounting 180 + degrees from the normal orientation. Reverse these directions in + the improbable event that the display's native subpixel order is + <literal>bgr</literal>. ''; }; @@ -335,7 +342,9 @@ in default = "default"; type = types.enum ["none" "default" "light" "legacy"]; description = '' - FreeType LCD filter. + FreeType LCD filter. At high resolution (> 200 DPI), LCD filtering + has no visible effect; users of such displays may want to select + <literal>none</literal>. ''; }; |