From 979368c4eb7f00dcae63d6336a3f3ef112f44f73 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Mon, 21 Dec 2020 09:15:13 -0800 Subject: [PATCH] font: add freetype_interpreter_version configuration option This defaults to None, taking the default from the freetype library. You can select an integer value to tell the library to use an alternative version. Versions that are available in the build used by wezterm are 35, 38 and 40. See https://freetype.org/freetype2/docs/subpixel-hinting.html for more information. --- config/src/lib.rs | 6 ++++++ wezterm-font/src/ftwrap.rs | 19 +++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/config/src/lib.rs b/config/src/lib.rs index 39c4432d9..ba30a90a1 100644 --- a/config/src/lib.rs +++ b/config/src/lib.rs @@ -558,6 +558,12 @@ pub struct Config { #[serde(default)] pub font_antialias: FontAntiAliasing, + /// Selects the freetype interpret version to use. + /// Likely values are 35, 38 and 40 which have different + /// characteristics with respective to subpixel hinting. + /// See https://freetype.org/freetype2/docs/subpixel-hinting.html + pub freetype_interpreter_version: Option, + /// Specify the features to enable when using harfbuzz for font shaping. /// There is some light documentation here: /// diff --git a/wezterm-font/src/ftwrap.rs b/wezterm-font/src/ftwrap.rs index a7209bde2..13adaa781 100644 --- a/wezterm-font/src/ftwrap.rs +++ b/wezterm-font/src/ftwrap.rs @@ -245,14 +245,17 @@ impl Library { let lib = ft_result(res, lib).context("FT_Init_FreeType")?; let mut lib = Library { lib }; - let interpreter_version: FT_UInt = 38; - unsafe { - FT_Property_Set( - lib.lib, - b"truetype\0" as *const u8 as *const FT_String, - b"interpreter-version\0" as *const u8 as *const FT_String, - &interpreter_version as *const FT_UInt as *const _, - ); + let config = configuration(); + if let Some(vers) = config.freetype_interpreter_version { + let interpreter_version: FT_UInt = vers; + unsafe { + FT_Property_Set( + lib.lib, + b"truetype\0" as *const u8 as *const FT_String, + b"interpreter-version\0" as *const u8 as *const FT_String, + &interpreter_version as *const FT_UInt as *const _, + ); + } } // Due to patent concerns, the freetype library disables the LCD