From 9178fabc5d7c095d0f3781f56f23ca6cda2a7f63 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 16 Dec 2023 20:18:14 -0800 Subject: [PATCH] renderer: also constrain PUA chars if preceded by PUA --- src/renderer/cell.zig | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/renderer/cell.zig b/src/renderer/cell.zig index b9407a4b1..6a323d4fe 100644 --- a/src/renderer/cell.zig +++ b/src/renderer/cell.zig @@ -45,13 +45,23 @@ pub fn fgMode( break :text .normal; } + // If we are at the end of the screen its definitely constrained + if (x == screen.cols - 1) break :text .constrained; + + // 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) { + const prev_cell = screen.getCell(.active, y, x - 1); + if (ziglyph.general_category.isPrivateUse(@intCast(prev_cell.char))) { + break :text .constrained; + } + } + // If the next cell is empty, then we allow it to use the // full glyph size. - if (x < screen.cols - 1) { - const next_cell = screen.getCell(.active, y, x + 1); - if (next_cell.char == 0 or next_cell.char == ' ') { - break :text .normal; - } + const next_cell = screen.getCell(.active, y, x + 1); + if (next_cell.char == 0 or next_cell.char == ' ') { + break :text .normal; } // Must be constrained