renderer/metal: offset zero-advance glyphs by the cell width

This commit is contained in:
Mitchell Hashimoto
2023-12-10 17:08:32 -08:00
parent 3fdb6a496d
commit 5e9ddb5e65

View File

@ -1787,6 +1787,15 @@ pub fn updateCell(
.emoji => .fg_color, .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(.{ self.cells.appendAssumeCapacity(.{
.mode = mode, .mode = mode,
.grid_pos = .{ @as(f32, @floatFromInt(x)), @as(f32, @floatFromInt(y)) }, .grid_pos = .{ @as(f32, @floatFromInt(x)), @as(f32, @floatFromInt(y)) },
@ -1795,7 +1804,7 @@ pub fn updateCell(
.bg_color = bg, .bg_color = bg,
.glyph_pos = .{ glyph.atlas_x, glyph.atlas_y }, .glyph_pos = .{ glyph.atlas_x, glyph.atlas_y },
.glyph_size = .{ glyph.width, glyph.height }, .glyph_size = .{ glyph.width, glyph.height },
.glyph_offset = .{ glyph.offset_x, glyph.offset_y }, .glyph_offset = .{ glyph.offset_x + extra_offset, glyph.offset_y },
}); });
} }