From 7be98291e161d1c6a0d878285abae4c909e48e0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 30 Nov 2019 14:51:44 +0100 Subject: [PATCH] render: font_baseline(): simply use the primary font's ascent This is what we used as baseline for regular glyphs anyway. Thus, we can update that code to call font_baseline() now. This makes it easier to change how we define the baseline in the future. --- render.c | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/render.c b/render.c index 64b64a13..f74c5fac 100644 --- a/render.c +++ b/render.c @@ -83,19 +83,7 @@ pixman_color_dim_for_search(pixman_color_t *color) static inline int font_baseline(const struct terminal *term) { - assert(term->fonts[0]->ascent >= 0); - assert(term->fonts[0]->descent >= 0); - - int diff = term->fonts[0]->height - (term->fonts[0]->ascent + term->fonts[0]->descent); - -#if 0 - LOG_INFO("height=%d, ascent=%d, descent=%d, diff=%d", - term->fonts[0]->height, - term->fonts[0]->ascent, term->fonts[0]->descent, - diff); -#endif - - return term->fonts[0]->height - diff / 2 - term->fonts[0]->descent; + return term->fonts[0]->ascent; } static void @@ -286,7 +274,7 @@ render_cell(struct terminal *term, pixman_image_t *pix, if (!(cell->attrs.blink && term->blink.state == BLINK_OFF)) { pixman_image_composite32( PIXMAN_OP_OVER, glyph->pix, NULL, pix, 0, 0, 0, 0, - x + glyph->x, y + term->fonts[0]->ascent - glyph->y, + x + glyph->x, y + font_baseline(term) - glyph->y, glyph->width, glyph->height); } } else { @@ -295,7 +283,7 @@ render_cell(struct terminal *term, pixman_image_t *pix, pixman_image_t *src = pixman_image_create_solid_fill(&fg); pixman_image_composite32( PIXMAN_OP_OVER, src, glyph->pix, pix, 0, 0, 0, 0, - x + glyph->x, y + term->fonts[0]->ascent - glyph->y, + x + glyph->x, y + font_baseline(term) - glyph->y, glyph->width, glyph->height); pixman_image_unref(src); } @@ -792,7 +780,7 @@ render_search_box(struct terminal *term) pixman_image_t *src = pixman_image_create_solid_fill(&fg); pixman_image_composite32( PIXMAN_OP_OVER, src, glyph->pix, buf->pix, 0, 0, 0, 0, - x + glyph->x, y + term->fonts[0]->ascent - glyph->y, + x + glyph->x, y + font_baseline(term) - glyph->y, glyph->width, glyph->height); pixman_image_unref(src);