font/sprite(underline): add thickness correction to undercurl

This commit is contained in:
Qwerasd
2024-10-14 14:46:43 -04:00
parent 10aad444b7
commit 63f82119cd

View File

@ -163,7 +163,9 @@ fn drawDashed(alloc: Allocator, width: u32, thickness: u32) !CanvasAndOffset {
/// geometry.
fn drawCurly(alloc: Allocator, width: u32, thickness: u32) !CanvasAndOffset {
const float_width: f64 = @floatFromInt(width);
const float_thick: f64 = @floatFromInt(thickness);
// Because of we way we draw the undercurl, we end up making it around 1px
// thicker than it should be, to fix this we just reduce the thickness by 1.
const float_thick: f64 = @floatFromInt(@max(1, thickness -| 1));
// Calculate the wave period for a single character
// `2 * pi...` = 1 peak per character