mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
font: render dotted underlines
This commit is contained in:
@ -16,6 +16,7 @@ pub const Sprite = enum(u32) {
|
|||||||
|
|
||||||
underline = start,
|
underline = start,
|
||||||
underline_double = start + 1,
|
underline_double = start + 1,
|
||||||
|
underline_dotted = start + 2,
|
||||||
|
|
||||||
// Note: we don't currently put the box drawing glyphs in here because
|
// 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
|
// 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)) {
|
Sprite.start...Sprite.end => switch (@intToEnum(Sprite, cp)) {
|
||||||
.underline,
|
.underline,
|
||||||
.underline_double,
|
.underline_double,
|
||||||
|
.underline_dotted,
|
||||||
=> .underline,
|
=> .underline,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -69,6 +69,7 @@ const Draw = struct {
|
|||||||
switch (sprite) {
|
switch (sprite) {
|
||||||
.underline => self.drawSingle(canvas),
|
.underline => self.drawSingle(canvas),
|
||||||
.underline_double => self.drawDouble(canvas),
|
.underline_double => self.drawDouble(canvas),
|
||||||
|
.underline_dotted => self.drawDotted(canvas),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,6 +99,21 @@ const Draw = struct {
|
|||||||
.height = self.thickness,
|
.height = self.thickness,
|
||||||
}, .on);
|
}, .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" {
|
test "single" {
|
||||||
|
@ -1009,6 +1009,7 @@ pub fn updateCell(
|
|||||||
.none => unreachable,
|
.none => unreachable,
|
||||||
.single => .underline,
|
.single => .underline,
|
||||||
.double => .underline_double,
|
.double => .underline_double,
|
||||||
|
.dotted => .underline_dotted,
|
||||||
else => .underline,
|
else => .underline,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user