mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 16:56:09 +03:00
font: fix double underline drawing with very low underline positions
This commit is contained in:
@ -91,16 +91,26 @@ const Draw = struct {
|
|||||||
|
|
||||||
/// Draw a double underline.
|
/// Draw a double underline.
|
||||||
fn drawDouble(self: Draw, canvas: *font.sprite.Canvas) void {
|
fn drawDouble(self: Draw, canvas: *font.sprite.Canvas) void {
|
||||||
|
// The maximum y value has to have space for the bottom underline.
|
||||||
|
// If we underflow (saturated) to 0, then we don't draw. This should
|
||||||
|
// never happen but we don't want to draw something undefined.
|
||||||
|
const y_max = self.height -| 1 -| self.thickness;
|
||||||
|
if (y_max == 0) return;
|
||||||
|
|
||||||
|
const space = self.thickness * 2;
|
||||||
|
const bottom = @min(self.pos + space, y_max);
|
||||||
|
const top = bottom - space;
|
||||||
|
|
||||||
canvas.rect(.{
|
canvas.rect(.{
|
||||||
.x = 0,
|
.x = 0,
|
||||||
.y = @intCast(i32, self.pos),
|
.y = @intCast(i32, top),
|
||||||
.width = self.width,
|
.width = self.width,
|
||||||
.height = self.thickness,
|
.height = self.thickness,
|
||||||
}, .on);
|
}, .on);
|
||||||
|
|
||||||
canvas.rect(.{
|
canvas.rect(.{
|
||||||
.x = 0,
|
.x = 0,
|
||||||
.y = @intCast(i32, self.pos + (self.thickness * 2)),
|
.y = @intCast(i32, bottom),
|
||||||
.width = self.width,
|
.width = self.width,
|
||||||
.height = self.thickness,
|
.height = self.thickness,
|
||||||
}, .on);
|
}, .on);
|
||||||
|
Reference in New Issue
Block a user