Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

font/sprite: undercurl minimum thickness improvement #2450

Merged
merged 1 commit into from
Oct 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/font/sprite/underline.zig
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,11 @@ fn drawCurly(alloc: Allocator, width: u32, thickness: u32) !CanvasAndOffset {
const float_width: f64 = @floatFromInt(width);
// 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));
//
// We use a minimum thickness of 0.414 because this empirically produces
// the nicest undercurls at 1px underline thickness; thinner tends to look
// too thin compared to straight underlines and has artefacting.
const float_thick: f64 = @max(0.414, @as(f64, @floatFromInt(thickness -| 1)));

// Calculate the wave period for a single character
// `2 * pi...` = 1 peak per character
Expand Down
Loading