From a36f67cbe311bebd9321fbf58773dace8128fcd7 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sun, 23 Jul 2023 17:35:57 +0200 Subject: render: apply new baseline calculation everywhere * URL jump labels * Scrollback position indicator * Line/box drawings characters Closes #1430 --- render.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) (limited to 'render.c') diff --git a/render.c b/render.c index 48957a0a..9c37f765 100644 --- a/render.c +++ b/render.c @@ -302,17 +302,6 @@ color_brighten(const struct terminal *term, uint32_t color) return hsl_to_rgb(hue, sat, min(100, lum * 1.3)); } -static inline int -font_baseline(const struct terminal *term) -{ - const struct fcft_font *font = term->fonts[0]; - const int line_height = term->cell_height; - const int font_height = font->ascent + font->descent; - const int glyph_top_y = round((line_height - font_height) / 2.); - - return term->font_y_ofs + glyph_top_y + font->ascent; -} - static void draw_unfocused_block(const struct terminal *term, pixman_image_t *pix, const pixman_color_t *color, int x, int y, int cell_cols) @@ -335,7 +324,7 @@ draw_beam_cursor(const struct terminal *term, pixman_image_t *pix, const struct fcft_font *font, const pixman_color_t *color, int x, int y) { - int baseline = y + font_baseline(term) - term->fonts[0]->ascent; + int baseline = y + term_font_baseline(term) - term->fonts[0]->ascent; pixman_image_fill_rectangles( PIXMAN_OP_SRC, pix, color, 1, &(pixman_rectangle16_t){ @@ -347,7 +336,7 @@ draw_beam_cursor(const struct terminal *term, pixman_image_t *pix, static int underline_offset(const struct terminal *term, const struct fcft_font *font) { - return font_baseline(term) - + return term_font_baseline(term) - (term->conf->use_custom_underline_offset ? -term_pt_or_px_as_pixels(term, &term->conf->underline_offset) : font->underline.position); @@ -401,7 +390,7 @@ draw_strikeout(const struct terminal *term, pixman_image_t *pix, pixman_image_fill_rectangles( PIXMAN_OP_SRC, pix, color, 1, &(pixman_rectangle16_t){ - x, y + font_baseline(term) - font->strikeout.position, + x, y + term_font_baseline(term) - font->strikeout.position, cols * term->cell_width, font->strikeout.thickness}); } @@ -767,13 +756,13 @@ 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, - pen_x + letter_x_ofs + g_x, y + font_baseline(term) - g_y, + pen_x + letter_x_ofs + g_x, y + term_font_baseline(term) - g_y, glyph->width, glyph->height); } } else { pixman_image_composite32( PIXMAN_OP_OVER, clr_pix, glyph->pix, pix, 0, 0, 0, 0, - pen_x + letter_x_ofs + g_x, y + font_baseline(term) - g_y, + pen_x + letter_x_ofs + g_x, y + term_font_baseline(term) - g_y, glyph->width, glyph->height); /* Combining characters */ @@ -813,7 +802,7 @@ render_cell(struct terminal *term, pixman_image_t *pix, /* Some fonts use a negative offset, while others use a * "normal" offset */ pen_x + x_ofs + g->x, - y + font_baseline(term) - g->y, + y + term_font_baseline(term) - g->y, g->width, g->height); } } @@ -1937,12 +1926,12 @@ render_osd(struct terminal *term, const struct wayl_sub_surface *sub_surf, if (pixman_image_get_format(glyph->pix) == PIXMAN_a8r8g8b8) { pixman_image_composite32( PIXMAN_OP_OVER, glyph->pix, NULL, buf->pix[0], 0, 0, 0, 0, - x + x_ofs + glyph->x, y + term->font_y_ofs + font->ascent - glyph->y, + x + x_ofs + glyph->x, y + /*term->font_y_ofs + font->ascent*/ term_font_baseline(term) - glyph->y, glyph->width, glyph->height); } else { pixman_image_composite32( PIXMAN_OP_OVER, src, glyph->pix, buf->pix[0], 0, 0, 0, 0, - x + x_ofs + glyph->x, y + term->font_y_ofs + font->ascent - glyph->y, + x + x_ofs + glyph->x, y + /*term->font_y_ofs + font->ascent*/ term_font_baseline(term) - glyph->y, glyph->width, glyph->height); } @@ -3364,7 +3353,7 @@ render_search_box(struct terminal *term) /* Glyph surface is a pre-rendered image (typically a color emoji...) */ pixman_image_composite32( PIXMAN_OP_OVER, glyph->pix, NULL, buf->pix[0], 0, 0, 0, 0, - x + x_ofs + glyph->x, y + font_baseline(term) - glyph->y, + x + x_ofs + glyph->x, y + term_font_baseline(term) - glyph->y, glyph->width, glyph->height); } else { int combining_ofs = width == 0 @@ -3376,7 +3365,7 @@ render_search_box(struct terminal *term) pixman_image_composite32( PIXMAN_OP_OVER, src, glyph->pix, buf->pix[0], 0, 0, 0, 0, x + x_ofs + combining_ofs + glyph->x, - y + font_baseline(term) - glyph->y, + y + term_font_baseline(term) - glyph->y, glyph->width, glyph->height); pixman_image_unref(src); } -- cgit v1.3