From 1907c58972482b2166dcc9060cb4fef631bf7712 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 25 Jan 2024 15:35:48 -0800 Subject: [PATCH] renderer: consider powerline box glyphs whitespace for PUA scaling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds to the heuristics introduced for #1071. Please read that issue and associated PRs in their entirety to understand this commit. This extends our concept of "whitespace" to include powerline box glyphs. We don't want to constrain nerd symbols next to powerline box glyphs because box glyphs are often used to style and contain nerd glyphs. For example, its common to see a right-facing semi-circle, then a nerd font glyph, then a left-facing semi-circle to create a pill-shaped label. This allows those nerd font symbols to be rendered full size. Test script below (copy the bytes): printf "󰃰\n" printf "󰃰 \n" printf "󰃰\n" --- src/renderer/cell.zig | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/renderer/cell.zig b/src/renderer/cell.zig index 9bbd8fd7b..1a5ac51d9 100644 --- a/src/renderer/cell.zig +++ b/src/renderer/cell.zig @@ -58,8 +58,14 @@ pub fn fgMode( // If we have a previous cell and it was PUA then we need to // also constrain. This is so that multiple PUA glyphs align. - if (x > 0) { + // As an exception, we ignore powerline glyphs since they are + // used for box drawing and we consider them whitespace. + if (x > 0) prev: { const prev_cell = screen.getCell(.active, y, x - 1); + + // Powerline is whitespace + if (isPowerline(prev_cell.char)) break :prev; + if (ziglyph.general_category.isPrivateUse(@intCast(prev_cell.char))) { break :text .constrained; } @@ -68,7 +74,10 @@ pub fn fgMode( // If the next cell is empty, then we allow it to use the // full glyph size. const next_cell = screen.getCell(.active, y, x + 1); - if (next_cell.char == 0 or next_cell.char == ' ') { + if (next_cell.char == 0 or + next_cell.char == ' ' or + isPowerline(next_cell.char)) + { break :text .normal; }