diff --git a/src/font/sprite.zig b/src/font/sprite.zig index dc3843de6..f5b232061 100644 --- a/src/font/sprite.zig +++ b/src/font/sprite.zig @@ -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 diff --git a/src/font/sprite/Face.zig b/src/font/sprite/Face.zig index d42b3ef0b..829cecc09 100644 --- a/src/font/sprite/Face.zig +++ b/src/font/sprite/Face.zig @@ -85,6 +85,7 @@ const Kind = enum { Sprite.start...Sprite.end => switch (@intToEnum(Sprite, cp)) { .underline, .underline_double, + .underline_dotted, => .underline, }, diff --git a/src/font/sprite/underline.zig b/src/font/sprite/underline.zig index 5f6d2f9af..4ce2aad31 100644 --- a/src/font/sprite/underline.zig +++ b/src/font/sprite/underline.zig @@ -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" { diff --git a/src/renderer/OpenGL.zig b/src/renderer/OpenGL.zig index 18b2aa959..35659490d 100644 --- a/src/renderer/OpenGL.zig +++ b/src/renderer/OpenGL.zig @@ -1009,6 +1009,7 @@ pub fn updateCell( .none => unreachable, .single => .underline, .double => .underline_double, + .dotted => .underline_dotted, else => .underline, };