fix: correct the cursor Y position value exposed to shader uniforms

Fix for discussion #8113

The cursor Y position value exposed to the shader uniforms was
incorrectly calculated. As per the doc in cell_text.v.glsl: In order to
get the top left of the glyph, we compute an offset based on the
bearings. The Y bearing is the distance from the bottom of the cell to
the top of the glyph, so we subtract it from the cell height to get the
y offset.

This calculation was mistakenly left out of the original code.

This will ensure that the custom shaders using
iCurrentCursor/iPreviousCursor get the correct Y coordinate representing
the top-left corner of the cursor rectangle, matching the documented
uniform behavior
This commit is contained in:
ClearAspect
2025-08-01 21:06:46 -04:00
committed by Mitchell Hashimoto
parent 66e5081721
commit f7994e6412

View File

@@ -2233,15 +2233,13 @@ pub fn Renderer(comptime GraphicsAPI: type) type {
);
pixel_x += @floatFromInt(cursor.bearings[0]);
pixel_y += @floatFromInt(cursor.bearings[1]);
// Convert the Y coordinate from bottom-to-top to top-to-bottom.
// Otherwise we end up with glyphs like underline at the top of the cell.
pixel_y += @floatFromInt(@as(i32, @intCast(cell.height)) - cursor.bearings[1]);
// If +Y is up in our shaders, we need to flip the coordinate.
if (!GraphicsAPI.custom_shader_y_is_down) {
pixel_y = @as(f32, @floatFromInt(screen.height)) - pixel_y;
// We need to add the cursor height because we need the +Y
// edge for the Y coordinate, and flipping means that it's
// the -Y edge now.
pixel_y += cursor_height;
}
const new_cursor: [4]f32 = .{