From 3eba48d74be2c6539668be9a792377b01ada32bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 7 Jan 2021 11:18:07 +0100 Subject: [PATCH] render: offset all glyphs with {horizontal,vertical}-letter-offset --- render.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/render.c b/render.c index 16198589..4e531207 100644 --- a/render.c +++ b/render.c @@ -256,7 +256,7 @@ color_dim_for_search(pixman_color_t *color) static inline int font_baseline(const struct terminal *term) { - return term->fonts[0]->ascent; + return term->conf->vertical_letter_offset + term->fonts[0]->ascent; } static void @@ -541,18 +541,20 @@ render_cell(struct terminal *term, pixman_image_t *pix, pixman_image_t *clr_pix = pixman_image_create_solid_fill(&fg); if (glyph != NULL) { + const int letter_x_ofs = term->conf->horizontal_letter_offset; + if (unlikely(pixman_image_get_format(glyph->pix) == PIXMAN_a8r8g8b8)) { /* Glyph surface is a pre-rendered image (typically a color emoji...) */ 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 + font_baseline(term) - glyph->y, + x + letter_x_ofs + glyph->x, y + font_baseline(term) - glyph->y, glyph->width, glyph->height); } } else { pixman_image_composite32( PIXMAN_OP_OVER, clr_pix, glyph->pix, pix, 0, 0, 0, 0, - x + glyph->x, y + font_baseline(term) - glyph->y, + x + letter_x_ofs + glyph->x, y + font_baseline(term) - glyph->y, glyph->width, glyph->height); } @@ -589,7 +591,7 @@ render_cell(struct terminal *term, pixman_image_t *pix, pixman_image_composite32( PIXMAN_OP_OVER, clr_pix, g->pix, pix, 0, 0, 0, 0, - x + x_ofs + g->x, y + font_baseline(term) - g->y, + x + letter_x_ofs + x_ofs + g->x, y + font_baseline(term) - g->y, g->width, g->height); } } @@ -1691,6 +1693,8 @@ render_osd(struct terminal *term, struct fcft_font *font = term->fonts[0]; pixman_color_t fg = color_hex_to_pixman(_fg); + const int x_ofs = term->conf->horizontal_letter_offset; + for (size_t i = 0; i < wcslen(text); i++) { const struct fcft_glyph *glyph = fcft_glyph_rasterize( font, text[i], term->font_subpixel); @@ -1701,7 +1705,7 @@ render_osd(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, 0, - x + glyph->x, y + font_baseline(term) - glyph->y, + x + x_ofs + glyph->x, y + font_baseline(term) - glyph->y, glyph->width, glyph->height); pixman_image_unref(src); @@ -2268,6 +2272,7 @@ render_search_box(struct terminal *term) struct fcft_font *font = term->fonts[0]; const int x_left = width - visible_width + margin; + const int x_ofs = term->conf->horizontal_letter_offset; int x = x_left; int y = margin; pixman_color_t fg = color_hex_to_pixman(term->colors.table[0]); @@ -2415,13 +2420,13 @@ 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 + glyph->x, y + font_baseline(term) - glyph->y, + x + x_ofs + glyph->x, y + font_baseline(term) - glyph->y, glyph->width, glyph->height); } else { 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, 0, - x + glyph->x, y + font_baseline(term) - glyph->y, + x + x_ofs + glyph->x, y + font_baseline(term) - glyph->y, glyph->width, glyph->height); pixman_image_unref(src); }