1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 23:21:08 +03:00

Disable ligatures for Menlo and Monaco

refs: https://github.com/wez/wezterm/issues/1736
refs: https://github.com/wez/wezterm/issues/1786
This commit is contained in:
Wez Furlong 2022-03-28 19:32:00 -07:00
parent a2004a2a7d
commit 72214b7db9
2 changed files with 59 additions and 34 deletions

View File

@ -529,6 +529,24 @@ impl<'lua> FromLua<'lua> for LuaFontAttributes {
}
}
/// On macOS, both Menlo and Monaco fonts have ligatures for `fi` that
/// take effect for words like `find` and which are a source of
/// confusion/annoyance and issues filed on Github.
/// Let's default to disabling ligatures for these fonts unless
/// the user has explicitly specified harfbuzz_features.
/// <https://github.com/wez/wezterm/issues/1736>
/// <https://github.com/wez/wezterm/issues/1786>
fn disable_ligatures_for_menlo_or_monaco(mut attrs: FontAttributes) -> FontAttributes {
if attrs.harfbuzz_features.is_none() && (attrs.family == "Menlo" || attrs.family == "Monaco") {
attrs.harfbuzz_features = Some(vec![
"kern".to_string(),
"clig".to_string(),
"liga=0".to_string(),
]);
}
attrs
}
/// Given a simple font family name, returns a text style instance.
/// The second optional argument is a list of the other TextStyle
/// fields, which at the time of writing includes only the
@ -556,7 +574,9 @@ fn font<'lua>(
text_style.foreground = map_defaults.foreground;
}
text_style.font.push(FontAttributes {
text_style
.font
.push(disable_ligatures_for_menlo_or_monaco(FontAttributes {
family: attrs.family,
stretch: attrs.stretch,
weight: attrs.weight,
@ -567,11 +587,13 @@ fn font<'lua>(
freetype_load_target: attrs.freetype_load_target,
freetype_render_target: attrs.freetype_render_target,
freetype_load_flags: match attrs.freetype_load_flags {
Some(flags) => Some(TryFrom::try_from(flags).map_err(|e| mlua::Error::external(e))?),
Some(flags) => {
Some(TryFrom::try_from(flags).map_err(|e| mlua::Error::external(e))?)
}
None => None,
},
scale: attrs.scale,
});
}));
Ok(text_style)
}
@ -602,7 +624,9 @@ fn font_with_fallback<'lua>(
text_style.foreground = map_defaults.foreground;
}
text_style.font.push(FontAttributes {
text_style
.font
.push(disable_ligatures_for_menlo_or_monaco(FontAttributes {
family: attrs.family,
stretch: attrs.stretch,
weight: attrs.weight,
@ -619,7 +643,7 @@ fn font_with_fallback<'lua>(
None => None,
},
scale: attrs.scale,
});
}));
}
Ok(text_style)

View File

@ -13,6 +13,7 @@ As features stabilize some brief notes about them will accumulate here.
#### New
#### Changed
* Disabled ligatures for `"Monaco"` and `"Menlo"` fonts, as those ligatures match even for words such as `find`. [#1786](https://github.com/wez/wezterm/issues/1786) [#1736](https://github.com/wez/wezterm/issues/1736)
#### Updated and Improved
* Bundled harfbuzz to 4.1.0
* On macOS, non-native fullscreen mode now attempts to avoid the notch on systems that have one. [#1737](https://github.com/wez/wezterm/issues/1737)