aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-11-30 13:51:44 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-11-30 13:51:44 +0000
commit7be98291e161d1c6a0d878285abae4c909e48e0f (patch)
tree7b19f2ac58c2aeb70ee69c1b9b65a3a76a2adc41 /render.c
parentfont: bug: bad multiplier when converting from 16.16 fixed float (diff)
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.
Diffstat (limited to 'render.c')
-rw-r--r--render.c20
1 files 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);