From 2ac8509c82f4eac89a9562f6cdf07c339c53a2c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 11 May 2021 17:40:59 +0200 Subject: [PATCH] render: force underlines to be visible MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some cases, the underline position (typically provided by the font, mind you), end up below the cell, making it visible. Note that below the cell here means below the line. I.e. the font provided underline position is below the font provided line height... Oh well. Doing this in foot rather than fcft, since other applications typically don’t have to clip the rendered text. Closes #503 --- CHANGELOG.md | 5 +++++ render.c | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e14edf0..c27eb646 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -75,8 +75,10 @@ ### Deprecated + * **bell** option in `foot.ini`; set actions in **[bell]** section instead. + ### Removed * Buffer damage quirk for Plasma/KWin. @@ -93,6 +95,9 @@ (https://codeberg.org/dnkl/foot/issues/495). * Assertion when emitting a sixel occupying the entire scrollback history (https://codeberg.org/dnkl/foot/issues/494). +* Font underlines being positioned below the cell (and thus being + invisible) for certain combinations of fonts and font sizes + (https://codeberg.org/dnkl/foot/issues/503). ### Security diff --git a/render.c b/render.c index 1454c84a..8481d330 100644 --- a/render.c +++ b/render.c @@ -317,11 +317,14 @@ draw_underline(const struct terminal *term, pixman_image_t *pix, const struct fcft_font *font, const pixman_color_t *color, int x, int y, int cols) { + /* Make sure the line isn't positioned below the cell */ + int y_ofs = font_baseline(term) - font->underline.position; + y_ofs = min(y_ofs, term->cell_height - font->underline.thickness); + pixman_image_fill_rectangles( PIXMAN_OP_SRC, pix, color, 1, &(pixman_rectangle16_t){ - x, y + font_baseline(term) - font->underline.position, - cols * term->cell_width, font->underline.thickness}); + x, y + y_ofs, cols * term->cell_width, font->underline.thickness}); } static void