From e6d3c0100c9fc2f987b3c1937e0663f366e7f2b2 Mon Sep 17 00:00:00 2001 From: kraftwerk28 Date: Mon, 27 Jun 2022 18:52:13 +0300 Subject: [PATCH] render: more precise calculation for undercurl --- render.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/render.c b/render.c index f4378b12..38845ae3 100644 --- a/render.c +++ b/render.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include @@ -443,11 +444,16 @@ draw_ext_underline(const struct terminal *term, pixman_image_t *pix, break; } case UNDERLINE_CURLY: { -#define I(x) pixman_int_to_fixed(x) const int top = y + y_ofs; const int bot = top + thickness * 3; - const int th = thickness; - const int half_x = x + ceil_w / 2, full_x = x + ceil_w; + const int half_x = x + ceil_w / 2.0, full_x = x + ceil_w; + + const double bt_2 = (bot - top) * (bot - top); + const double th_2 = thickness * thickness; + const double hx_2 = ceil_w * ceil_w / 4.0; + const int th = round(sqrt(th_2 + (th_2 * bt_2 / hx_2)) / 2.); + +#define I(x) pixman_int_to_fixed(x) const pixman_trapezoid_t traps[] = { { I(top), I(bot),