From f7c558e733ae7aa6b31334586184a543d5b8457d Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 7 Jan 2024 14:54:15 -0800 Subject: [PATCH 1/2] renderer: constrain dingbats category to cell size Dingbats are generally symbolic glyphs that frequently overflow the cell. Their defined codepoint width is "1" so they take one cell but very often overflow to the next. This extends the previously created logic for Nerd Font symbols such that when a dingbat is next to whitespace, we allow it to use the full size, but when a dingbat is next to an occupied cell we constrain it to the cell size. --- src/renderer/cell.zig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/renderer/cell.zig b/src/renderer/cell.zig index 56d606b6c..9bbd8fd7b 100644 --- a/src/renderer/cell.zig +++ b/src/renderer/cell.zig @@ -41,7 +41,9 @@ pub fn fgMode( // the subsequent character is empty, then we allow it to use // the full glyph size. See #1071. .text => text: { - if (!ziglyph.general_category.isPrivateUse(@intCast(cell.char))) { + if (!ziglyph.general_category.isPrivateUse(@intCast(cell.char)) and + !ziglyph.blocks.isDingbats(@intCast(cell.char))) + { break :text .normal; } From 62e5234da4626a46efa4d3a6f3f085d09be60b03 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 7 Jan 2024 15:02:56 -0800 Subject: [PATCH 2/2] renderer: for constrained cells, offset was being doubled This helps better preserve the centerline for constrained glyphs --- src/renderer/shaders/cell.metal | 2 +- src/renderer/shaders/cell.v.glsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/renderer/shaders/cell.metal b/src/renderer/shaders/cell.metal index ccb340231..1ce7e74a4 100644 --- a/src/renderer/shaders/cell.metal +++ b/src/renderer/shaders/cell.metal @@ -165,7 +165,7 @@ vertex VertexOut uber_vertex( if (input.mode == MODE_FG_CONSTRAINED) { if (glyph_size.x > cell_size_scaled.x) { float new_y = glyph_size.y * (cell_size_scaled.x / glyph_size.x); - glyph_offset.y += glyph_size.y - new_y; + glyph_offset.y += (glyph_size.y - new_y) / 2; glyph_size.y = new_y; glyph_size.x = cell_size_scaled.x; } diff --git a/src/renderer/shaders/cell.v.glsl b/src/renderer/shaders/cell.v.glsl index 18b586508..966c6e7e9 100644 --- a/src/renderer/shaders/cell.v.glsl +++ b/src/renderer/shaders/cell.v.glsl @@ -194,7 +194,7 @@ void main() { if (mode == MODE_FG_CONSTRAINED) { if (glyph_size.x > cell_size_scaled.x) { float new_y = glyph_size.y * (cell_size_scaled.x / glyph_size.x); - glyph_offset_calc.y = glyph_offset_calc.y + (glyph_size.y - new_y); + glyph_offset_calc.y = glyph_offset_calc.y + ((glyph_size.y - new_y) / 2); glyph_size_calc.y = new_y; glyph_size_calc.x = cell_size_scaled.x; }