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:
parent
a2004a2a7d
commit
72214b7db9
@ -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,22 +574,26 @@ fn font<'lua>(
|
||||
text_style.foreground = map_defaults.foreground;
|
||||
}
|
||||
|
||||
text_style.font.push(FontAttributes {
|
||||
family: attrs.family,
|
||||
stretch: attrs.stretch,
|
||||
weight: attrs.weight,
|
||||
style: attrs.style,
|
||||
is_fallback: false,
|
||||
is_synthetic: false,
|
||||
harfbuzz_features: attrs.harfbuzz_features,
|
||||
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))?),
|
||||
None => None,
|
||||
},
|
||||
scale: attrs.scale,
|
||||
});
|
||||
text_style
|
||||
.font
|
||||
.push(disable_ligatures_for_menlo_or_monaco(FontAttributes {
|
||||
family: attrs.family,
|
||||
stretch: attrs.stretch,
|
||||
weight: attrs.weight,
|
||||
style: attrs.style,
|
||||
is_fallback: false,
|
||||
is_synthetic: false,
|
||||
harfbuzz_features: attrs.harfbuzz_features,
|
||||
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))?)
|
||||
}
|
||||
None => None,
|
||||
},
|
||||
scale: attrs.scale,
|
||||
}));
|
||||
|
||||
Ok(text_style)
|
||||
}
|
||||
@ -602,24 +624,26 @@ fn font_with_fallback<'lua>(
|
||||
text_style.foreground = map_defaults.foreground;
|
||||
}
|
||||
|
||||
text_style.font.push(FontAttributes {
|
||||
family: attrs.family,
|
||||
stretch: attrs.stretch,
|
||||
weight: attrs.weight,
|
||||
style: attrs.style,
|
||||
is_fallback: idx != 0,
|
||||
is_synthetic: false,
|
||||
harfbuzz_features: attrs.harfbuzz_features,
|
||||
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))?)
|
||||
}
|
||||
None => None,
|
||||
},
|
||||
scale: attrs.scale,
|
||||
});
|
||||
text_style
|
||||
.font
|
||||
.push(disable_ligatures_for_menlo_or_monaco(FontAttributes {
|
||||
family: attrs.family,
|
||||
stretch: attrs.stretch,
|
||||
weight: attrs.weight,
|
||||
style: attrs.style,
|
||||
is_fallback: idx != 0,
|
||||
is_synthetic: false,
|
||||
harfbuzz_features: attrs.harfbuzz_features,
|
||||
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))?)
|
||||
}
|
||||
None => None,
|
||||
},
|
||||
scale: attrs.scale,
|
||||
}));
|
||||
}
|
||||
|
||||
Ok(text_style)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user