From 73f50efb7fcfd038e527be547b227be8dfd0b723 Mon Sep 17 00:00:00 2001 From: Wez Furlong Date: Sat, 11 Feb 2023 08:01:11 -0700 Subject: [PATCH] ls-fonts: emulate the effect of normalize_output_to_unicode_nfc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This aids in debugging: ``` ; wezterm --config normalize_output_to_unicode_nfc=false ls-fonts --text $(echo a$'\u301\u302') LeftToRight 0 x_adv=8 cells=1 glyph=aacute,190 wezterm.font("JetBrains Mono", {weight="Regular", stretch="Normal", style="Normal"}) /usr/share/fonts/jetbrains-mono-fonts/JetBrainsMono-Regular.otf, FontConfig 0 á̂ \u{61}\u{301}\u{302} x_adv=0 cells=0 glyph=uni0302,1646 wezterm.font("JetBrains Mono", {weight="Regular", stretch="Normal", style="Normal"}) /usr/share/fonts/jetbrains-mono-fonts/JetBrainsMono-Regular.otf, FontConfig ``` ``` ; ./target/debug/wezterm --config normalize_output_to_unicode_nfc=true ls-fonts --text $(echo a$'\u301\u302') LeftToRight 0 x_adv=8 cells=1 glyph=aacute,190 wezterm.font("JetBrains Mono", {weight="Regular", stretch="Normal", style="Normal"}) /usr/share/fonts/jetbrains-mono-fonts/JetBrainsMono-Regular.otf, FontConfig 0 á̂ \u{e1}\u{302} x_adv=0 cells=0 glyph=uni0302,1646 wezterm.font("JetBrains Mono", {weight="Regular", stretch="Normal", style="Normal"}) /usr/share/fonts/jetbrains-mono-fonts/JetBrainsMono-Regular.otf, FontConfig ``` refs: #3093 --- wezterm-gui/src/main.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/wezterm-gui/src/main.rs b/wezterm-gui/src/main.rs index 9be800f5a..9201519ca 100644 --- a/wezterm-gui/src/main.rs +++ b/wezterm-gui/src/main.rs @@ -25,6 +25,7 @@ use std::rc::Rc; use std::sync::Arc; use termwiz::cell::{CellAttributes, UnicodeVersion}; use termwiz::surface::{Line, SEQ_ZERO}; +use unicode_normalization::UnicodeNormalization; use wezterm_bidi::Direction; use wezterm_client::domain::{ClientDomain, ClientDomainConfig}; use wezterm_font::shaper::PresentationWidth; @@ -866,8 +867,15 @@ pub fn run_ls_fonts(config: config::ConfigHandle, cmd: &LsFontsCommand) -> anyho }; if let Some(text) = &text { + // Emulate the effect of output normalization + let text = if config.normalize_output_to_unicode_nfc { + text.nfc().collect() + } else { + text.to_string() + }; + let line = Line::from_text( - text, + &text, &CellAttributes::default(), SEQ_ZERO, Some(unicode_version),