From 3e9a6e4de50ccf1843d33b1f91d42abf12cc3252 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 10 Dec 2023 17:10:00 -0800 Subject: [PATCH] renderer/opengl: apply extra offset for zero-advance glyphs --- src/renderer/OpenGL.zig | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index a9972930e..9ba9f0921 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -1490,6 +1490,15 @@ pub fn updateCell( .emoji => .fg_color, }; + // If this glyph doesn't have an advance, then we assume it is + // connected to the previous glyph (perhaps an unsafe assumption...) + // and offset by the cell width. + // Related: https://github.com/mitchellh/ghostty/issues/1046 + const extra_offset: i32 = if (glyph.advance_x == 0) + @intCast(self.grid_metrics.cell_width) + else + 0; + self.cells.appendAssumeCapacity(.{ .mode = mode, .grid_col = @intCast(x), @@ -1499,7 +1508,7 @@ pub fn updateCell( .glyph_y = glyph.atlas_y, .glyph_width = glyph.width, .glyph_height = glyph.height, - .glyph_offset_x = glyph.offset_x, + .glyph_offset_x = glyph.offset_x + extra_offset, .glyph_offset_y = glyph.offset_y, .r = colors.fg.r, .g = colors.fg.g,