mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-17 01:06:08 +03:00
font/sprite: test for thick underline, assertion on x/y for rect
This commit is contained in:
@ -424,6 +424,9 @@ const PixmanImpl = struct {
|
|||||||
/// Draw and fill a rectangle. This is the main primitive for drawing
|
/// Draw and fill a rectangle. This is the main primitive for drawing
|
||||||
/// lines as well (which are just generally skinny rectangles...)
|
/// lines as well (which are just generally skinny rectangles...)
|
||||||
pub fn rect(self: *Canvas, v: Rect, color: Color) void {
|
pub fn rect(self: *Canvas, v: Rect, color: Color) void {
|
||||||
|
assert(v.x >= 0);
|
||||||
|
assert(v.y >= 0);
|
||||||
|
|
||||||
const boxes = &[_]pixman.Box32{
|
const boxes = &[_]pixman.Box32{
|
||||||
.{
|
.{
|
||||||
.x1 = @intCast(v.x),
|
.x1 = @intCast(v.x),
|
||||||
|
@ -80,7 +80,7 @@ const Draw = struct {
|
|||||||
// Ensure we never overflow out of bounds on the canvas
|
// Ensure we never overflow out of bounds on the canvas
|
||||||
const y_max = self.height -| 1;
|
const y_max = self.height -| 1;
|
||||||
const bottom = @min(self.pos + self.thickness, y_max);
|
const bottom = @min(self.pos + self.thickness, y_max);
|
||||||
const y = @as(i32, @intCast(bottom)) - @as(i32, @intCast(self.thickness));
|
const y = @as(i32, @intCast(bottom -| self.thickness));
|
||||||
|
|
||||||
canvas.rect(.{
|
canvas.rect(.{
|
||||||
.x = 0,
|
.x = 0,
|
||||||
@ -224,6 +224,26 @@ test "single" {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "single large thickness" {
|
||||||
|
const testing = std.testing;
|
||||||
|
const alloc = testing.allocator;
|
||||||
|
|
||||||
|
var atlas_greyscale = try font.Atlas.init(alloc, 512, .greyscale);
|
||||||
|
defer atlas_greyscale.deinit(alloc);
|
||||||
|
|
||||||
|
// unrealistic thickness but used to cause a crash
|
||||||
|
// https://github.com/mitchellh/ghostty/pull/1548
|
||||||
|
_ = try renderGlyph(
|
||||||
|
alloc,
|
||||||
|
&atlas_greyscale,
|
||||||
|
.underline,
|
||||||
|
36,
|
||||||
|
18,
|
||||||
|
9,
|
||||||
|
200,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
test "curly" {
|
test "curly" {
|
||||||
const testing = std.testing;
|
const testing = std.testing;
|
||||||
const alloc = testing.allocator;
|
const alloc = testing.allocator;
|
||||||
|
Reference in New Issue
Block a user