Skip to content

Commit

Permalink
ls-fonts --text used wrong per-glyph text
Browse files Browse the repository at this point in the history
It was showing the whole text for the cluster for each shaped
glyph.

Fix it up to map back to the corresponding cell range and
extract the text from the line.

Include the x_advance metric in the output while we're in
there.

refs: #1333
  • Loading branch information
wez committed Jan 6, 2022
1 parent 91a423d commit 8437d78
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions wezterm-gui/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,17 @@ pub fn run_ls_fonts(config: config::ConfigHandle, cmd: &LsFontsCommand) -> anyho
// revised list that includes system fallbacks!
let handles = font.clone_handles();

for info in infos {
let mut iter = infos.iter().peekable();
while let Some(info) = iter.next() {
let idx = cluster.byte_to_cell_idx(info.cluster as usize);
let text = if let Some(ahead) = iter.peek() {
line.columns_as_str(idx..cluster.byte_to_cell_idx(ahead.cluster as usize))
} else {
line.columns_as_str(idx..line.cells().len())
};

let parsed = &handles[info.font_idx];
let escaped = format!("{}", cluster.text.escape_unicode());
let escaped = format!("{}", text.escape_unicode());
if config.custom_block_glyphs {
if let Some(block) = customglyph::BlockKey::from_str(&text) {
println!(
Expand All @@ -517,9 +525,10 @@ pub fn run_ls_fonts(config: config::ConfigHandle, cmd: &LsFontsCommand) -> anyho
}

println!(
"{:4} {:12} glyph={:<4} {}\n{:29}{}",
cluster.text,
"{:4} {:12} x_adv={:<2} glyph={:<4} {}\n{:38}{}",
text,
escaped,
info.x_advance.get(),
info.glyph_pos,
parsed.lua_name(),
"",
Expand Down

0 comments on commit 8437d78

Please sign in to comment.