mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
font: render dotted underlines
This commit is contained in:
@ -16,6 +16,7 @@ pub const Sprite = enum(u32) {
|
||||
|
||||
underline = start,
|
||||
underline_double = start + 1,
|
||||
underline_dotted = start + 2,
|
||||
|
||||
// Note: we don't currently put the box drawing glyphs in here because
|
||||
// there are a LOT and I'm lazy. What I want to do is spend more time
|
||||
|
@ -85,6 +85,7 @@ const Kind = enum {
|
||||
Sprite.start...Sprite.end => switch (@intToEnum(Sprite, cp)) {
|
||||
.underline,
|
||||
.underline_double,
|
||||
.underline_dotted,
|
||||
=> .underline,
|
||||
},
|
||||
|
||||
|
@ -69,6 +69,7 @@ const Draw = struct {
|
||||
switch (sprite) {
|
||||
.underline => self.drawSingle(canvas),
|
||||
.underline_double => self.drawDouble(canvas),
|
||||
.underline_dotted => self.drawDotted(canvas),
|
||||
}
|
||||
}
|
||||
|
||||
@ -98,6 +99,21 @@ const Draw = struct {
|
||||
.height = self.thickness,
|
||||
}, .on);
|
||||
}
|
||||
|
||||
/// Draw a dotted underline.
|
||||
fn drawDotted(self: Draw, canvas: *font.sprite.Canvas) void {
|
||||
const dot_width = @max(self.thickness, 3);
|
||||
const dot_count = self.width / dot_width;
|
||||
var i: u32 = 0;
|
||||
while (i < dot_count) : (i += 2) {
|
||||
canvas.rect(.{
|
||||
.x = i * dot_width,
|
||||
.y = self.pos,
|
||||
.width = dot_width,
|
||||
.height = self.thickness,
|
||||
}, .on);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
test "single" {
|
||||
|
@ -1009,6 +1009,7 @@ pub fn updateCell(
|
||||
.none => unreachable,
|
||||
.single => .underline,
|
||||
.double => .underline_double,
|
||||
.dotted => .underline_dotted,
|
||||
else => .underline,
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user