From e298bb7a11359b7dc70bc7913d57d00370bcb816 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Wed, 25 May 2022 06:51:31 -0700 Subject: [PATCH] shaping: fix repeated glyphs for Unicode NFD text harfbuzz can return incomplete overlapping runs when it processes text in unicode NFD. Add another check for the case where we've accumulated the bytes in the range 0-12 and then harfbuzz returns another range of 6-12. We coalesce the two together so that we can pass the full unresolved sequence to the next fallback pass. refs: https://github.com/wez/wezterm/issues/2032 --- docs/changelog.md | 1 + wezterm-font/src/shaper/harfbuzz.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/changelog.md b/docs/changelog.md index fe901c3f0..779e1e760 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -67,6 +67,7 @@ As features stabilize some brief notes about them will accumulate here. * Detaching an ssh multiplexer domain sometimes killed the associated panes! [#1993](https://github.com/wez/wezterm/issues/1993) * `DecreaseFontSize` wasn't quite the inverse of `IncreaseFontSize`. Thanks to [@Funami580](https://github.com/Funami580)! [#1997](https://github.com/wez/wezterm/pull/1997) * Wayland: unable to paste text that was copied before starting the initial wezterm window. Thanks to [@Funami580](https://github.com/Funami580)! [#1994](https://github.com/wez/wezterm/pull/1994) [#1385](https://github.com/wez/wezterm/issues/1385) +* Unicode NFD text could incorrectly render with repeated glyphs [#2032](https://github.com/wez/wezterm/issues/2032) ### 20220408-101518-b908e2dd diff --git a/wezterm-font/src/shaper/harfbuzz.rs b/wezterm-font/src/shaper/harfbuzz.rs index 4a7d8ce0c..bb131b506 100644 --- a/wezterm-font/src/shaper/harfbuzz.rs +++ b/wezterm-font/src/shaper/harfbuzz.rs @@ -401,13 +401,21 @@ impl HarfbuzzShaper { std::mem::swap(&mut info, prior); prior.len += info.len; continue; + } else if info.cluster + info.len == prior.cluster + prior.len { + // Overlaps and coincide with the end of prior; this one folds away. + // This can happen with NFD rather than NFC text. + // + continue; } + // log::info!("prior={:#?}, info={:#?}", prior, info); } } } info_clusters.push(vec![info]); } // log::error!("do_shape: font_idx={} {:?} {:#?}", font_idx, &s[range.clone()], info_clusters); + // log::info!("cluster_info: {:#?}", cluster_info); + // log::info!("info_clusters: {:#?}", info_clusters); let mut direct_clusters = 0; @@ -425,7 +433,6 @@ impl HarfbuzzShaper { log::error!("incomplete cluster for text={:?} {:?}", s, info_clusters); } */ - //println!("Incomplete: {:?}. infos: {:?}", cluster_info, infos); let first_info = &infos[0];