mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
metal: underline styles
This commit is contained in:
@ -171,6 +171,14 @@ pub fn init(alloc: Allocator, options: renderer.Options) !Metal {
|
|||||||
};
|
};
|
||||||
log.debug("cell dimensions={}", .{metrics});
|
log.debug("cell dimensions={}", .{metrics});
|
||||||
|
|
||||||
|
// Set the sprite font up
|
||||||
|
options.font_group.group.sprite = font.sprite.Face{
|
||||||
|
.width = @floatToInt(u32, metrics.cell_width),
|
||||||
|
.height = @floatToInt(u32, metrics.cell_height),
|
||||||
|
.thickness = 2,
|
||||||
|
.underline_position = @floatToInt(u32, metrics.underline_position),
|
||||||
|
};
|
||||||
|
|
||||||
// Create the font shaper. We initially create a shaper that can support
|
// Create the font shaper. We initially create a shaper that can support
|
||||||
// a width of 160 which is a common width for modern screens to help
|
// a width of 160 which is a common width for modern screens to help
|
||||||
// avoid allocations later.
|
// avoid allocations later.
|
||||||
@ -408,11 +416,13 @@ pub fn setFontSize(self: *Metal, size: font.face.DesiredSize) !void {
|
|||||||
if (std.meta.eql(self.cell_size, new_cell_size)) return;
|
if (std.meta.eql(self.cell_size, new_cell_size)) return;
|
||||||
self.cell_size = new_cell_size;
|
self.cell_size = new_cell_size;
|
||||||
|
|
||||||
// Set the cell size of the box font
|
// Set the sprite font up
|
||||||
if (self.font_group.group.sprite) |*sprite| {
|
self.font_group.group.sprite = font.sprite.Face{
|
||||||
sprite.width = @floatToInt(u32, self.cell_size.width);
|
.width = @floatToInt(u32, self.cell_size.width),
|
||||||
sprite.height = @floatToInt(u32, self.cell_size.height);
|
.height = @floatToInt(u32, self.cell_size.height),
|
||||||
}
|
.thickness = 2,
|
||||||
|
.underline_position = @floatToInt(u32, metrics.underline_position),
|
||||||
|
};
|
||||||
|
|
||||||
// Notify the window that the cell size changed.
|
// Notify the window that the cell size changed.
|
||||||
_ = self.window_mailbox.push(.{
|
_ = self.window_mailbox.push(.{
|
||||||
@ -912,11 +922,30 @@ pub fn updateCell(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (cell.attrs.underline != .none) {
|
if (cell.attrs.underline != .none) {
|
||||||
|
const sprite: font.Sprite = switch (cell.attrs.underline) {
|
||||||
|
.none => unreachable,
|
||||||
|
.single => .underline,
|
||||||
|
.double => .underline_double,
|
||||||
|
.dotted => .underline_dotted,
|
||||||
|
.dashed => .underline_dashed,
|
||||||
|
.curly => .underline_curly,
|
||||||
|
};
|
||||||
|
|
||||||
|
const glyph = try self.font_group.renderGlyph(
|
||||||
|
self.alloc,
|
||||||
|
font.sprite_index,
|
||||||
|
@enumToInt(sprite),
|
||||||
|
null,
|
||||||
|
);
|
||||||
|
|
||||||
self.cells.appendAssumeCapacity(.{
|
self.cells.appendAssumeCapacity(.{
|
||||||
.mode = .underline,
|
.mode = .fg,
|
||||||
.grid_pos = .{ @intToFloat(f32, x), @intToFloat(f32, y) },
|
.grid_pos = .{ @intToFloat(f32, x), @intToFloat(f32, y) },
|
||||||
.cell_width = cell.widthLegacy(),
|
.cell_width = cell.widthLegacy(),
|
||||||
.color = .{ colors.fg.r, colors.fg.g, colors.fg.b, alpha },
|
.color = .{ colors.fg.r, colors.fg.g, colors.fg.b, alpha },
|
||||||
|
.glyph_pos = .{ glyph.atlas_x, glyph.atlas_y },
|
||||||
|
.glyph_size = .{ glyph.width, glyph.height },
|
||||||
|
.glyph_offset = .{ glyph.offset_x, glyph.offset_y },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user